# Logstash HTTP output plugin not reading metadata fields correctly for user/password fields, what am I doing wrong

**URL:** https://discuss.elastic.co/t/logstash-http-output-plugin-not-reading-metadata-fields-correctly-for-user-password-fields-what-am-i-doing-wrong/269482
**Category:** Logstash
**Created:** [April 7, 2021, 2:23pm UTC](https://discuss.elastic.co/t/logstash-http-output-plugin-not-reading-metadata-fields-correctly-for-user-password-fields-what-am-i-doing-wrong/269482 "2021-04-07T14:23:20Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![R.L](https://avatars.discourse-cdn.com/v4/letter/r/22d042/32.png) [@R.L](https://discuss.elastic.co/u/R.L)
#### Post date: [April 7, 2021, 2:23pm UTC](https://discuss.elastic.co/t/logstash-http-output-plugin-not-reading-metadata-fields-correctly-for-user-password-fields-what-am-i-doing-wrong/269482/1 "2021-04-07T14:23:20Z")

</div>

This is my config:

```auto
filter {
		
        prune {
        blacklist_names => ["timestamp", "path", "size", "@version", "host"]
      }
	     
      uuid {
        target => "[@metadata][snapshot][id]"
        overwrite => true
      
   }
   
   mutate {

	  add_field => { "[@metadata][snapshot][repo]" => "minio_test" }
	  add_field => { "[@metadata][elastic][host]" => "xxx" }
	  add_field => { "[@metadata][elastic][port]" => "xxx" }
	  add_field => { "[@metadata][elastic][protocol]" => "https"}
	  add_field => { "[@metadata][elastic][user]" => "xxx" }
	  add_field => { "[@metadata][elastic][password]" => xxx}
   }

}

```

```auto
output {

   http {

    follow_redirects => false
    http_method => "put"
	format => "json"
    url => "%{[@metadata][elastic][protocol]}://%{[@metadata][elastic][host]}:%{[@metadata][elastic][port]}/_snapshot/%{[@metadata][snapshot][repo]}/%{[@metadata][snapshot][id]}"
	user => "%{[@metadata][elastic][user]}"
	password => "%{[@metadata][elastic][password]}"

  }

}

```

This is output through stdout:

```auto
{
                 "indices" => "<blah>",
      "ignore_unavailable" => true,
               "@metadata" => {
            "path" => "<blah>",
         "elastic" => {
                "port" => "xxx",
                "host" => "xxx",
            "password" => "xxx",
            "protocol" => "https",
                "user" => "xxx"
        },
            "host" => "<blah>",
        "snapshot" => {
              "id" => "eedcb560-46b8-4486-9af8-4cdb42074111",
            "repo" => "minio_test"
        }
    },
    "include_global_state" => false
}

```

So it seems like the metadata fields are filled out properly by filter mutate plugin, however on REST endpoint side, I see:

**"message": "Authentication finally failed for %{[@metadata][elastic][user]}**

So it seems like the http output user field is not being filled in properly with data in [@metadata] when I try to use it in HTTP output plugin.

Funnily enough, the url field gets filled in with [@metadata] fields perfectly.

When I just used string literal to fill out user/password fields, it works perfectly.

What am I doing wrong?

---

<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: [April 7, 2021, 2:32pm UTC](https://discuss.elastic.co/t/logstash-http-output-plugin-not-reading-metadata-fields-correctly-for-user-password-fields-what-am-i-doing-wrong/269482/2 "2021-04-07T14:32:37Z")

</div>

The [code](https://github.com/logstash-plugins/logstash-mixin-http_client/blob/671005ce0f7769938bbf2f5a417f7212f4c7209e/lib/logstash/plugin_mixins/http_client.rb#L131) does not sprintf the user and password options. It [does](https://github.com/logstash-plugins/logstash-output-http/blob/cfcf57c3746f71698269dc6cf6fa443c7a006960/lib/logstash/outputs/http.rb#L229) sprintf the url, so this is working as expected.

---

<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: [May 5, 2021, 2:33pm UTC](https://discuss.elastic.co/t/logstash-http-output-plugin-not-reading-metadata-fields-correctly-for-user-password-fields-what-am-i-doing-wrong/269482/3 "2021-05-05T14:33:32Z")

</div>

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