type: log
paths:
{{ range $i, $path := .paths }}
 - {{$path}}
{{ end }}
exclude_files: [".gz$"]
tags: {{.tags | tojson}}
publisher_pipeline.disable_host: {{ inList .tags "forwarded" }}

json.keys_under_root: false

fields_under_root: true
fields:
  network.transport: tcp
  network.protocol: http

processors:
  - rename:
      fields:
        - from: "json"
          to: "zeek.http"

        - from: "zeek.http.id.orig_h"
          to: "source.address"

        - from: "zeek.http.id.orig_p"
          to: "source.port"

        - from: "zeek.http.id.resp_h"
          to: "destination.address"

        - from: "zeek.http.id.resp_p"
          to: "destination.port"

        - from: "zeek.http.uid"
          to: "zeek.session_id"

        - from: "zeek.http.method"
          to: "http.request.method"

        - from: "zeek.http.referrer"
          to: "http.request.referrer"

        - from: "zeek.http.status_code"
          to: "http.response.status_code"

        - from: "zeek.http.version"
          to: "http.version"

        - from: "zeek.http.request_body_len"
          to: "http.request.body.bytes"

        - from: "zeek.http.response_body_len"
          to: "http.response.body.bytes"

        - from: "zeek.http.uri"
          to: "url.original"

        - from: "zeek.http.host"
          to: "url.domain"

        - from: "zeek.http.username"
          to: "url.username"

        - from: "zeek.http.password"
          to: "url.password"

        - from: "zeek.http.user_agent"
          to: "user_agent.original"

      ignore_missing: true
      fail_on_error: false
  - convert:
      fields:
        - {from: "zeek.session_id", to: "event.id"}
        - {from: "source.address", to: "source.ip", type: "ip"}
        - {from: "destination.address", to: "destination.ip", type: "ip"}
        - {from: "destination.port", to: "url.port"}
        - {from: "http.request.method", to: "event.action"}
        - {from: "url.username", to: "user.name"}
      ignore_missing: true
      fail_on_error: false
  - add_fields:
      target: event
      fields:
        kind: event
        category:
          - network
          - web
        type:
          - connection
          - info
          - protocol
  - community_id:
{{ if .internal_networks }}
  - add_network_direction:
      source: source.ip
      destination: destination.ip
      target: network.direction
      internal_networks: {{ .internal_networks | tojson }}
{{ end }}
  - add_fields:
      target: ''
      fields:
        ecs.version: 1.12.0
