fix panic if sink type does not exist

This commit is contained in:
Lou Knauer 2022-02-10 10:01:30 +01:00
parent 39bfeab283
commit 67f0c5b190
2 changed files with 9 additions and 13 deletions

View File

@ -9,25 +9,21 @@ The `http` sink uses POST requests to a HTTP server to submit the metrics in the
"<name>": { "<name>": {
"type": "http", "type": "http",
"meta_as_tags" : true, "meta_as_tags" : true,
"database" : "mymetrics", "url" : "https://my-monitoring.example.com:1234/api/write",
"host": "dbhost.example.com", "jwt" : "blabla.blabla.blabla",
"port": "4222",
"jwt" : "0x0000q231",
"ssl" : false,
"timeout": "5s", "timeout": "5s",
"max_idle_connections" : 10, "max_idle_connections" : 10,
"idle_connection_timeout" : "5s" "idle_connection_timeout" : "5s",
"flush_delay": "2s",
} }
} }
``` ```
- `type`: makes the sink an `http` sink - `type`: makes the sink an `http` sink
- `meta_as_tags`: print all meta information as tags in the output (optional) - `meta_as_tags`: print all meta information as tags in the output (optional)
- `database`: All metrics are written to this bucket - `url`: The full URL of the endpoint
- `host`: Hostname of the InfluxDB database server - `jwt`: JSON web tokens for authentification (Using the *Bearer* scheme)
- `port`: Portnumber (as string) of the InfluxDB database server
- `jwt`: JSON web tokens for authentification
- `ssl`: Activate SSL encryption
- `timeout`: General timeout for the HTTP client (default '5s') - `timeout`: General timeout for the HTTP client (default '5s')
- `max_idle_connections`: Maximally idle connections (default 10) - `max_idle_connections`: Maximally idle connections (default 10)
- `idle_connection_timeout`: Timeout for idle connections (default '5s') - `idle_connection_timeout`: Timeout for idle connections (default '5s')
- `flush_delay`: Batch all writes arriving in during this duration (default '1s', batching can be disabled by setting it to 0)

View File

@ -133,7 +133,7 @@ func (sm *sinkManager) AddOutput(name string, rawConfig json.RawMessage) error {
} }
} }
if _, found := AvailableSinks[sinkConfig.Type]; !found { if _, found := AvailableSinks[sinkConfig.Type]; !found {
cclog.ComponentError("SinkManager", "SKIP", name, "unknown sink:", err.Error()) cclog.ComponentError("SinkManager", "SKIP", name, "unknown sink:", sinkConfig.Type)
return err return err
} }
s := AvailableSinks[sinkConfig.Type] s := AvailableSinks[sinkConfig.Type]