forked from lix-project/hydra
Merge pull request #692 from knl/emit-hostname-with-influxdb-metrics
Add host tag to InfluxDB metrics
This commit is contained in:
commit
1831866a52
|
@ -3,9 +3,8 @@ package Hydra::Plugin::InfluxDBNotification;
|
||||||
use strict;
|
use strict;
|
||||||
use parent 'Hydra::Plugin';
|
use parent 'Hydra::Plugin';
|
||||||
use HTTP::Request;
|
use HTTP::Request;
|
||||||
# use JSON;
|
|
||||||
use LWP::UserAgent;
|
use LWP::UserAgent;
|
||||||
# use Hydra::Helper::CatalystUtils;
|
use Sys::Hostname::Long;
|
||||||
|
|
||||||
sub isEnabled {
|
sub isEnabled {
|
||||||
my ($self) = @_;
|
my ($self) = @_;
|
||||||
|
@ -67,6 +66,11 @@ sub toBuildStatusClass {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Get the hostname. If we can't, we swallow the exception from hostname.
|
||||||
|
my $hostname = eval {
|
||||||
|
hostname_long;
|
||||||
|
};
|
||||||
|
|
||||||
# Syntax
|
# Syntax
|
||||||
# build_status,job=my-job status=failed,result=dependency-failed duration=123i
|
# build_status,job=my-job status=failed,result=dependency-failed duration=123i
|
||||||
# | -------------------- -------------- |
|
# | -------------------- -------------- |
|
||||||
|
@ -81,6 +85,8 @@ sub createLine {
|
||||||
foreach my $tag (sort keys %$tagSet) {
|
foreach my $tag (sort keys %$tagSet) {
|
||||||
push @tags, "$tag=$tagSet->{$tag}";
|
push @tags, "$tag=$tagSet->{$tag}";
|
||||||
}
|
}
|
||||||
|
# we add host tag to all outputs
|
||||||
|
push @tags, "host=$hostname" if defined $hostname;
|
||||||
my @fields = ();
|
my @fields = ();
|
||||||
foreach my $field (sort keys %$fieldSet) {
|
foreach my $field (sort keys %$fieldSet) {
|
||||||
push @fields, "$field=$fieldSet->{$field}";
|
push @fields, "$field=$fieldSet->{$field}";
|
||||||
|
|
Loading…
Reference in a new issue