# Using compare on a numaric field

**URL:** <https://discuss.elastic.co/t/using-compare-on-a-numaric-field/232219>\
**Category:** Elasticsearch\
**Tags:** elastic-stack-alerting\
**Created:** [May 12, 2020, 11:31am UTC](https://discuss.elastic.co/t/using-compare-on-a-numaric-field/232219 "2020-05-12T11:31:15Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andrew22](https://avatars.discourse-cdn.com/v4/letter/a/f6c823/32.png) [@Andrew22](https://discuss.elastic.co/u/Andrew22)\
**Post date:** [May 12, 2020, 11:31am UTC](https://discuss.elastic.co/t/using-compare-on-a-numaric-field/232219/1 "2020-05-12T11:31:15Z")

</div>

Hello,

I am having trouble setting up an alert based on a numeric field. I am trying to send an alert when the field is above a certain threshold perhaps somebody could give me a hand. currently I have

```auto
    {
  "trigger": {
    "schedule": {
      "interval": "1d"
    }
  },
  "input": {
    "search": {
      "request": {
        "search_type": "query_then_fetch",
        "indices": [
          "logs-*"
        ],
        "rest_total_hits_as_int": true,
        "body": {
          "query": {
            "bool": {
              "must": [
                {
                  "range": {
                    "seconds": {
                      "gte": "0"
                    }
                  }
                },
                {
                  "range": {
                    "@timestamp": {
                      "gte": "now-1d",
                      "lte": "now"
                    }
                  }
                }
              ]
            }
          }
        }
      }
    }
  },
  "condition": {
    "compare": {
      "ctx.payload.hits.hits.0._source.seconds": {
        "gt": 200
      }
    }
  },
  "actions": {

```

but it detects nothing even though I have events that have the field seconds that are larger then 200.

any help will be much appreciated.

regards,

---

<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:** [June 9, 2020, 11:40am UTC](https://discuss.elastic.co/t/using-compare-on-a-numaric-field/232219/2 "2020-06-09T11:40:34Z")

</div>

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