export a /prometheus endpoint

[?]
Sep 24, 2019, 8:34 PM
TF5HAPRDV6USGRKEEDIV263YZRUWGC4SKP3RXCBBVT7FEBGT5XFQC

Dependencies

  • [2] JLQN6QYH Revert "Remove the global channel"
  • [3] ICYJNJWH Revert "Move build logic for the core hydra package into its own default.nix."
  • [4] HPGWVEFK Add 'readonly_ips' option, to allow readonly access for certain IPs when 'private' option is enabled.
  • [*] T4LLYESZ * Nix expression for building Hydra.
  • [*] J5UVLXOK * Start of a basic Catalyst web interface.
  • [*] LBNVQXUB * Build the /build stuff in a separate controller.
  • [*] SZYDW2DG hydra: added some user admin
  • [*] SMM4HQTP * Put actions related to builds under /build (e.g. /log/<buildid>

Change contents

  • edit in release.nix at line 102
    [3.1793]
    [3.1793]
    NetPrometheus
  • edit in src/lib/Hydra/Controller/Root.pm at line 9
    [8.3368]
    [9.3010]
    use Hydra::View::TT;
  • edit in src/lib/Hydra/Controller/Root.pm at line 17
    [4.29]
    [10.0]
    use Net::Prometheus;
  • edit in src/lib/Hydra/Controller/Root.pm at line 205
    [2.52]
    [2.52]
    sub prometheus :Local Args(0) {
    my ($self, $c) = @_;
    my $machines = getMachines;
  • edit in src/lib/Hydra/Controller/Root.pm at line 209
    [2.53]
    [2.53]
    my $client = Net::Prometheus->new;
    my $duration = $client->new_histogram(
    name => "hydra_machine_build_duration",
    help => "How long builds are taking per server. Note: counts are gauges, NOT counters.",
    labels => [ "machine" ],
    buckets => [
    60,
    600,
    1800,
    3600,
    7200,
    21600,
    43200,
    86400,
    172800,
    259200,
    345600,
    518400,
    604800,
    691200
    ]
    );
    my $steps = dbh($c)->selectall_arrayref(
    "select machine, s.starttime as starttime " .
    "from BuildSteps s join Builds b on s.build = b.id " .
    "where busy != 0 order by machine, stepnr",
    { Slice => {} });
    foreach my $step (@$steps) {
    my $name = $step->{machine} ? Hydra::View::TT->stripSSHUser(undef, $step->{machine}) : "";
    $name = "localhost" unless $name;
    $duration->labels($name)->observe(time - $step->{starttime});
    }
    $c->stash->{'plain'} = { data => $client->render };
    $c->forward('Hydra::View::Plain');
    }