job: create a prometheus endpoint
[?]
Dec 28, 2019, 9:39 PM
NQJFHYBIP2D34U642PZI77QKMZYQIO5QAC5YOXXQZXNPBLP7OEWQCDependencies
- [2]
ODNCGFQ5* Improved the navigation bar: don't include all projects (since that - [3]
V7UDCU3WFix a couple of encoding issues - [4]
DEMSSSB2* Controller for jobs which inherits all actions in ListBuilds. So - [5]
GNIEG2GC* Disambiguate jobs by jobset name. I.e. jobs with the same name in
Change contents
- replacement in src/lib/Hydra/Controller/Job.pm at line 9
use Net::Prometheus; - edit in src/lib/Hydra/Controller/Job.pm at line 32
sub prometheus : Chained('job') PathPart('prometheus') Args(0) {my ($self, $c) = @_;my $job = $c->stash->{job};my $prometheus = Net::Prometheus->new; - edit in src/lib/Hydra/Controller/Job.pm at line 37
my $lastBuild = $job->builds->find({ finished => 1 },{ order_by => 'id DESC', rows => 1, columns => [@buildListColumns] });$prometheus->new_counter(name => "hydra_job_completion_time",help => "The most recent job's completion time",labels => [ "project", "jobset", "job", "nixname" ])->labels($c->stash->{project}->name,$c->stash->{jobset}->name,$c->stash->{job}->name,$lastBuild->nixname,)->inc($lastBuild->stoptime);$prometheus->new_gauge(name => "hydra_job_failed",help => "Record if the most recent version of this job failed (1 means failed)",labels => [ "project", "jobset", "job", "nixname" ])->labels($c->stash->{project}->name,$c->stash->{jobset}->name,$c->stash->{job}->name,$lastBuild->nixname,)->inc($lastBuild->stoptime >= 0);$c->stash->{'plain'} = { data => $prometheus->render };$c->forward('Hydra::View::Plain');}