{
  "description": "Pipeline for parsing MongoDB logs",
  "processors": [{
    "grok": {
      "field": "message",
      "patterns":[
        "%{TIMESTAMP_ISO8601:mongodb.log.timestamp} %{WORD:mongodb.log.severity} %{WORD:mongodb.log.component} \\s*\\[%{WORD:mongodb.log.context}\\] %{GREEDYDATA:mongodb.log.message}"
      ],
      "ignore_missing": true
    }
  },
  {
    "remove": {
      "field": "message"
    }
  },
  {
    "rename": {
      "field": "@timestamp",
      "target_field": "read_timestamp"
    }
  },
  {
    "date": {
      "field": "mongodb.log.timestamp",
      "target_field": "@timestamp",
      "formats": ["yyyy-MM-dd'T'HH:mm:ss.SSSZZ"]
    }
  },
  {
    "remove": {
      "field": "mongodb.log.timestamp"
    }
  }],
  "on_failure" : [{
    "set" : {
      "field" : "error.message",
      "value" : "{{ _ingest.on_failure_message }}"
    }
  }]
}
