-
Notifications
You must be signed in to change notification settings - Fork 5.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add influxdb gzip support #2978
Add influxdb gzip support #2978
Conversation
aa4cc13
to
905b4fa
Compare
7309ac5
to
599aa5d
Compare
669ad0b
to
8abde2a
Compare
I think it should be possible to do this without buffering the entire request body again, similar to this gist https://gist.github.com/schmichael/7379338#file-gistfile1-go-L41. Is this something you are interested in looking into? |
@danielnelson Yes, definitely. Thanks for the example. Let me see what I can do to make this more efficient. |
576d96e
to
9e62fc3
Compare
Fix lint Mop
plugins/outputs/influxdb/README.md
Outdated
@@ -43,6 +43,9 @@ This plugin writes to [InfluxDB](https://www.influxdb.com) via HTTP or UDP. | |||
|
|||
## HTTP Proxy Config | |||
# http_proxy = "http://corporate.proxy:3128" | |||
|
|||
## Compress each HTTP request payload using GZIP, defaults to false. | |||
# gzip = false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's change the option to be content_encoding = "gzip"
supporting only gzip
, this will allow us to potentially add more encodings later and IMO reads better.
// } | ||
if c.config.Gzip { | ||
req.Header.Set("Content-Encoding", "gzip") | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you move all the Header code into makeRequest, I'm not sure why they should be separate.
@@ -233,15 +233,24 @@ func (c *httpClient) makeWriteRequest( | |||
return nil, err | |||
} | |||
req.Header.Set("Content-Length", fmt.Sprint(contentLength)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is going to complicate things... if we are using gzip we need to report the length of the body here after compression, but since we are now streaming the data it is trickier. I think we need to use Transfer-Encoding: chunked
and this header is unset for gzip.
I haven't ever done this with go, maybe we can use https://golang.org/pkg/net/http/httputil/#NewChunkedWriter? Or maybe it will be automatically handled if we don't set this header?
fae10de
to
37a9468
Compare
@danielnelson I ran through some testing and I think that the HTTP client handles streaming automatically if the content length header is unset. Basic smoke testA sample telegraf.conf was generated as per the docs (
|
37a9468
to
c8e0b4e
Compare
An approach for fixing #2802. Adds an optional parameter
gzip
(default:false
), which if enabled, will compress the payload of each HTTP request sent to InfluxDB using GZIP.While testing I was able to get on average 67% space savings when comparing the content length of the compressed vs. uncompressed payloads using the default sample
telegraf.conf
with no input filters.Required for all PRs: