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: udp
  network.protocol: sip

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

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

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

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

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

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

        - from: "zeek.sip.trans_depth"
          to: "zeek.sip.transaction_depth"

        - from: "zeek.sip.method"
          to: "zeek.sip.sequence.method"

        - from: "zeek.sip.request_from"
          to: "zeek.sip.request.from"

        - from: "zeek.sip.request_to"
          to: "zeek.sip.request.to"

        - from: "zeek.sip.request_path"
          to: "zeek.sip.request.path"

        - from: "zeek.sip.request_body_len"
          to: "zeek.sip.request.body_length"

        - from: "zeek.sip.response_from"
          to: "zeek.sip.response.from"

        - from: "zeek.sip.response_to"
          to: "zeek.sip.response.to"

        - from: "zeek.sip.response_path"
          to: "zeek.sip.response.path"

        - from: "zeek.sip.response_body_len"
          to: "zeek.sip.response.body_length"

        - from: "zeek.sip.status_code"
          to: "zeek.sip.status.code"

        - from: "zeek.sip.status_msg"
          to: "zeek.sip.status.msg"

      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: "zeek.sip.sequence.method", to: "event.action"}
        - {from: "zeek.sip.uri", to: "url.full"}
      ignore_missing: true
      fail_on_error: false
  - add_fields:
      target: event
      fields:
        kind: event
        category:
          - network
        type:
          - connection
          - 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
