diff --git a/sinks/httpSink.go b/sinks/httpSink.go index a21f8f2..3080faa 100644 --- a/sinks/httpSink.go +++ b/sinks/httpSink.go @@ -18,6 +18,7 @@ type HttpSinkConfig struct { Port string `json:"port,omitempty"` Database string `json:"database,omitempty"` JWT string `json:"jwt,omitempty"` + SSL bool `json:"ssl,omitempty"` } type HttpSink struct { @@ -31,6 +32,7 @@ type HttpSink struct { func (s *HttpSink) Init(config json.RawMessage) error { s.name = "HttpSink" + s.config.SSL = false if len(config) > 0 { err := json.Unmarshal(config, &s.config) if err != nil { @@ -42,7 +44,11 @@ func (s *HttpSink) Init(config json.RawMessage) error { } s.client = &http.Client{} - s.url = fmt.Sprintf("http://%s:%s/%s", s.config.Host, s.config.Port, s.config.Database) + proto := "http" + if s.config.SSL { + proto = "https" + } + s.url = fmt.Sprintf("%s://%s:%s/%s", proto, s.config.Host, s.config.Port, s.config.Database) s.jwt = s.config.JWT s.buffer = &bytes.Buffer{} s.encoder = influx.NewEncoder(s.buffer) diff --git a/sinks/httpSink.md b/sinks/httpSink.md index 3c9dfd9..5440a82 100644 --- a/sinks/httpSink.md +++ b/sinks/httpSink.md @@ -13,6 +13,7 @@ The `http` sink uses POST requests to a HTTP server to submit the metrics in the "host": "dbhost.example.com", "port": "4222", "jwt" : "0x0000q231", + "ssl" : false } } ``` @@ -22,4 +23,5 @@ The `http` sink uses POST requests to a HTTP server to submit the metrics in the - `database`: All metrics are written to this bucket - `host`: Hostname of the InfluxDB database server - `port`: Portnumber (as string) of the InfluxDB database server -- `jwt`: JSON web tokens for authentification \ No newline at end of file +- `jwt`: JSON web tokens for authentification +- `ssl`: Activate SSL encryption \ No newline at end of file