Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Output openTSDB HTTPS with basic auth (#1913)
Browse files Browse the repository at this point in the history
aarnaud authored and sparrc committed Dec 13, 2016
1 parent 9add7b9 commit a611489
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
@@ -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,
}
5 changes: 4 additions & 1 deletion plugins/outputs/opentsdb/opentsdb_http.go
Original file line number Diff line number Diff line change
@@ -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",
}

0 comments on commit a611489

Please sign in to comment.