How to include log field value in the alert body message

Hello there,

I would like to include a log's field value in the alert body message. The alert is pushed to slack channel. From the log entry below, I wanted to include the payload.message and payload.customData.orders

The log entry

    {
   "metaData":{
      "timestamp":"2020-08-21T07:06:56.648Z",
      "appVersion":"0.0.1-SNAPSHOT",
      "appName":"cr-order-monitor",
      "logger":"http-nio-8080-exec-2",
      "priority":"ERROR",
      "envName":"dev",
      "envHost":"localhost",
      "tracePoint":"END"
   },
   "payload":{
      "class":"com.inventoryfilesuploader.controllers.FileUploadController:47",
     "message":"Price mismatch",
      "customData":{
​         "orders": [ "order_id1", "order_id2", "order_id3" ]
      },
      "exception":""
   }
} 

the configuration for the trigger action is below

Monitor {{ctx.monitor.name}} just entered alert status. Please investigate the issue.
- Message: {{ctx.payload.message}}
- Trigger: {{ctx.trigger.name}}
- Severity: {{ctx.trigger.severity}}
- Period start: {{ctx.periodStart}}
- Period end: {{ctx.periodEnd}}

The above is not printing the value of the payload.mesage. I tried {{ctx.payload.hits}}. If I print out the whole {{ctx}} in the body I get the folllowing

    {monitor={_id=FofyAHQBm5zOLdVNL306, _version=105, name=Inventory File Monitor S307, enabled=true}, trigger={id=GYfzAHQBm5zOLdVNZX1e, name=Inventory File Missing S307, severity=4, actions=[{name=Missing Inventory File from S307}]}, results=[{_shards={total=35, failed=0, successful=35, skipped=0}, hits={hits=[], total={value=2, relation=eq}, max_score=null}, took=8, timed_out=false}], periodStart=2020-08-21T07:44:10.087Z, periodEnd=2020-08-21T07:45:10.087Z, alert={acknowledged_time=null, id=7YT5D3QBnr12y3m8mqFF, version=-1, end_time=null, error_message=null, last_notification_time=1597995850206, severity=4, start_time=1597995850206, state=ACTIVE}, error=null}

Thanks in advance

I'm not very familiar with the actions in Kibana, but it looks like payload is not present in ctx from your example, which would cause errors. I think you might get better help in the alerting forum: https://discuss.elastic.co/tag/stack-alerting

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