# How to get context Alert Data in SUBJECT of Security Alert SIEM

**URL:** <https://discuss.elastic.co/t/how-to-get-context-alert-data-in-subject-of-security-alert-siem/312802>\
**Category:** Endpoint Security\
**Tags:** elastic-stack-alerting\
**Created:** [August 24, 2022, 11:28am UTC](https://discuss.elastic.co/t/how-to-get-context-alert-data-in-subject-of-security-alert-siem/312802 "2022-08-24T11:28:16Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rohit\_Kumbhar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rohit_kumbhar/32/67682_2.png) [@Rohit\_Kumbhar](https://discuss.elastic.co/u/Rohit_Kumbhar)\
**Post date:** [August 24, 2022, 11:28am UTC](https://discuss.elastic.co/t/how-to-get-context-alert-data-in-subject-of-security-alert-siem/312802/1 "2022-08-24T11:28:16Z")

</div>

Hi,

I Have a Security Alert where I have to get data\_stream.namespace and host.name in SUBJECT of Alert

Can someone please guide me through it?

I have tried below but got blank in output mail subject

`Subject : AlertName | {{context.alerts.data_stream.namespace}} | {{context.alerts.host.name}}`

I am getting results in email body as I put following syntax

```auto

{{#context.alerts}}

Namespace : {{data_stream.namespace}}
Hostname : {{host.name}}

{{/context.alerts}}

```

Help would be much appreciated

Thanks !!

---

<div class="post-metadata">

**Author:** ![gmmorris](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gmmorris/32/72624_2.png) [@gmmorris](https://discuss.elastic.co/u/gmmorris)\
**Post date:** [August 24, 2022, 11:33am UTC](https://discuss.elastic.co/t/how-to-get-context-alert-data-in-subject-of-security-alert-siem/312802/2 "2022-08-24T11:33:21Z")

</div>

Hi Rohit,

The reason your subject line is empty is that `context.alerts` is an array and you have to iterate through it, by doing something like: `{{#context.alerts}}{{data_stream.namespace}}{{/context.alerts}}`.

That said, I'm guessing you don't want all the namespaces in your subject line as it would the nbe very long, so perhaps try this: `{{context.alerts.0.data_stream.namespace}}`. This would give you the namespace in the first alert document contained in `context.alerts`.

---

<div class="post-metadata">

**Author:** ![Rohit\_Kumbhar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rohit_kumbhar/32/67682_2.png) [@Rohit\_Kumbhar](https://discuss.elastic.co/u/Rohit_Kumbhar)\
**Post date:** [August 30, 2022, 12:21pm UTC](https://discuss.elastic.co/t/how-to-get-context-alert-data-in-subject-of-security-alert-siem/312802/3 "2022-08-30T12:21:27Z")

</div>

Thanks for the blazing fast reply @gmmorris !  
It really helped !!

---

<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 27, 2022, 12:21pm UTC](https://discuss.elastic.co/t/how-to-get-context-alert-data-in-subject-of-security-alert-siem/312802/4 "2022-09-27T12:21:28Z")

</div>

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