# Telegraf HTTP Output GZIP Encoding Not Working For Me

**URL:** <https://community.influxdata.com/t/telegraf-http-output-gzip-encoding-not-working-for-me/39915>\
**Category:** Telegraf\
**Tags:** telegraf\
**Created:** [December 21, 2024, 6:30pm UTC](https://community.influxdata.com/t/telegraf-http-output-gzip-encoding-not-working-for-me/39915 "2024-12-21T18:30:25Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![arnel\_lim](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/arnel_lim/32/15268_2.png) [@arnel\_lim](https://community.influxdata.com/u/arnel_lim)\
**Post date:** [December 21, 2024, 6:30pm UTC](https://community.influxdata.com/t/telegraf-http-output-gzip-encoding-not-working-for-me/39915/1 "2024-12-21T18:30:25Z")

</div>

I’m having trouble with the content\_encoding = “gzip” setting in the telegraf config. It does not appear to work for me. I’m seeing 0 bytes at the target http output webserver.

- Default encoding works. (uncompressed)
- GZIP encoding sent manually via curl command works as well. (see below)

I’m using same input for comprressed and decompressed cases from telegraf.

Is there anything I’m missing from my telegraf config file below? My sample python webserver use the following code to decompress and print the output.

```
            with gzip.GzipFile(fileobj=BytesIO(raw_data)) as gz:
                decompressed_data = gz.read().decode('utf-8')
            print("Decompressed Data:\n", decompressed_data)

```

**Debug Webserver Output - Uncompressed output works fine.**

(‘content\_length:\n’, 286)  
(‘content\_encoding:\n’, ‘’)  
(‘content\_location:\n’, ‘’)  
++++++ NOT COMPRESSED ----

(‘Received Data:\n’, u’{“metrics”:[{“fields”:{“@1\_portList\_tags”:“1:1”,“@2\_portList\_tags”:“1:7”,“@3\_portList\_tags”:“1:13”,“ipAddress”:“10.1.2.3”,“macAddr”:“00:73:04:05:06:07”,“vlanId\_key”:10},“name”:“TestStats”,“tags”:{“reporterSerialnum”:“\“XYZ-5678\””,“serialnum”:“\“ABCD-1234\””},“timestamp”:1734804378}]}\n’)  
127.0.0.1 - - [21/Dec/2024 18:06:18] “POST / HTTP/1.1” 200 -

**Debug Webserver Output - Telegref GZIP output does NOT work. I see content\_length of 0.**

(‘content\_length:\n’, 0)  
(‘content\_encoding:\n’, ‘gzip’)  
(‘content\_location:\n’, ‘’)  
---------- gzip ---------

(‘Decompressed Data:\n’, u’')

**Debug WebServer - Manually sending using curl WORKS with GZIP**

**echo “Hello, World!” | gzip | curl -X POST -H “Content-Encoding: gzip” --data-binary @- [http://localhost:8080](http://localhost:8080)**

Debug WebServer  
(‘content\_length:\n’, 34)  
(‘content\_encoding:\n’, ‘gzip’)  
(‘content\_location:\n’, ‘’)  
---------- gzip ---------

(‘Decompressed Data:\n’, u’Hello, World!\n’)  
127.0.0.1 - - [21/Dec/2024 18:14:51] “POST / HTTP/1.1” 200 -

alim@calabash devtest $ cat telegraf1.conf  
[global\_tags]

[agent]  
collection\_jitter = “0s”  
debug = false  
flush\_interval = “1s”  
flush\_jitter = “1s”  
hostname = “EXOS-5520”  
interval = “4s”  
logfile = “./telegraf.log”  
metric\_batch\_size = 1000  
metric\_buffer\_limit = 1000  
omit\_hostname = true  
precision = “”  
quiet = false  
round\_interval = true

[[inputs.file]]  
files = [“./inputs/input”]  
interval = “2s”  
data\_format = “influx”  
metric\_batch\_size = 50

[[outputs.http]]  
url = “[http://localhost:8080/](http://localhost:8080/)”  
method = “POST”  
tagexclude = [“path”]  
data\_format = “json”  
metric\_batch\_size = 5  
use\_batch\_format = true  
content\_encoding = “gzip”  
[outputs.http.headers]  
Content-Type = “application/json; charset=utf-8”

$ ./telegraf --version  
Telegraf 1.33.0 (git: HEAD@67902005)

---

<div class="post-metadata">

**Author:** ![arnel\_lim](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/arnel_lim/32/15268_2.png) [@arnel\_lim](https://community.influxdata.com/u/arnel_lim)\
**Post date:** [February 2, 2025, 2:30am UTC](https://community.influxdata.com/t/telegraf-http-output-gzip-encoding-not-working-for-me/39915/3 "2025-02-02T02:30:03Z")

</div>

**Disregard this issue.**

This was a problem with my test webserver which was looking at content-length. Telegraf will send GZIP’d data as chunked, so content-length will always be 0. If content-length is 0, I needed to check if payload data is chunked and read payload accordingly. In any case, this is not a telegraf issue.

---

<div class="post-metadata">

**Author:** ![Anaisdg](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/anaisdg/32/6401_2.png) [@Anaisdg](https://community.influxdata.com/u/Anaisdg)\
**Post date:** [February 3, 2025, 11:10pm UTC](https://community.influxdata.com/t/telegraf-http-output-gzip-encoding-not-working-for-me/39915/4 "2025-02-03T23:10:43Z")

</div>

@arnel_lim  
thanks for sharing your question and solution! Im glad you figured it out
