# Pass an array data as a variable to URL of http logstash plugin

**URL:** https://discuss.elastic.co/t/pass-an-array-data-as-a-variable-to-url-of-http-logstash-plugin/307186
**Category:** Logstash
**Created:** [June 14, 2022, 4:06pm UTC](https://discuss.elastic.co/t/pass-an-array-data-as-a-variable-to-url-of-http-logstash-plugin/307186 "2022-06-14T16:06:29Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![santhoshi.p](https://avatars.discourse-cdn.com/v4/letter/s/43a26b/32.png) [@santhoshi.p](https://discuss.elastic.co/u/santhoshi.p)
#### Post date: [June 14, 2022, 4:06pm UTC](https://discuss.elastic.co/t/pass-an-array-data-as-a-variable-to-url-of-http-logstash-plugin/307186/1 "2022-06-14T16:06:29Z")

</div>

Hi,

I am trying to pass an array to a URL as a loop could you please help me to acheive this in logstash pipeline.  
Any suggestions that is provided is helpful  
.  
My response is below:  
nodeId: 9  
"datasource" =\> [  
[0] "ciscoSupyState",  
[1] "tcpAttemptFails",  
[2] "tcpInSegs",  
[3] "tcpRetransSegs"]

http plugin code:

http {  
url =\> "[http://XXXXXX/node[%{nodeId}].nodeSnmp[]/%{datasource}](http://XXXXXX/node%5B%25%7BnodeId%7D%5D.nodeSnmp%5B%5D/%25%7Bdatasource%7D)"  
verb =\> "GET"  
user =\> "xxxx"  
password =\> "xxx"  
target\_body =\> "xxxx"  
target\_headers =\> "xxx"  
headers =\> {  
"Content-Type" =\> "application/json"  
"Accept" =\> "application/json"  
} }

---

<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: [June 14, 2022, 4:13pm UTC](https://discuss.elastic.co/t/pass-an-array-data-as-a-variable-to-url-of-http-logstash-plugin/307186/2 "2022-06-14T16:13:13Z")

</div>

See [this](https://discuss.elastic.co/t/parse-array-and-send-to-elastic-filter/306271/2) thread.

---

<div class="post-metadata">

### Author: ![santhoshi.p](https://avatars.discourse-cdn.com/v4/letter/s/43a26b/32.png) [@santhoshi.p](https://discuss.elastic.co/u/santhoshi.p)
#### Post date: [June 14, 2022, 4:40pm UTC](https://discuss.elastic.co/t/pass-an-array-data-as-a-variable-to-url-of-http-logstash-plugin/307186/3 "2022-06-14T16:40:21Z")

</div>

Hi Badger,

Thank you for your reply.

But the elements in datasource are variable componet as they are not fixed. Please find the below response in detail.

{  
"datasource" =\> [  
[0] "ciscoMemoryPoolUsed",  
[1] "ciscoSupyState",  
[2] "csSupSource",  
[3] "tcpEstabResets",  
[4] "CiscoEnvMonState",  
[5] "ciscoMemoryPoolFree"  
[6],......  
],  
"DatasourceNodeId" =\> "2",  
"@timestamp" =\> 2022-06-14T16:38:16.628472Z  
}  
{  
"DatasourceNodeId" =\> "1"  
"datasource" =\> [  
[0] "icmp",  
[1] "http",  
[2] "https"  
],

---

<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: [June 14, 2022, 4:45pm UTC](https://discuss.elastic.co/t/pass-an-array-data-as-a-variable-to-url-of-http-logstash-plugin/307186/4 "2022-06-14T16:45:56Z")

</div>

If neither approach in the linked thread works for you I would suggest making the http call from a ruby filter instead of using an http filter.

---

<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: [July 12, 2022, 4:46pm UTC](https://discuss.elastic.co/t/pass-an-array-data-as-a-variable-to-url-of-http-logstash-plugin/307186/5 "2022-07-12T16:46:26Z")

</div>

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