Output openTSDB HTTPS with basic auth (#1913)
This commit is contained in:
parent
6e241611be
commit
7558081873
|
@ -90,7 +90,7 @@ func (o *OpenTSDB) Write(metrics []telegraf.Metric) error {
|
||||||
|
|
||||||
if u.Scheme == "" || u.Scheme == "tcp" {
|
if u.Scheme == "" || u.Scheme == "tcp" {
|
||||||
return o.WriteTelnet(metrics, u)
|
return o.WriteTelnet(metrics, u)
|
||||||
} else if u.Scheme == "http" {
|
} else if u.Scheme == "http" || u.Scheme == "https" {
|
||||||
return o.WriteHttp(metrics, u)
|
return o.WriteHttp(metrics, u)
|
||||||
} else {
|
} else {
|
||||||
return fmt.Errorf("Unknown scheme in host parameter.")
|
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{
|
http := openTSDBHttp{
|
||||||
Host: u.Host,
|
Host: u.Host,
|
||||||
Port: o.Port,
|
Port: o.Port,
|
||||||
|
Scheme: u.Scheme,
|
||||||
|
User: u.User,
|
||||||
BatchSize: o.HttpBatchSize,
|
BatchSize: o.HttpBatchSize,
|
||||||
Debug: o.Debug,
|
Debug: o.Debug,
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,8 @@ type HttpMetric struct {
|
||||||
type openTSDBHttp struct {
|
type openTSDBHttp struct {
|
||||||
Host string
|
Host string
|
||||||
Port int
|
Port int
|
||||||
|
Scheme string
|
||||||
|
User *url.Userinfo
|
||||||
BatchSize int
|
BatchSize int
|
||||||
Debug bool
|
Debug bool
|
||||||
|
|
||||||
|
@ -118,7 +120,8 @@ func (o *openTSDBHttp) flush() error {
|
||||||
o.body.close()
|
o.body.close()
|
||||||
|
|
||||||
u := url.URL{
|
u := url.URL{
|
||||||
Scheme: "http",
|
Scheme: o.Scheme,
|
||||||
|
User: o.User,
|
||||||
Host: fmt.Sprintf("%s:%d", o.Host, o.Port),
|
Host: fmt.Sprintf("%s:%d", o.Host, o.Port),
|
||||||
Path: "/api/put",
|
Path: "/api/put",
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue