From a61148904ded8ce580462593941c2da7ea6a909a Mon Sep 17 00:00:00 2001 From: Anthony Arnaud Date: Tue, 13 Dec 2016 09:15:51 -0500 Subject: [PATCH] Output openTSDB HTTPS with basic auth (#1913) --- plugins/outputs/opentsdb/opentsdb.go | 4 +++- plugins/outputs/opentsdb/opentsdb_http.go | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/plugins/outputs/opentsdb/opentsdb.go b/plugins/outputs/opentsdb/opentsdb.go index 232edc0b79463..ce797e10f2e5d 100644 --- a/plugins/outputs/opentsdb/opentsdb.go +++ b/plugins/outputs/opentsdb/opentsdb.go @@ -90,7 +90,7 @@ func (o *OpenTSDB) Write(metrics []telegraf.Metric) error { if u.Scheme == "" || u.Scheme == "tcp" { return o.WriteTelnet(metrics, u) - } else if u.Scheme == "http" { + } else if u.Scheme == "http" || u.Scheme == "https" { return o.WriteHttp(metrics, u) } else { return fmt.Errorf("Unknown scheme in host parameter.") @@ -101,6 +101,8 @@ func (o *OpenTSDB) WriteHttp(metrics []telegraf.Metric, u *url.URL) error { http := openTSDBHttp{ Host: u.Host, Port: o.Port, + Scheme: u.Scheme, + User: u.User, BatchSize: o.HttpBatchSize, Debug: o.Debug, } diff --git a/plugins/outputs/opentsdb/opentsdb_http.go b/plugins/outputs/opentsdb/opentsdb_http.go index e0a7a66ef2c09..912ca670a3111 100644 --- a/plugins/outputs/opentsdb/opentsdb_http.go +++ b/plugins/outputs/opentsdb/opentsdb_http.go @@ -23,6 +23,8 @@ type HttpMetric struct { type openTSDBHttp struct { Host string Port int + Scheme string + User *url.Userinfo BatchSize int Debug bool @@ -118,7 +120,8 @@ func (o *openTSDBHttp) flush() error { o.body.close() u := url.URL{ - Scheme: "http", + Scheme: o.Scheme, + User: o.User, Host: fmt.Sprintf("%s:%d", o.Host, o.Port), Path: "/api/put", }