How to set a condition in set processor (ingest node pipeline) to check if log.level= error

Hi, my doc looks like this and I need to access log.level which is a nested field. can someone help me as I need a condition to set a new field called statuscode if log.level=error.

image

tried ctx.messageinfo.log.level=="error" and ctx?.messageinfo?.log.level=="error"
both did not work

Think you are looking for this.

POST _ingest/pipeline/_simulate
{
  "pipeline": {
    "processors": [
      {
        "set": {
          "field": "field-name",
          "value": "value",
          "if": "ctx.messageinfo['log.level'] == 'error'"
        }
      }
    ]
  },
  "docs": [
    {
      "_source": {
        "messageinfo": {
          "log.level": "error"
        }
      }
    }
  ]
}
1 Like

Thanks a ton Aaron . This works as expected. Much appreciated!

1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.