metrics: influx: send along auth token on connection test too

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Thomas Lamprecht 2021-03-15 09:14:54 +01:00 committed by Dominik Csapak
parent 9f8d8f2b05
commit bb35a833d1

View File

@ -207,6 +207,11 @@ sub test_connection {
my $url = "${proto}://${host}:${port}/health";
my $ua = LWP::UserAgent->new();
$ua->timeout($cfg->{timeout} // 1);
# in the initial add connection test, the token may still be in $cfg
my $token = $cfg->{token} // get_credentials($id);
if (defined($token)) {
$ua->default_header("Authorization" => "Token $token");
}
my $response = $ua->get($url);
if (!$response->is_success) {