# HTTP output for stadtpuls.com IoT platform

**URL:** <https://discuss.elastic.co/t/http-output-for-stadtpuls-com-iot-platform/296777>\
**Category:** Logstash\
**Created:** [February 9, 2022, 6:09pm UTC](https://discuss.elastic.co/t/http-output-for-stadtpuls-com-iot-platform/296777 "2022-02-09T18:09:04Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![CargoBikoMeter](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cargobikometer/32/101615_2.png) [@CargoBikoMeter](https://discuss.elastic.co/u/CargoBikoMeter)\
**Post date:** [February 9, 2022, 6:09pm UTC](https://discuss.elastic.co/t/http-output-for-stadtpuls-com-iot-platform/296777/1 "2022-02-09T18:09:04Z")

</div>

Currently I have a working logstash configuration which stores JSON based input data from my IoT data from TTN via output into my Elasticsearch node. Now I would extract some data (e.g. temperature, pressure) and send only the field measurements via http output to the [stadtpuls.com](http://stadtpuls.com) API. Currently I use the following filter statement among many others:

```auto
  ### BEGIN stadtpuls.com encoder
      if ( [dev_id] == "akiot-htcc-ab01-umweltsensor01") {
          mutate {
            add_field => {"measurements" => ["%{temperature}","%{pressure}"]}
          }
        }
      ### END stadtpuls.com encoder

```

But how can I prevent that the http output sends the entire JSON based event document to the API?

---

<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:** [February 9, 2022, 6:12pm UTC](https://discuss.elastic.co/t/http-output-for-stadtpuls-com-iot-platform/296777/2 "2022-02-09T18:12:31Z")

</div>

> [@CargoBikoMeter](#):
>
> how can I prevent that the http output sends the entire JSON based event document to the API?

You could use a [prune](https://www.elastic.co/guide/en/logstash/current/plugins-filters-prune.html) filter with a whitelist\_names options. If you have multiple outputs you might need pipeline-to-pipeline communications with a [forked-path](https://www.elastic.co/guide/en/logstash/current/pipeline-to-pipeline.html#forked-path-pattern) pattern.

---

<div class="post-metadata">

**Author:** ![CargoBikoMeter](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cargobikometer/32/101615_2.png) [@CargoBikoMeter](https://discuss.elastic.co/u/CargoBikoMeter)\
**Post date:** [February 11, 2022, 8:45pm UTC](https://discuss.elastic.co/t/http-output-for-stadtpuls-com-iot-platform/296777/3 "2022-02-11T20:45:13Z")

</div>

Thanks for the advice with the forked-pattern. Now it is working, I defined one input and two output pipelines. How could I suppress the app\_id tag from output processing, if I use that tag currently for suppressing unneeded output?

Currently pipeline definition: **pipelines.yml**

```auto
- pipeline.id: input
  queue.type: persisted
  path.config: "/etc/logstash/conf.d/input.conf"

- pipeline.id: buffered-es
  queue.type: persisted
  path.config: "/etc/logstash/conf.d/es.conf"

- pipeline.id: buffered-stadtpuls
  queue.type: persisted
  path.config: "/etc/logstash/conf.d/stadtpuls.conf"

```

**/etc/logstash/conf.d/stadtpuls.conf:**

```auto
input { pipeline { address => "stadtpuls" } }

filter {
# process data for stadtpuls
      mutate {
        add_field => ["app_id", "%{[end_device_ids][application_ids][application_id]}" ]
      } # mutate

     # measurements[temperature,pressure,humidity,p10,p25,voltage]
      mutate {
       add_field => {
          "measurements" => [
             ......
         ]
     }
       }

     mutate { remove_field => ["app_id","@version","@timestamp","host","received_at","_source","headers","correlation_ids","uplink_message","end_device_ids"] }

} # filter

output {
     if ([app_id] == "adlerkiez-pm-sensor-01") {
         http {
            .....
        }
    } # if app_id

```

Is it possible to filter not desired input at an earlier stage in the pipeline processing chain?

---

<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:** [February 11, 2022, 10:31pm UTC](https://discuss.elastic.co/t/http-output-for-stadtpuls-com-iot-platform/296777/4 "2022-02-11T22:31:43Z")

</div>

You unconditionally remove the [app\_id] field in the second mutate, so it will not exist when the event reaches the output section.

If you want to use the app\_id in the output section but do not want it sent to the output then use `[@metadata][app_id]`. Then you can test it in the conditional but it will not be sent on with the event.

I hope that helps. It is not entirely clear what you are asking.

---

<div class="post-metadata">

**Author:** ![CargoBikoMeter](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cargobikometer/32/101615_2.png) [@CargoBikoMeter](https://discuss.elastic.co/u/CargoBikoMeter)\
**Post date:** [February 12, 2022, 5:51pm UTC](https://discuss.elastic.co/t/http-output-for-stadtpuls-com-iot-platform/296777/5 "2022-02-12T17:51:37Z")

</div>

> [@Badger](#):
>
> @metadata

This was the right solution, thanks. Now my pipeline is working and sends only what I want.

---

<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:** [March 12, 2022, 5:51pm UTC](https://discuss.elastic.co/t/http-output-for-stadtpuls-com-iot-platform/296777/6 "2022-03-12T17:51:57Z")

</div>

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