<div dir="ltr">Resurrecting an old thread about native Prometheus metrics directly from Radiator. I noticed the old community solution by Tarko Tikan is not working as expected with current Radiator versions. Here's an updated version of the <font face="monospace">PageNotFoundHook</font> script:<div><br></div><div><font face="monospace"># Prometheus metrics from Radiator, updated<br>#<br># Usage:<br>#<br># Add PageNotFoundHook to Radiator config and save this script<br># as /etc/radiator/<a href="http://metrics.pl">metrics.pl</a><br>#<br># To access metrics without login, disable authentication in<br># ServerHTTP and add DefaultPrivilegeLevel 1 (for https enable<br># TLS in ServerHTTP):<br>#<br># curl <a href="http://127.0.0.1:9048/metrics">http://127.0.0.1:9048/metrics</a><br>#<br># If web authentication is enabled, first call login url to<br># fetch a session key cookie:<br>#<br># curl -c /tmp/cookies -d "username=mikem&password=fred" <a href="http://127.0.0.1:9048/login">http://127.0.0.1:9048/login</a><br># curl -b /tmp/cookies <a href="http://127.0.0.1:9048/metrics">http://127.0.0.1:9048/metrics</a><br>#<br># Example snippet for /etc/radiator/radiator.conf:<br>#<br># <ServerHTTP><br>#   DefaultPrivilegeLevel 1<br>#   PageNotFoundHook file:"%D/<a href="http://metrics.pl">metrics.pl</a>"<br># </ServerHTTP><br>#<br># Notes:<br># Radiator 4.21 internal change: ServerConfig => StatslogGeneric<br><br>use strict;<br>use warnings;<br><br>sub {<br>  my $uri = $_[0];<br><br>  if ($uri !~ m%^/metrics/?$%) {<br>    return;<br>  }<br><br>  my %headers = ( "Content-Type"=>"text/plain; version=0.0.4" );<br>  my $stats;<br>  foreach (sort keys %Radius::StatsLogGeneric::statistic_names) {<br>    my $name = "radiator_$_";<br>    my $value = $main::config->{Statistics}{$_};<br>    my $help = $Radius::StatsLogGeneric::statistic_names{$_};<br>    $stats .= sprintf "# HELP %s %s\n", $name, $help;<br>    $stats .= sprintf "%s %f\n", $name, $value;<br>  }<br>  return (200, $stats, %headers);<br>}</font></div><div><br></div><div>The output of the script is not utilising the full power of OpenMetrics 1.0.0 spec, so <font face="monospace">Content-Type</font> is set accordingly. It should be easy to update output to <font face="monospace">application/openmetrics-text</font>, though. This script can also be used as a starting point for exporting Radiator statistics data to other systems.</div><div><br></div><div>You should check the documentation for full configuration of <font face="monospace">ServerHTTP</font> block and for any security implications of enabling <font face="monospace">ServerHTTP</font>.</div><div><br></div><div>//jani</div><div><br></div></div>