# Insert Events with Changed Status Only using Logstash

**URL:** <https://discuss.elastic.co/t/insert-events-with-changed-status-only-using-logstash/319196>\
**Category:** Logstash\
**Created:** [November 17, 2022, 1:03pm UTC](https://discuss.elastic.co/t/insert-events-with-changed-status-only-using-logstash/319196 "2022-11-17T13:03:45Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![sajid](https://avatars.discourse-cdn.com/v4/letter/s/779978/32.png) [@sajid](https://discuss.elastic.co/u/sajid)\
**Post date:** [November 17, 2022, 1:03pm UTC](https://discuss.elastic.co/t/insert-events-with-changed-status-only-using-logstash/319196/1 "2022-11-17T13:03:45Z")

</div>

Hi All,

Need your help to solve an issue. Below are the details:

**Pipeline1** : Polls multiple http endpoints every minute using http\_poller and insert the response to index1 in ES.

Below is the sample response of one of the endpoints:

```auto
{
    "status": "Healthy",
    "totalDuration": "00:00:00.0052662",
    "entries": {
        "testDep-1": {
            "data": {},
            "duration": "00:00:00.0010479",
            "status": "Healthy"
        },
        "testDep-2": {
            "data": {},
            "duration": "00:00:00.0018730",
            "status": "Healthy"
        },
        "testDep-3": {
            "data": {},
            "duration": "00:00:00.0023060",
            "status": "Healthy"
        }
    }
}

```

This logstash pipeline split the response of a http endpoint to multiple events ex. for above it creates 1+3 events. Refer screenshot below:

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/f/4/f4473119a0ccdcacbbcf94af279d302a4b7db96e.png)

**Pipeline2** : Query index1 using elasticsearch input plugin with {"range": {"@timestamp": {"gte": "now-60s","lte": "now"}}} so that only last response of http\_poller can be picked. Then transform some data in filter section and insert into index2 as shown in below image:

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/3/3/33b164eaa1272f59a7ffe4abb337b197413dbc8d.png)

The Pipeline2 is inserting all the events from index1 to index2. Now the requirement is we don't want all the events in index2. We only need events when "status" or "dependency.status" gets changed. i.e. if a URL is responding with "unhealthy" and once that response comes back to healthy state. You can understand it as we need alerts only in the index2.(When a http endpoints becomes unhealthy and when it comes to healthy again without repetitive events ).

We are using basic license and can't use watcher. We want to do this using logstash only. Please guide how can we achieve this.

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [November 17, 2022, 5:11pm UTC](https://discuss.elastic.co/t/insert-events-with-changed-status-only-using-logstash/319196/2 "2022-11-17T17:11:50Z")

</div>

You could use an elasticsearch filter to query index1 for the current value of those fields on the most recent document and drop{} the event if they are unchanged. Alternatively you could use ruby and cache the most recent value for those fields and event.cancel if they are unchanged.

---

<div class="post-metadata">

**Author:** ![sajid](https://avatars.discourse-cdn.com/v4/letter/s/779978/32.png) [@sajid](https://discuss.elastic.co/u/sajid)\
**Post date:** [December 7, 2022, 1:17pm UTC](https://discuss.elastic.co/t/insert-events-with-changed-status-only-using-logstash/319196/3 "2022-12-07T13:17:56Z")

</div>

Hi @Badger,

I tried elasticsearch filter plugin but not couldn't get the desired result. If possible can you please help with some sample code?

---

<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:** [January 4, 2023, 1:18pm UTC](https://discuss.elastic.co/t/insert-events-with-changed-status-only-using-logstash/319196/4 "2023-01-04T13:18:40Z")

</div>

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