description: Pipeline for parsing icinga debug logs
processors:
- set:
    field: event.ingested
    value: '{{_ingest.timestamp}}'
- grok:
    field: message
    patterns:
    - '\[%{TIMESTAMP:icinga.debug.timestamp}\] %{WORD:log.level}/%{WORD:icinga.debug.facility}:
      %{GREEDYMULTILINE:message}'
    ignore_missing: true
    pattern_definitions:
      TIMESTAMP: '%{YEAR}-%{MONTHNUM}-%{MONTHDAY} %{HOUR}:%{MINUTE}:%{SECOND} %{ISO8601_TIMEZONE}'
      GREEDYMULTILINE: |-
        (.|
        )*
- date:
    field: icinga.debug.timestamp
    target_field: '@timestamp'
    formats:
    - yyyy-MM-dd HH:mm:ss Z
    ignore_failure: true
- remove:
    field: icinga.debug.timestamp
- set:
    field: event.kind
    value: event
- script:
    lang: painless
    source: >-
      def errorLevels = ["warning", "critical"];
      if (ctx?.log?.level != null) {
        if (errorLevels.contains(ctx.log.level)) {
          ctx.event.type = "error";
        } else {
          ctx.event.type = "info";
        }
      }
on_failure:
- set:
    field: error.message
    value: '{{ _ingest.on_failure_message }}'
