# Can Output elasticsearch plugin credential use @metadata?

**URL:** https://discuss.elastic.co/t/can-output-elasticsearch-plugin-credential-use-metadata/181980
**Category:** Logstash
**Created:** [May 21, 2019, 10:34am UTC](https://discuss.elastic.co/t/can-output-elasticsearch-plugin-credential-use-metadata/181980 "2019-05-21T10:34:34Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![mmk1995](https://avatars.discourse-cdn.com/v4/letter/m/8797f3/32.png) [@mmk1995](https://discuss.elastic.co/u/mmk1995)
#### Post date: [May 21, 2019, 10:34am UTC](https://discuss.elastic.co/t/can-output-elasticsearch-plugin-credential-use-metadata/181980/1 "2019-05-21T10:34:34Z")

</div>

Dear All,

I am trying to use @metadata that has defined in filter for the user and password fields in output, is that possible or is there another way? Please see below configuration:

> output {  
> elasticsearch {  
> hosts=\> ["[https://xxxxxxxxxxxxxxxxx](https://xxxxxxxxxxxxxxxxx)"]  
> ssl =\> true  
> ssl\_certificate\_verification =\> true  
> cacert =\> "/etc/logstash/xxxxxxxxxxxxxxxxx"  
> user=\> "%{[@metadata][logstash\_username]}"  
> password=\> "%{[@metadata][logstash\_password]}"  
> index =\> "xxxxxxxxxxxxxxxxx}"  
> }  
> jdbc {  
> connection\_string =\> "%{[@metadata][connString]}"  
> statement =\> xxxxxxxxxxxxxxxxx  
> }
> 
> jdbc {  
> connection\_string =\> "%{[@metadata][connString]}"  
> statement =\> xxxxxxxxxxxxxxxxx  
> }  
> }

---

<div class="post-metadata">

### Author: ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)
#### Post date: [May 21, 2019, 7:52pm UTC](https://discuss.elastic.co/t/can-output-elasticsearch-plugin-credential-use-metadata/181980/2 "2019-05-21T19:52:53Z")

</div>

The Elasticsearch output plugin sends bulk requests, so setting a parameter that is applied per request (multiple documents) based on a field that can vary across events in that batch does not IMHO make sense. What is it you are trying to achieve?

---

<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: [May 21, 2019, 10:02pm UTC](https://discuss.elastic.co/t/can-output-elasticsearch-plugin-credential-use-metadata/181980/3 "2019-05-21T22:02:24Z")

</div>

Also, my reading of the code is that the basic\_auth configuration is done at startup time, so there is no event from which fields or metadata can be referenced.

---

<div class="post-metadata">

### Author: ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)
#### Post date: [May 22, 2019, 1:08am UTC](https://discuss.elastic.co/t/can-output-elasticsearch-plugin-credential-use-metadata/181980/4 "2019-05-22T01:08:48Z")

</div>

That is probably true as well.

---

<div class="post-metadata">

### Author: ![mmk1995](https://avatars.discourse-cdn.com/v4/letter/m/8797f3/32.png) [@mmk1995](https://discuss.elastic.co/u/mmk1995)
#### Post date: [May 22, 2019, 1:24am UTC](https://discuss.elastic.co/t/can-output-elasticsearch-plugin-credential-use-metadata/181980/5 "2019-05-22T01:24:37Z")

</div>

Hello Badgar and Dahlqvist,

I am using ruby to call a servlet in filter and returned the username and password of ElasticSearch. I am trying to store the values as metadata and use those in the output. Could you suggest another way to achieve this?

Thank you.

---

<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: [May 22, 2019, 1:32am UTC](https://discuss.elastic.co/t/can-output-elasticsearch-plugin-credential-use-metadata/181980/6 "2019-05-22T01:32:37Z")

</div>

It is possible that an environment reference rather than a sprintf reference would work. I have not tested it, but perhaps you can use logstash or curl or something else to do the servlet call and then pass the variables to elastic as via the [environment](https://www.elastic.co/guide/en/logstash/current/environment-variables.html).

---

<div class="post-metadata">

### Author: ![mmk1995](https://avatars.discourse-cdn.com/v4/letter/m/8797f3/32.png) [@mmk1995](https://discuss.elastic.co/u/mmk1995)
#### Post date: [May 22, 2019, 1:49am UTC](https://discuss.elastic.co/t/can-output-elasticsearch-plugin-credential-use-metadata/181980/7 "2019-05-22T01:49:20Z")

</div>

Do you mean pass the variable to Logstash instead of elastic?  
Also, can I reference the environment variable in the output elasticsearch plugin?

---

<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: [June 19, 2019, 1:49am UTC](https://discuss.elastic.co/t/can-output-elasticsearch-plugin-credential-use-metadata/181980/8 "2019-06-19T01:49:22Z")

</div>

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