# Run http\_poller only once and terminate logstash

**URL:** <https://discuss.elastic.co/t/run-http-poller-only-once-and-terminate-logstash/249029>\
**Category:** Logstash\
**Created:** [September 17, 2020, 7:34pm UTC](https://discuss.elastic.co/t/run-http-poller-only-once-and-terminate-logstash/249029 "2020-09-17T19:34:24Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![hamsinihboomi](https://avatars.discourse-cdn.com/v4/letter/h/8491ac/32.png) [@hamsinihboomi](https://discuss.elastic.co/u/hamsinihboomi)\
**Post date:** [September 17, 2020, 7:34pm UTC](https://discuss.elastic.co/t/run-http-poller-only-once-and-terminate-logstash/249029/1 "2020-09-17T19:34:24Z")

</div>

I have an API call to JIRA which should run only once every 4 weeks. I'm using logstash http\_poller to fetch the data from JIRA.

The schedule with http\_poller does not allow a complex cron schedule so I was planning on setting up an external cron. For this, I need the http\_poller to run only once which works with using schedule as **{"in" =\> "0"}** but logstash is not terminated after the run.

Is there a way to terminate logstash after http\_poller runs once. Or is there an alternative input plugin to fetch API data?

---

<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:** [September 17, 2020, 8:12pm UTC](https://discuss.elastic.co/t/run-http-poller-only-once-and-terminate-logstash/249029/2 "2020-09-17T20:12:49Z")

</div>

> [@hamsinihboomi](#):
>
> Is there a way to terminate logstash after http\_poller runs once. Or is there an alternative input plugin to fetch API data?

Use a stdin input, which will tell logstash to exit when it hits end-of-file. Then run logstash using

```
echo One line | /usr/share/logstash/bin/logstash ...

```

Use an http filter to make the API call.

---

<div class="post-metadata">

**Author:** ![hamsinihboomi](https://avatars.discourse-cdn.com/v4/letter/h/8491ac/32.png) [@hamsinihboomi](https://discuss.elastic.co/u/hamsinihboomi)\
**Post date:** [September 18, 2020, 3:38pm UTC](https://discuss.elastic.co/t/run-http-poller-only-once-and-terminate-logstash/249029/3 "2020-09-18T15:38:23Z")

</div>

Thanks a lot @Badger! I've tried to implement this solution and I'm getting the below error.

> error during HTTP request {:url=\>"URL\_with\_query\_params", :code=\>415, :response=\>""}

The call that I'm making is a GET call to JIRA REST API and here's the configuration I'm using. The URL does have query parameters and I've tried to use **query** property to define the parameters as key-value pairs but no luck.

```auto
input {
	stdin {}
}

filter {
	http {
		url => "URL_with_query_params"
		verb => "GET"
		user => "username"
		password => "password"
		truststore => "path_to_certificate"
		truststore_password => "truststore_password"
	}
}

output {
  stdout { codec => rubydebug }
}

```

Can you please review and let me know why this is not working?

---

<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:** [September 18, 2020, 4:02pm UTC](https://discuss.elastic.co/t/run-http-poller-only-once-and-terminate-logstash/249029/4 "2020-09-18T16:02:05Z")

</div>

A 415 response code would typically indicate an incorrect Content-Type header. You can set the header using the "headers" option...

```
http {
    headers => { "Content-Type" => "text/plain" }
    ...

```

text/plain is just an example. I do not know what the JIRA API expects.

---

<div class="post-metadata">

**Author:** ![hamsinihboomi](https://avatars.discourse-cdn.com/v4/letter/h/8491ac/32.png) [@hamsinihboomi](https://discuss.elastic.co/u/hamsinihboomi)\
**Post date:** [September 18, 2020, 5:22pm UTC](https://discuss.elastic.co/t/run-http-poller-only-once-and-terminate-logstash/249029/5 "2020-09-18T17:22:05Z")

</div>

Thanks a lot for the help @Badger! I was able to successfully implement this. JIRA API was expecting Content-Type as "application/json".

---

<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 16, 2020, 5:22pm UTC](https://discuss.elastic.co/t/run-http-poller-only-once-and-terminate-logstash/249029/6 "2020-10-16T17:22:13Z")

</div>

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