Skip to content

Commit

Permalink
Output openTSDB HTTPS with basic auth (#1913)
Browse files Browse the repository at this point in the history
  • Loading branch information
aarnaud authored and sparrc committed Dec 13, 2016
1 parent 9add7b9 commit a611489
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 3 additions & 1 deletion plugins/outputs/opentsdb/opentsdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
Expand All @@ -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,
}
Expand Down
5 changes: 4 additions & 1 deletion plugins/outputs/opentsdb/opentsdb_http.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ type HttpMetric struct {
type openTSDBHttp struct {
Host string
Port int
Scheme string
User *url.Userinfo
BatchSize int
Debug bool

Expand Down Expand Up @@ -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",
}
Expand Down

0 comments on commit a611489

Please sign in to comment.