# How will create a global variable in logstash?

**URL:** <https://discuss.elastic.co/t/how-will-create-a-global-variable-in-logstash/319705>\
**Category:** Logstash\
**Created:** [November 24, 2022, 7:08am UTC](https://discuss.elastic.co/t/how-will-create-a-global-variable-in-logstash/319705 "2022-11-24T07:08:57Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rakhshunda\_Noorein\_J](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rakhshunda_noorein_j/32/99407_2.png) [@Rakhshunda\_Noorein\_J](https://discuss.elastic.co/u/Rakhshunda_Noorein_J)\
**Post date:** [November 24, 2022, 7:08am UTC](https://discuss.elastic.co/t/how-will-create-a-global-variable-in-logstash/319705/1 "2022-11-24T07:08:57Z")

</div>

Hello,

My config is like this -

```auto
input{
http_poller{
// here I have mentioned API url and authorisation
tags => ["tag1"]
}
http_poller{
// here I have mentioned API url and authorisation
tags => ["tag2"]
}
http_poller{
// here I have mentioned API url and authorisation
tags => ["tag3"]
}
}
filter { 
  mutate {
	remove_field => ["[message]" ]
	remove_field => ["[@version]" ]
	remove_field => ["[@timestamp]" ]
	remove_field => ["[event]" ]
  }
}
output{
if "tag1" in tags
{
elasticsearch{
//elastic credentials and index name
}
}
if "tag2" in tags
{
elasticsearch{
//elastic credentials and index name
}
}
if "tag3" in tags
{
elasticsearch{
//elastic credentials and index name
}
}
}

```

Here Api Credentials and Elastic credentials are same for all the tags. So, I want to use a global variable so that I can use it in the configuration.

P.s: I dont want to use environment variable. Is there any other way to do that???

---

<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:** [December 22, 2022, 7:09am UTC](https://discuss.elastic.co/t/how-will-create-a-global-variable-in-logstash/319705/2 "2022-12-22T07:09:36Z")

</div>

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