mirror of
https://github.com/ClusterCockpit/cc-metric-collector.git
synced 2025-04-19 19:21:41 +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"`
|
Port string `json:"port,omitempty"`
|
||||||
Database string `json:"database,omitempty"`
|
Database string `json:"database,omitempty"`
|
||||||
JWT string `json:"jwt,omitempty"`
|
JWT string `json:"jwt,omitempty"`
|
||||||
|
SSL bool `json:"ssl,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type HttpSink struct {
|
type HttpSink struct {
|
||||||
@ -31,6 +32,7 @@ type HttpSink struct {
|
|||||||
|
|
||||||
func (s *HttpSink) Init(config json.RawMessage) error {
|
func (s *HttpSink) Init(config json.RawMessage) error {
|
||||||
s.name = "HttpSink"
|
s.name = "HttpSink"
|
||||||
|
s.config.SSL = false
|
||||||
if len(config) > 0 {
|
if len(config) > 0 {
|
||||||
err := json.Unmarshal(config, &s.config)
|
err := json.Unmarshal(config, &s.config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -42,7 +44,11 @@ func (s *HttpSink) Init(config json.RawMessage) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
s.client = &http.Client{}
|
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.jwt = s.config.JWT
|
||||||
s.buffer = &bytes.Buffer{}
|
s.buffer = &bytes.Buffer{}
|
||||||
s.encoder = influx.NewEncoder(s.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",
|
"host": "dbhost.example.com",
|
||||||
"port": "4222",
|
"port": "4222",
|
||||||
"jwt" : "0x0000q231",
|
"jwt" : "0x0000q231",
|
||||||
|
"ssl" : false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
@ -23,3 +24,4 @@ The `http` sink uses POST requests to a HTTP server to submit the metrics in the
|
|||||||
- `host`: Hostname of the InfluxDB database server
|
- `host`: Hostname of the InfluxDB database server
|
||||||
- `port`: Portnumber (as string) 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