fix #5997: metrics: influxdb: fall back to the ready endpoint in connection test
The connection test for InfluxDB over HTTP(S) queries the '/health' endpoint. The InfluxDB v2 listener of Telegraf only has it since version 1.36, older versions only provide '/api/v2/ready'. So adding such a listener as metric server fails with '404 Not Found', although writing metrics to it would work. If '/health' is not found, query '/api/v2/ready' instead. Other errors, like an invalid token, are still reported right away. Signed-off-by: Michal Fox <me@dualfroz.com>
This commit is contained in:
1 parent
6cb3347d96
commit
2564208ca8
1 file changed
+5
@@ -267,6 +267,11 @@ sub test_connection {
|
||||
}
|
||||
my $response = $ua->get($url);
|
||||
|
||||
# the InfluxDB v2 listener of Telegraf before 1.36 only has the ready endpoint
|
||||
if ($response->code == 404) {
|
||||
$response = $ua->get(_get_v2url($cfg, "ready"));
|
||||
}
|
||||
|
||||
if (!$response->is_success) {
|
||||
my $err = $response->status_line;
|
||||
die "$err\n";
|
||||
|
||||
Reference in new issue
Block a user