hey,

Resurrecting old thread about native Prometheus metrics directly from Radiator. Did some digging in the source and "creative use of game mechanics" type of solution I came up with is following:

<ServerHTTP>
  PageNotFoundHook file:"stats.pl"
</ServerHTTP>

sub {
  my $uri = $_[0];

  if($uri !~ /^\/metrics$/) {
    return;
  }

  my $stats;
  foreach (sort keys %Radius::ServerConfig::statistic_names)
  {
    my $name = "radiator_$_";
    my $value = $main::config->{Statistics}{$_};
    my $help = $Radius::ServerConfig::statistic_names{$_};
    $stats .= sprintf "# HELP %s %s\n", $name, $help;
    $stats .= sprintf "%s %f\n", $name, $value;
  }

  return (200, $stats);
}

I'm not sure it's ment to be used this way but it works and is not horrible at all. I don't see any obvious drawbacks why it shouldn't be used, just have to check for any security implications of enabling ServerHTTP.

--
tarko
_______________________________________________
radiator mailing list
radiator@lists.open.com.au
https://lists.open.com.au/mailman/listinfo/radiator

Reply via email to