# Need to frequently change url-timestamp value within logstash input

**URL:** <https://discuss.elastic.co/t/need-to-frequently-change-url-timestamp-value-within-logstash-input/314026>\
**Category:** Logstash\
**Created:** [September 9, 2022, 1:27am UTC](https://discuss.elastic.co/t/need-to-frequently-change-url-timestamp-value-within-logstash-input/314026 "2022-09-09T01:27:40Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pukar](https://avatars.discourse-cdn.com/v4/letter/p/a9adbd/32.png) [@Pukar](https://discuss.elastic.co/u/Pukar)\
**Post date:** [September 9, 2022, 1:27am UTC](https://discuss.elastic.co/t/need-to-frequently-change-url-timestamp-value-within-logstash-input/314026/1 "2022-09-09T01:27:40Z")

</div>

Hi,  
I'm parsing some json data from a website using rest api with start\_timestamp of 4 hours before current time period. Is there a way within logstash to write such code to get data from last 4 hours on every runtime or is python script the way to go?

Logstash config will run every 5 minutes or so and the input url needs to have its timestamp value changes accordingly.  
`urlname => "https://targetIP/api/v1/alerts?start_timestamp=2022-09-09T00:00:00.000Z+01:00" `

logstash config:

```auto
input{
	http_poller{
		urls =>{
		    urlname => "https://targetIP/api/v1/alerts?start_timestamp=2022-09-09T00:00:00.000Z+01:00"
        }
		user => "user1"
        password => "pwd123"
		request_timeout => 60
		schedule => {every => "30s"}
		codec => "json"
		ssl_verification_mode => "none"
	}
	
}
# Working version: pls do not edit without approval
output{
	elasticsearch{
		hosts => ["https://IP:9200"]
		index => "forescout-alerts"
		ssl => true
		ssl_certificate_verification => false
		user => "uname"
    	password => pwdpwd"
	}

	stdout {codec => rubydebug}
}

```

---

<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 9, 2022, 1:44am UTC](https://discuss.elastic.co/t/need-to-frequently-change-url-timestamp-value-within-logstash-input/314026/2 "2022-09-09T01:44:09Z")

</div>

You could use a heartbeat input to control the schedule, then use an http filter to make the request.

---

<div class="post-metadata">

**Author:** ![Pukar](https://avatars.discourse-cdn.com/v4/letter/p/a9adbd/32.png) [@Pukar](https://discuss.elastic.co/u/Pukar)\
**Post date:** [September 9, 2022, 10:31am UTC](https://discuss.elastic.co/t/need-to-frequently-change-url-timestamp-value-within-logstash-input/314026/3 "2022-09-09T10:31:19Z")

</div>

I'm using python script to calculate the latest timestamp and script is changing the url value. [https://targetIP/api/v1/alerts?start\_timestamp=2022-09-09T00:00:00.000Z+01:00](https://targetIP/api/v1/alerts?start_timestamp=2022-09-09T00:00:00.000Z+01:00)". Is there a way http\_poller can use the py output as url name?

---

<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 9, 2022, 3:56pm UTC](https://discuss.elastic.co/t/need-to-frequently-change-url-timestamp-value-within-logstash-input/314026/4 "2022-09-09T15:56:39Z")

</div>

> [@Pukar](#):
>
> Is there a way http\_poller can use the py output as url name?

No, there is not.

---

<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 7, 2022, 3:57pm UTC](https://discuss.elastic.co/t/need-to-frequently-change-url-timestamp-value-within-logstash-input/314026/5 "2022-10-07T15:57:04Z")

</div>

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