# Bucket level monitor include document field like sample\_documents for dedupedAlerts and completedAlerts

**URL:** <https://forum.opensearch.org/t/bucket-level-monitor-include-document-field-like-sample-documents-for-dedupedalerts-and-completedalerts/18741>\
**Category:** Alerting\
**Created:** [April 6, 2024, 1:27pm UTC](https://forum.opensearch.org/t/bucket-level-monitor-include-document-field-like-sample-documents-for-dedupedalerts-and-completedalerts/18741 "2024-04-06T13:27:35Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![hm21](https://avatars.discourse-cdn.com/v4/letter/h/8dc957/32.png) [@hm21](https://forum.opensearch.org/u/hm21)\
**Post date:** [April 6, 2024, 1:27pm UTC](https://forum.opensearch.org/t/bucket-level-monitor-include-document-field-like-sample-documents-for-dedupedalerts-and-completedalerts/18741/1 "2024-04-06T13:27:35Z")

</div>

**Versions** (relevant - OpenSearch/Dashboard/Server OS/Browser):  
2.13.0

**Describe the issue** :

I have a bucket level monitor with the following query:

```auto
{
    "size": 1,
    "query": {
        "bool": {
            "filter": [
                {
                    "range": {
                        "@timestamp": {
                            "from": "{{period_end}}||-1h",
                            "to": "{{period_end}}",
                            "include_lower": true,
                            "include_upper": true,
                            "format": "epoch_millis",
                            "boost": 1
                        }
                    }
                },
                {
                    "match_phrase": {
                        "MESSAGE": {
                            "query": "*connection failed*",
                            "slop": 0,
                            "zero_terms_query": "NONE",
                            "boost": 1
                        }
                    }
                }
            ],
            "adjust_pure_negative": true,
            "boost": 1
        }
    },
    "aggregations": {
        "composite_agg": {
            "composite": {
                "size": 10,
                "sources": [
                    {
                        "hostname": {
                            "terms": {
                                "field": "hostname",
                                "missing_bucket": false,
                                "order": "asc"
                            }
                        }
                    }
                ]
            }
        }
    }
}

```

The index/documents this query is used on has also a field named “MESSAGE”. I want to include that field named “MESSAGE” into the notification message but not use group by on it in the query.

`ctx.results.0.hits.hits` does not work here because I want the “MESSAGE” field from one of the grouped by elements and not a random “MESSAGE” field value.

Does anybody have an idea how to do that?

btw.: the new `sample_documents` would work here but I want that not only for `newAlerts` but also for `dedupedAlerts` and `completedAlerts` and `sample_documents`only works for `newAlerts`.

---

<div class="post-metadata">

**Author:** ![hm21](https://avatars.discourse-cdn.com/v4/letter/h/8dc957/32.png) [@hm21](https://forum.opensearch.org/u/hm21)\
**Post date:** [April 10, 2024, 4:56pm UTC](https://forum.opensearch.org/t/bucket-level-monitor-include-document-field-like-sample-documents-for-dedupedalerts-and-completedalerts/18741/2 "2024-04-10T16:56:41Z")

</div>

any ideas?

---

<div class="post-metadata">

**Author:** ![hm21](https://avatars.discourse-cdn.com/v4/letter/h/8dc957/32.png) [@hm21](https://forum.opensearch.org/u/hm21)\
**Post date:** [April 12, 2024, 8:21am UTC](https://forum.opensearch.org/t/bucket-level-monitor-include-document-field-like-sample-documents-for-dedupedalerts-and-completedalerts/18741/3 "2024-04-12T08:21:35Z")

</div>

any ideas would be highly appreciated

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex019/uploads/mauve_hedgehog/original/2X/3/33547ea01a5b12dcca2958411d3edd97ae2ea8c1.png) [@system](https://forum.opensearch.org/u/system)\
**Post date:** [June 11, 2024, 8:22am UTC](https://forum.opensearch.org/t/bucket-level-monitor-include-document-field-like-sample-documents-for-dedupedalerts-and-completedalerts/18741/4 "2024-06-11T08:22:01Z")

</div>

Closed on June 11, 2024, 8:22am UTC

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