# Logstash and http-output plugin

**URL:** <https://discuss.elastic.co/t/logstash-and-http-output-plugin/36203>\
**Category:** Logstash\
**Created:** [December 2, 2015, 4:29pm UTC](https://discuss.elastic.co/t/logstash-and-http-output-plugin/36203 "2015-12-02T16:29:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alvin82](https://avatars.discourse-cdn.com/v4/letter/a/8edcca/32.png) [@Alvin82](https://discuss.elastic.co/u/Alvin82)\
**Post date:** [December 2, 2015, 4:29pm UTC](https://discuss.elastic.co/t/logstash-and-http-output-plugin/36203/1 "2015-12-02T16:29:05Z")

</div>

hi all,  
i've made a config file like this:

```
input {
    file {
        add_field => {"[@metadata][cl_cert]" => "cert.crt"}
        add_field => {"[@metadata][cl_key]" => "private-key.pem"}
        path => "/var/log/*.json"
        start_position => "beginning"
    }
}

filter {
.................
}

output {
        http {
            http_method => "post"
            automatic_retries => 50
            format => "json"
            url => "https://xxx/xxx.php"
            cacert => "/etc/ssl/certs/xxxx.pem"
            client_cert => "/etc/logstash/%{[@metadata][cl_cert]}"
            client_key => "/etc/logstash/%{[@metadata][cl_key]}"
}

```

But i obtain this error:

```
  # This setting must be a path
  # File does not exist or cannot be opened %{[@metadata][client_cert]}
  client_cert => "%{[@metadata][cl_cert]}"

  # This setting must be a path
  # File does not exist or cannot be opened %{[@metadata][client_key]}
  client_key => "%{[@metadata][cl_key]}"

```

The path is correct and the certificate can be used in the http output plugin if i change these lines

```
                client_cert => "/etc/logstash/cert.crt"
                client_key => "/etc/logstash/private-key.pem"

```

How can i avoid this problem?

---

<div class="post-metadata">

**Author:** ![theuntergeek](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/theuntergeek/32/44961_2.png) [@theuntergeek](https://discuss.elastic.co/u/theuntergeek)\
**Post date:** [December 2, 2015, 4:50pm UTC](https://discuss.elastic.co/t/logstash-and-http-output-plugin/36203/2 "2015-12-02T16:50:37Z")

</div>

I don't think that the output settings are configured to do string interpolation (obtain values from fields). This is an interesting and uncommon use-case. I presume that you eventually intend to have multiple keys in the directory, and will dynamically assign them as needed.

The problem is that the http output plugin does not calculate the key for every single event, as this would slow the outbound flow dramatically. Instead, it creates a client connection at start-up, and that requires that the `client_cert` and `client_key` be hard-coded at plugin initialization time. If you need to have multiple certificates, your best bet is to use conditionals to route between multiple http output blocks in your configuration, with each having a hard-coded key.

---

<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 6, 2017, 5:20am UTC](https://discuss.elastic.co/t/logstash-and-http-output-plugin/36203/3 "2017-07-06T05:20:20Z")

</div>


