插件本地插件稳定版

Prometheus reporting endpoint

local_prometheusJohn Maydew

  • Moodle 1.9–5.1
  • 更新 2023-11-28

Presents an HTTP endpoint that can be used to scrape metrics data for Prometheus or InfluxDB v2
Moodle Prometheus reporting endpoint
A local plugin that presents an endpoint for Prometheus metric gathering.
Can be used either in Prometheus or as an InfluxDB v2 scraper
Developing
Plugins can add their own metrics to the output by adding their own plugin_name_prometheus_get_metrics(int $window) function
to lib.php. This function must return either one or more local_prometheusmetric objects, or an empty array.
Plugins should give users the option to toggle metric gathering for that plugin on or off.
The $window parameter is a unix timestamp and is used for determining the cutoff for a ‘current’ value. For example to determine
the number of currently online users we can only look at the last access timestamp. In this case, $window would mean “treat users
active since this timestamp as currently online”.
Example implementation in lib.php:
/**
* Fetch metrics for the plugin
*
* @param int $window
* @return metric[]
*/
mod_example_prometheus_get_metrics(int $window): array {
$metric = new metric(

返回插件目录