Prometheus reporting endpoint

Local plugins ::: local_prometheus
Maintained by John Maydew
Presents an HTTP endpoint that can be used to scrape metrics data for Prometheus or InfluxDB v2

Prometheus reporting endpoint v1.1.0

Moodle 3.9, 3.10, 3.11, 4.0, 4.1, 4.2
Released: lundi 22 mai 2023, 23:13

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_prometheus\metric 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( 'moodle_mod_example_foo', metric::TYPE_GAUGE, 'optional HELP text, can be omitted' ); $metric->add_value(new metric_value( [ 'label' => 'foo' ], 12 )); return [ $metric ]; }

Installation

The plugin requires Moodle 3.9 or later, and PHP 7.4 or later. You will also need some way of gathering, storing, and using the metrics that the plugin generates.

There's no special installation steps or instructions, just install it as you would any other plugin

Install from Moodle.org

  • Download .zip file from https://moodle.org/plugins/local_prometheus
  • Navigate to /moodle/root/local
  • Extract the .zip to the current directory
  • Go to your Moodle admin control panel, or php /moodle/root/admin/cli/upgrade.php

Install from git

Install from .zip

  • Download .zip file from GitHub
  • Navigate to /moodle/root/local/prometheus
  • Extract the .zip to the current directory
  • Rename the moodle-local_prometheus-master directory to prometheus
  • Go to your Moodle admin control panel, or php /moodle/root/admin/cli/upgrade.php

Version information

Version build number
2023052200
Version release name
v1.1.0
Maturity
Version stable
MD5 Sum
212285aee27b091f45b172181a35b394
Supported software
Moodle 3.9, Moodle 3.10, Moodle 3.11, Moodle 4.0, Moodle 4.1, Moodle 4.2

Version control information

Version control system (VCS)
GIT
VCS repository URL
VCS branch
master
VCS tag
v1.1.0

Default installation instructions for plugins of the type Local plugins

  1. Make sure you have all the required versions.
  2. Download and unpack the module.
  3. Place the folder in the "local" subdirectory.
  4. Visit http://yoursite.com/admin to finish the installation.