# Kibana Alerting Es query with field runtime\_mappings

**URL:** <https://discuss.elastic.co/t/kibana-alerting-es-query-with-field-runtime-mappings/307097>\
**Category:** Kibana\
**Tags:** runtime-fields\
**Created:** [June 14, 2022, 6:50am UTC](https://discuss.elastic.co/t/kibana-alerting-es-query-with-field-runtime-mappings/307097 "2022-06-14T06:50:39Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![hanstf](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hanstf/32/106980_2.png) [@hanstf](https://discuss.elastic.co/u/hanstf)\
**Post date:** [June 14, 2022, 6:50am UTC](https://discuss.elastic.co/t/kibana-alerting-es-query-with-field-runtime-mappings/307097/1 "2022-06-14T06:50:40Z")

</div>

I am trying to create an Alert rule with es query that contains runtime mappings ([Elasticsearch query | Kibana Guide [7.13] | Elastic](https://www.elastic.co/guide/en/kibana/7.13/rule-type-es-query.html)).  
My rule is like below:

```auto
{
  "runtime_mappings": {
    "file_found_status": {
      "type": "keyword",
      "script": {
        "source": """
      if (doc['kubernetes.labels.app.keyword'].value == 'test') {
        if (doc['message_nonjson.keyword'].value.contains("FILE_" + doc['@timestamp'].value.toString("YYYYMMdd"))) {
          emit("file found")  
        } else {
          emit("file not found")  
        }
      }
    """
      }
    }
  },
  "fields": [
    "file_found_status"
  ],
  "query": {
    "bool": {
      "must": [
        {
          "match": {
            "file_found": "file not found"
          }
        }
      ]
    }
  }
}

```

The query is working on the dev tools and there are some documents matched, but I test on the "Test Query" inside the "create rule" page, it always show as 0 document matched.

I am using kibana version: 7.13.4

Does Alert rule does not support runtime\_mappings ?

---

<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:** [July 12, 2022, 6:51am UTC](https://discuss.elastic.co/t/kibana-alerting-es-query-with-field-runtime-mappings/307097/2 "2022-07-12T06:51:06Z")

</div>

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