RoadRunner server includes an embedded metrics server based on Prometheus.
To enable metrics add metrics
section to your configuration:
metrics:
address: localhost:2112
Once complete you can access Prometheus metrics using http://localhost:2112/metrics
url.
RoadRunner will expose default
http
andlimit
server metrics automatically.
You can also publish application-specific metrics using an RPC connection to the server. First, you have to register a metric in your configuration file:
metrics:
address: localhost:2112
collect:
app_metric_counter:
type: counter
help: "Application counter."
To send metric from the application:
$rpc = new Spiral\Goridge\RPC(new Spiral\Goridge\SocketRelay("127.0.0.1", 6001));
$metrics = new Spiral\RoadRunner\Metrics($rpc);
$metrics->add('app_metric_counter', 1);
Supported types: gauge, counter, summary, histogram.
You can use tagged (labels) metrics to group values:
metrics:
address: localhost:2112
collect:
app_type_duration:
type: histogram
help: "Application counter."
labels: ["type"]
You should specify values for your labels while pushing the metric:
$rpc = new Spiral\Goridge\RPC(new Spiral\Goridge\SocketRelay("127.0.0.1", 6001));
$metrics = new Spiral\RoadRunner\Metrics($rpc);
$metrics->add('app_type_duration', 0.5, ['some-type']);