mirror of
https://github.com/ClusterCockpit/cc-metric-collector.git
synced 2025-04-17 02:15:55 +02:00
HTTPS for HttpSink
This commit is contained in:
parent
7b38321b52
commit
d24b8c198b
@ -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)
|
||||
|
@ -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
|
||||
- `jwt`: JSON web tokens for authentification
|
||||
- `ssl`: Activate SSL encryption
|
Loading…
x
Reference in New Issue
Block a user