# Elastic Search by Date Range

**URL:** <https://discuss.elastic.co/t/elastic-search-by-date-range/285869>\
**Category:** Logs\
**Created:** [October 5, 2021, 3:27am UTC](https://discuss.elastic.co/t/elastic-search-by-date-range/285869 "2021-10-05T03:27:51Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Raghavendra\_B](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/raghavendra_b/32/77615_2.png) [@Raghavendra\_B](https://discuss.elastic.co/u/Raghavendra_B)\
**Post date:** [October 5, 2021, 3:27am UTC](https://discuss.elastic.co/t/elastic-search-by-date-range/285869/1 "2021-10-05T03:27:51Z")

</div>

Hello,

I want to see the logs for **last 5 minutes from particular timestamp**.

I am constructing elastic log url dynamically for alert message (with timestamp i.e the alert triggered time). For specifying date range for logs, i don't have context of start time. So i have to look for last 5 min logs (alert trigger for 5 min ).

Ex:

```auto
     start: "~5m ago" and end:alertTriggertrdTime
     logPosition=(end:alertTriggertrdTime,position:!n,start:~5m ago,streamLive:!f)

```

But didn't workout for me. Could you please help us on this issue.

 ![Screenshot 2021-10-05 at 8.16.47 AM](https://us1.discourse-cdn.com/elastic/original/3X/f/f/ff8fe1b2ffb777a0e99619b9c535e4961a32f8c0.png)

---

<div class="post-metadata">

**Author:** ![weltenwort](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/weltenwort/32/53885_2.png) [@weltenwort](https://discuss.elastic.co/u/weltenwort)\
**Post date:** [October 26, 2021, 11:28am UTC](https://discuss.elastic.co/t/elastic-search-by-date-range/285869/2 "2021-10-26T11:28:35Z")

</div>

Hi @Raghavendra_B,

we have special routes to open the logs stream at a specific time:

```auto
/app/logs/link-to/logs?time=${TIMESTAMP}

```

where you replace `${TIMESTAMP}` with a millisecond epoch value like `1635247161801`. Then the Logs UI would set the time range to `TIMESTAMP - 1 hour` until `TIMESTAMP + 1 hour` and center on the given `TIMESTAMP`.

Does that help in your use-case?

---

<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:** [November 23, 2021, 11:28am UTC](https://discuss.elastic.co/t/elastic-search-by-date-range/285869/3 "2021-11-23T11:28:54Z")

</div>

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