# SOLVED - Logstash http output to Kafka REST Proxy

**URL:** <https://discuss.elastic.co/t/solved-logstash-http-output-to-kafka-rest-proxy/281098>\
**Category:** Logstash\
**Created:** [August 11, 2021, 4:02pm UTC](https://discuss.elastic.co/t/solved-logstash-http-output-to-kafka-rest-proxy/281098 "2021-08-11T16:02:43Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![stevetu21](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stevetu21/32/45820_2.png) [@stevetu21](https://discuss.elastic.co/u/stevetu21)\
**Post date:** [August 11, 2021, 4:02pm UTC](https://discuss.elastic.co/t/solved-logstash-http-output-to-kafka-rest-proxy/281098/1 "2021-08-11T16:02:44Z")

</div>

Wanted to share a solution that I found to [Logstash http output to Kafka-REST-Proxy](https://discuss.elastic.co/t/logstash-http-output-to-kafka-rest-proxy/64930) and [Logstash to Confluent kafka rest proxy](https://discuss.elastic.co/t/logstash-to-confluent-kafka-rest-proxy/96213). Was running into the same issue trying to use the http output to write a confluent Kafka REST proxy, but couldn't find any answers. Managed to figure it out. Wanted to share the solution that worked for me here (and probably future me will be most thankful if this helps nobody else!).

```auto
output {
    http {
        http_method => "post"
        url => "https://example.host/kafka-rest/customer/topics/TOPIC_HERE?apikey=X"
        headers => ["Accept", "application/vnd.kafka.v2+json, application/vnd.kafka+json, application/json"]
        content_type => "application/vnd.kafka.json.v2+json"
        format => "message"
        message => '{
                        "records":[
                            {
                                "key": "%{key}",
                                "value": {
                                    "f1": "%{f1}",
                                    "f2": "%{f2}"
                                }
                            }
                        ]
                    }'
    }
}

```

Above is assuming that `key`, `f1`, and `f2` fields exist in the event (whether via input or created by add\_field, or whatever).

Also, this Kafka REST POST doc can be helpful: [Confluent REST Proxy API Reference | Confluent Documentation](https://docs.confluent.io/platform/current/kafka-rest/api.html#post--topics-(string-topic_name))

Was using Logstash 6.5.1 (don't judge), but imagine would work similarly on newer versions as well.

---

<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:** [September 8, 2021, 4:02pm UTC](https://discuss.elastic.co/t/solved-logstash-http-output-to-kafka-rest-proxy/281098/2 "2021-09-08T16:02:54Z")

</div>

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