# How to get or extract Count of fields using logstash

**URL:** <https://discuss.elastic.co/t/how-to-get-or-extract-count-of-fields-using-logstash/343501>\
**Category:** Logstash\
**Created:** [September 21, 2023, 4:42am UTC](https://discuss.elastic.co/t/how-to-get-or-extract-count-of-fields-using-logstash/343501 "2023-09-21T04:42:50Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ayushi\_bhardwaj](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ayushi_bhardwaj/32/109915_2.png) [@Ayushi\_bhardwaj](https://discuss.elastic.co/u/Ayushi_bhardwaj)\
**Post date:** [September 21, 2023, 4:42am UTC](https://discuss.elastic.co/t/how-to-get-or-extract-count-of-fields-using-logstash/343501/1 "2023-09-21T04:42:50Z")

</div>

Hello,  
I want to extract or get count of fields using logstash. Below is the query i have written but when i put this query in logstash it does not work

this query does not give me the count. pls help

```auto
GET /abc-int-aplha*/_search?pretty
{"size": 0,
"query": {
    "range": {
      "@timestamp": {
        "gte": "now-15m"
      }
    }},
  "aggs": {
    "2": {
      "terms": {
        "field": "measurement",
        "order": {
          "_count": "asc"
        },
        "size": 200
      },
      "aggs": {
        "3": {
          "terms": {
            "field": "e2e.status",
            "order": {
              "_count": "desc"
            },
            "size": 20
          }
        }
      }
    }
  }}
```

---

<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:** [October 19, 2023, 4:43am UTC](https://discuss.elastic.co/t/how-to-get-or-extract-count-of-fields-using-logstash/343501/2 "2023-10-19T04:43:26Z")

</div>

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