# Output conditions with logstash plugin http\_poller

**URL:** <https://discuss.elastic.co/t/output-conditions-with-logstash-plugin-http-poller/294608>\
**Category:** Logstash\
**Created:** [January 17, 2022, 4:26pm UTC](https://discuss.elastic.co/t/output-conditions-with-logstash-plugin-http-poller/294608 "2022-01-17T16:26:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![redaER7](https://avatars.discourse-cdn.com/v4/letter/r/da6949/32.png) [@redaER7](https://discuss.elastic.co/u/redaER7)\
**Post date:** [January 17, 2022, 4:26pm UTC](https://discuss.elastic.co/t/output-conditions-with-logstash-plugin-http-poller/294608/1 "2022-01-17T16:26:49Z")

</div>

I would like to implement a conditional output to Elasticsearch index using logstash http\_poller input plugin. I am using a GET request and sending the response to the index only if the response is not already in the index:

```auto
Read LastMsg every 10 seconds
If LastMsg not in Index:
  write LastMsg in Index

```

For now, I implemented the input section and I would like to develop the output section

```auto
input {
  http_poller {
    urls => {
    api_read_msg ==> {
    method ==> get
    url ==> "https://api.sendgrid.com/v3/messages?limit=1"
    headers ==> {
      Authorization ==> "Bearer ${API_KEY}",
      Content-Type ==> "application/json"
      }
    }
    tags ==> "sendgrid"
    request_timeout ==> 60
    schedue ==> { cron ==> "*/10 * * * * * UTC"}
    coedc => "json"
    metadata_target ==> "http_poller_metadata"
    }
  }
}
output {
  elasticsearch {
    hosts => ['${ES_HOST_ADDRESS}']
    user => '${ES_USER}'
    password => '${ES_PASSWORD}'
    ssl => "true"
    index => "my_index"
  }
  stdout {
    id => "Pipeline_read_api"
    codec => json
  }
}

```

Has any one tried to perform such action ?  
Thanks,

---

<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:** [February 14, 2022, 4:27pm UTC](https://discuss.elastic.co/t/output-conditions-with-logstash-plugin-http-poller/294608/2 "2022-02-14T16:27:06Z")

</div>

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