The influx http client (v2) that telegraf uses does not uses the defined http_proxy, https_proxy, no_proxy environment variables and always tries to connect directly to the endpoint configured in telegraf.conf
None
Telegraf - Version 0.10.4.1
Linux valar0003 3.16.0-4-amd64 #1 SMP Debian 3.16.7-ckt20-1+deb8u4 (2016-02-29) x86_64 GNU/Linux
Debian 8.3
Connections to influxdb are proxyed
Connections are either refused or blocked pending on your firewall configuration and the following is logged:
016/08/05 14:55:54 Database creation failed: Get http://influxdb.****/query?db=&q=CREATE+DATABASE+IF+NOT+EXISTS+%22***%22: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)
2016/08/05 14:55:54 Starting Telegraf (version 1.0.0-beta1)
can you provide a link to documentation of the environment variable? is it an issue that should be opened on the influxdb repo?
The golang http itself provides some helper functions to use those variables: https://golang.org/pkg/net/http/#ProxyFromEnvironment
And I open this in the influxdb if it makes more sense
Thanks
I have created a related issue on the influx repo.
Closing this one. Thanks.
Reopening as the comment on https://github.com/influxdata/influxdb/issues/7157 says:
"Telegraf issues should be created in influxdata/telegraf rather than here."
i need this to! is there a workaround?
Any update/workaround on this?
Anywork around for this ? I am stuck here too
I am facing the same issue. Most corporate environments do not allow unfettered access to the internet from any server. They are tightly controlled so egress out is through a single source i.e. a web proxy. From the doc's
DefaultTransport is the default implementation of Transport and is used by DefaultClient. It establishes network connections as needed and caches them for reuse by subsequent calls. It uses HTTP proxies as directed by the $HTTP_PROXY and $NO_PROXY (or $http_proxy and $no_proxy) environment variables.
https://golang.org/pkg/net/http/#ProxyFromEnvironment
The datadog output uses the following from your code
func (d *Datadog) Connect() error {
if d.Apikey == "" {
return fmt.Errorf("apikey is a required field for datadog output")
}
d.client = &http.Client{
Timeout: d.Timeout.Duration,
}
return nil
}
I think should be something similar to the below.
func (d *Datadog) Connect() error {
if d.Apikey == "" {
return fmt.Errorf("apikey is a required field for datadog output")
}
if *proxy != "" {
proxyURL, err := url.Parse(*proxy)
if err != nil {
panic("Error parsing proxy URL")
}
transport := http.Transport{
Proxy: http.ProxyURL(proxyURL)
}
client = http.Client{
Transport: &transport,
Timeout: d.Timeout.Duration ,
}
} else {
client = http.Client{
Timeout: d.Timeout.Duration,
}
}
return nil
}
I think at this point as you overide the default client you need to set the transport to be proxy and provide the proxy url which should be picked up from the environment variables one of HTTP_PROXY, HTTPS_PROXY,http_proxy or https_proxy.
Does this make sense ? I am not a coder so I suggest somone look over what I am saying
Doesn't work for me, InfluxDB output does not respect environment proxy settings.
declare -x http_proxy="http://172.21.8.35:3128"
declare -x https_proxy="http://172.21.8.35:3128"
telegraf /etc/telegraf/telegraf.conf --debug
Post http://xxx:8086/query?db=&q=CREATE+DATABASE+%22cem%22: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)
(version 1.2.1)
I have tried with both the http_proxy and https_proxy as mentioned by @Integrative . But it does not work.
Any update/workaround on this?
Any chance this gets into a 1.4.x release? This bug/missing feature renders the http_response input pretty useless for anything but intranet resources.
@jcmcken The fix for this issue only added support to the InfluxDB and other output plugins, I opened a new issue for http_response: https://github.com/influxdata/telegraf/issues/3297
Most helpful comment
Any update/workaround on this?