mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
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>
86 lines
1.8 KiB
PHP
86 lines
1.8 KiB
PHP
<?php
|
|
|
|
include_once("confparser.inc.php");
|
|
|
|
$ROUTES = array(
|
|
'' => 'home.php',
|
|
'/index.php' => 'home.php',
|
|
'/packages' => 'packages.php',
|
|
'/pkgbase' => 'pkgbase.php',
|
|
'/requests' => 'pkgreq.php',
|
|
'/register' => 'register.php',
|
|
'/account' => 'account.php',
|
|
'/accounts' => 'account.php',
|
|
'/login' => 'login.php',
|
|
'/logout' => 'logout.php',
|
|
'/passreset' => 'passreset.php',
|
|
'/rpc' => 'rpc.php',
|
|
'/rss/modified' => 'modified-rss.php',
|
|
'/rss' => 'rss.php',
|
|
'/tos' => 'tos.php',
|
|
'/tu' => 'tu.php',
|
|
'/addvote' => 'addvote.php',
|
|
'/metrics' => 'metrics.php' // Prometheus Metrics
|
|
);
|
|
|
|
$PKG_PATH = '/packages';
|
|
$PKGBASE_PATH = '/pkgbase';
|
|
$PKGREQ_PATH = '/requests';
|
|
$USER_PATH = '/account';
|
|
|
|
function get_route($path) {
|
|
global $ROUTES;
|
|
|
|
$path = rtrim($path, '/');
|
|
if (isset($ROUTES[$path])) {
|
|
return $ROUTES[$path];
|
|
} else {
|
|
return NULL;
|
|
}
|
|
}
|
|
|
|
function get_uri($path, $absolute=false) {
|
|
if ($absolute) {
|
|
return rtrim(aur_location(), '/') . $path;
|
|
} else {
|
|
return $path;
|
|
}
|
|
}
|
|
|
|
function get_pkg_route() {
|
|
global $PKG_PATH;
|
|
return $PKG_PATH;
|
|
}
|
|
|
|
function get_pkgbase_route() {
|
|
global $PKGBASE_PATH;
|
|
return $PKGBASE_PATH;
|
|
}
|
|
|
|
function get_pkgreq_route() {
|
|
global $PKGREQ_PATH;
|
|
return $PKGREQ_PATH;
|
|
}
|
|
|
|
function get_pkg_uri($pkgname, $absolute=false) {
|
|
global $PKG_PATH;
|
|
$path = $PKG_PATH . '/' . urlencode($pkgname) . '/';
|
|
return get_uri($path, $absolute);
|
|
}
|
|
|
|
function get_pkgbase_uri($pkgbase_name, $absolute=false) {
|
|
global $PKGBASE_PATH;
|
|
$path = $PKGBASE_PATH . '/' . urlencode($pkgbase_name) . '/';
|
|
return get_uri($path, $absolute);
|
|
}
|
|
|
|
function get_user_route() {
|
|
global $USER_PATH;
|
|
return $USER_PATH;
|
|
}
|
|
|
|
function get_user_uri($username, $absolute=false) {
|
|
global $USER_PATH;
|
|
$path = $USER_PATH . '/' . urlencode($username) . '/';
|
|
return get_uri($path, $absolute);
|
|
}
|