Skip to content

feat(PHP): add aurweb Prometheus metrics

Kevin Morris requested to merge kevr/aurweb:request_metrics into master

feat(PHP): add aurweb Prometheus metrics

Along with this initial requests metric implementation, we also now serve the /metrics route, which grabs request metrics out of cache and renders them properly for Prometheus.

NOTE Metrics are only enabled when the aurweb system admin has enabled caching by configuring options.cache correctly in $AUR_CONFIG. Otherwise, an error is logged about no cache being configured.

New dependencies have been added which require the use of composer. See INSTALL for the dependency section in regards to composer dependencies and how to install them properly for aurweb.

Metrics are in the following forms:

aurweb_http_requests_count(method="GET",route="/some_route")
aurweb_api_requests_count(method="GET",route="/rpc",type="search")

This should allow us to search through the requests for specific routes and queries.

Signed-off-by: Kevin Morris kevr@0cost.org

Example output:

# HELP aurweb_api_requests_count A metric count for the aurweb platform.
# TYPE aurweb_api_requests_count gauge
aurweb_api_requests_count{method="GET",route="/rpc",type="info"} 2
aurweb_api_requests_count{method="GET",route="/rpc",type="search"} 6
# HELP aurweb_http_requests_count A metric count for the aurweb platform.
# TYPE aurweb_http_requests_count gauge
aurweb_http_requests_count{method="GET",route="/"} 3
aurweb_http_requests_count{method="GET",route="/rpc"} 8
# HELP php_info Information about the PHP environment.
# TYPE php_info gauge
php_info{version="8.0.11"} 1
Edited by Kevin Morris

Merge request reports