# Variable in HTTP plugin

**URL:** <https://discuss.elastic.co/t/variable-in-http-plugin/322308>\
**Category:** Logstash\
**Created:** [January 2, 2023, 12:02pm UTC](https://discuss.elastic.co/t/variable-in-http-plugin/322308 "2023-01-02T12:02:06Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Anu14](https://avatars.discourse-cdn.com/v4/letter/a/0ea827/32.png) [@Anu14](https://discuss.elastic.co/u/Anu14)\
**Post date:** [January 2, 2023, 12:02pm UTC](https://discuss.elastic.co/t/variable-in-http-plugin/322308/1 "2023-01-02T12:02:06Z")

</div>

Hello,

I have a pretty basic use case for which I am unable to use log stash as intended and would appreciate community's help.

There are 'n' keys that are part of a URL. These keys keep changing on daily basis and I would like to loop through 'n URLs ' formed from those keys and store the data in index.

Below is my conf file where I am using 1 hardcoded key.

```auto
input
{
  http_poller  
    { 
		urls => 
		{
			logs => 
			{
				method => get
				url => "https://someURL/Hardcoded Key value"
				headers => {
					accept => "application/json"
				}
				           
			}
		
		}
		codec => "json_lines"
		schedule => { every => "1m"}
                               
	}
}

filter 
{
	json 
	{
		source => "message"
		some filtering here
	}
	
}

output 
{
	elasticsearch 
	{
		hosts => ["http://localhost:9200"]
		index => "MyIndex"
		user => "UN"
		password => "PW"
	}
}

```

I am looking for a way to use variable for the "key" component in URL and call this script 'n' times.

I am open to other suggestions as well.

---

<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:** [January 2, 2023, 5:40pm UTC](https://discuss.elastic.co/t/variable-in-http-plugin/322308/2 "2023-01-02T17:40:40Z")

</div>

Are you saying you want the url that the http\_poller calls to be variable? I do not think that is possible.

---

<div class="post-metadata">

**Author:** ![Anu14](https://avatars.discourse-cdn.com/v4/letter/a/0ea827/32.png) [@Anu14](https://discuss.elastic.co/u/Anu14)\
**Post date:** [January 2, 2023, 6:19pm UTC](https://discuss.elastic.co/t/variable-in-http-plugin/322308/3 "2023-01-02T18:19:53Z")

</div>

Yes, a part of the URL needs to come from a variable.

Ex:[https://test.sample.com/Logs?$filter=](https://test.sample.com/Logs?%24filter=)((JobKey eq \<\< **JOBKEY** \>\>&$orderby=TimeStamp desc

I want to pass JOBKEY as variable. (There are multiple job keys and they keep changing every 24 hours.)

---

<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:** [January 2, 2023, 6:28pm UTC](https://discuss.elastic.co/t/variable-in-http-plugin/322308/4 "2023-01-02T18:28:56Z")

</div>

You can reference an [environment variable](https://www.elastic.co/guide/en/logstash/current/environment-variables.html), but if the environment changes then logstash will only see the new value if it restarts.

---

<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 30, 2023, 6:29pm UTC](https://discuss.elastic.co/t/variable-in-http-plugin/322308/5 "2023-01-30T18:29:29Z")

</div>

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