# How to find top\_metrics value in watcher context when dots in field

**URL:** <https://discuss.elastic.co/t/how-to-find-top-metrics-value-in-watcher-context-when-dots-in-field/262843>\
**Category:** Kibana\
**Tags:** elastic-stack-alerting\
**Created:** [February 1, 2021, 1:31pm UTC](https://discuss.elastic.co/t/how-to-find-top-metrics-value-in-watcher-context-when-dots-in-field/262843 "2021-02-01T13:31:18Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![WernerKwas](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/wernerkwas/32/82886_2.png) [@WernerKwas](https://discuss.elastic.co/u/WernerKwas)\
**Post date:** [February 1, 2021, 1:31pm UTC](https://discuss.elastic.co/t/how-to-find-top-metrics-value-in-watcher-context-when-dots-in-field/262843/1 "2021-02-01T13:31:18Z")

</div>

Hi,

I need some help with the following issue i cannot resolve. Thanks in advance.  
Possibly because the field "[transaction.duration.us](http://transaction.duration.us)" contains dots i'm not able to get the value isolated in the condition section of the watcher.

QUERY:

```auto
         "aggs": {
            "percentiles_calc": {
              "percentiles": {
                "field": "transaction.duration.us",
                "percents": 95,
                "keyed": false
              }
            },
            "last3_hits": {
              "top_metrics": {
                "metrics": {
                  "field": "transaction.duration.us"
                },
                "sort": {
                  "@timestamp": "desc"
                },
                "size": 3
              }
            }
          }
        }
      }
    }
  },
  "condition": {
    "compare": {
      "ctx.payload.aggregations.last3_hits.top.0.metrics": {
        "gt": "{{ctx.payload.aggregations.percentiles_calc.values.0.value}}"
 
QUERY RESULT :

  "aggregations": {
          "percentiles_calc": {
            "values": [
              {
                "value": 724399.9999999987,
                "key": 95
              }
            ]
          },
          "last3_hits": {
            "top": [
              {
                "sort": ["2021-01-20T13:09:55.306Z"],
                "metrics": {
                  "transaction.duration.us": 77000
                }
              },
              {
                "sort": ["2021-01-20T13:09:25.558Z"],
                "metrics": {
                  "transaction.duration.us": 305000
                }
              },
              {
                "sort": ["2021-01-20T13:07:24.159Z"],
                "metrics": {
                  "transaction.duration.us": 121000

CONDITION RESULT:
     "condition": {
      "type": "compare",
      "status": "success",
      "met": false,
      "compare": {
        "resolved_values": {
          "ctx.payload.aggregations.last3_hits.top.0.metrics": {
            **"transaction.duration.us": 77000**
          },
          "ctx.payload.aggregations.percentiles_calc.values.0.value": 724399.9999999987
        }
      }

```

---

<div class="post-metadata">

**Author:** ![Patrick\_Mueller](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/patrick_mueller/32/109425_2.png) [@Patrick\_Mueller](https://discuss.elastic.co/u/Patrick_Mueller)\
**Post date:** [February 4, 2021, 5:22am UTC](https://discuss.elastic.co/t/how-to-find-top-metrics-value-in-watcher-context-when-dots-in-field/262843/2 "2021-02-04T05:22:36Z")

</div>

It seems like this isn't the complete JSON, seeing the whole thing could be useful. Elastic stack version would be useful as well.

Is this while using the Watcher UI in Kibana - if not the Elasticsearch discuss forum might be more appropriate.

It's not clear to me what the stars around the following text are; I would have expected to see the line without stars, so not clear if you got something different. Did you add them as markdown formatting to make that line bold?

```auto
    **"transaction.duration.us": 77000**

```

---

<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:** [March 4, 2021, 5:23am UTC](https://discuss.elastic.co/t/how-to-find-top-metrics-value-in-watcher-context-when-dots-in-field/262843/3 "2021-03-04T05:23:33Z")

</div>

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