# How to include log field value in the alert body message

**URL:** <https://discuss.elastic.co/t/how-to-include-log-field-value-in-the-alert-body-message/245876>\
**Category:** Kibana\
**Tags:** elastic-stack-alerting, kql-kibana-query-language\
**Created:** [August 21, 2020, 8:24am UTC](https://discuss.elastic.co/t/how-to-include-log-field-value-in-the-alert-body-message/245876 "2020-08-21T08:24:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![akhettar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/akhettar/32/74293_2.png) [@akhettar](https://discuss.elastic.co/u/akhettar)\
**Post date:** [August 21, 2020, 8:24am UTC](https://discuss.elastic.co/t/how-to-include-log-field-value-in-the-alert-body-message/245876/1 "2020-08-21T08:24:38Z")

</div>

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

```auto
    {
   "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

```auto
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

```auto
    {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

 ![Screenshot 2020-08-21 at 10.20.18](https://us1.discourse-cdn.com/elastic/original/3X/6/e/6e6e8168f253aff1578ff1ca48d73310a58a50ec.png)

---

<div class="post-metadata">

**Author:** ![wylie](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/wylie/32/81794_2.png) [@wylie](https://discuss.elastic.co/u/wylie)\
**Post date:** [August 24, 2020, 5:10pm UTC](https://discuss.elastic.co/t/how-to-include-log-field-value-in-the-alert-body-message/245876/2 "2020-08-24T17:10:22Z")

</div>

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](https://discuss.elastic.co/tag/stack-alerting)

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [September 21, 2020, 5:10pm UTC](https://discuss.elastic.co/t/how-to-include-log-field-value-in-the-alert-body-message/245876/3 "2020-09-21T17:10:42Z")

</div>

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