Export the most recent stop time and exit status in a prometheus-friendly format.
NQJFHYBIP2D34U642PZI77QKMZYQIO5QAC5YOXXQZXNPBLP7OEWQC
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');
}