# Search for last 24 hours logs based on field?

**URL:** <https://discuss.elastic.co/t/search-for-last-24-hours-logs-based-on-field/222582>\
**Category:** Elasticsearch\
**Created:** [March 8, 2020, 5:47am UTC](https://discuss.elastic.co/t/search-for-last-24-hours-logs-based-on-field/222582 "2020-03-08T05:47:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Blason](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/blason/32/42284_2.png) [@Blason](https://discuss.elastic.co/u/Blason)\
**Post date:** [March 8, 2020, 5:47am UTC](https://discuss.elastic.co/t/search-for-last-24-hours-logs-based-on-field/222582/1 "2020-03-08T05:47:34Z")

</div>

Hey Folks,

Can someone please help me on constructing curl based query on src\_ip and agg: those for last 24 hours?

here is something I constructed based on count and need help with for timerange

```auto
curl -s -XGET "https://127.0.0.1:9200/lox-*/_search" -H 'Content-Type: application/json' -d'
{
  "aggs": {
    "ips": {
      "terms": { "field": "src_ip.keyword", "size": 1000 }
      }
    },
  "size" : 0
  }'
}

```

---

<div class="post-metadata">

**Author:** ![Blason](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/blason/32/42284_2.png) [@Blason](https://discuss.elastic.co/u/Blason)\
**Post date:** [March 8, 2020, 5:49am UTC](https://discuss.elastic.co/t/search-for-last-24-hours-logs-based-on-field/222582/2 "2020-03-08T05:49:43Z")

</div>

may be this I tried but not sure how do I agg:src\_ip for last 24 hrs.

````auto
curl -XGET 'https://127.0.01:9200/lox-*/_search?pretty' -H 'Content-Type: application/json' -d'
{
    "query": {
        "range" : {
            "msgSubmissionTime" : {
                "gte" : "now-24h",
                "lt" : "now"
            }
        }
    }
}
```
````

---

<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:** [April 5, 2020, 5:49am UTC](https://discuss.elastic.co/t/search-for-last-24-hours-logs-based-on-field/222582/3 "2020-04-05T05:49:47Z")

</div>

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