MyBB Community Forums

Full Version: Prometheus Exporter
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi all,

I've recently been working on a simple plugin for MyBB to export statistics data to the Prometheus monitoring and time series database system. Prometheus is a tool that's becoming quite popular for monitoring all sorts of systems, including web servers. It can also be tied in to other tools such as Grafana to help visualise and monitor statistics.

I've now got to a point where I thought it would be worthwhile to get some feedback on what kind of stats might be useful to expose and any other feedback people might have. This plugin is aimed at people running their own servers (VPS or dedicated) rather than shared hosts really, as you need to have Prometheus running for it to be of any use.

This plugin requires PHP 7.1 or newer.

The plugin is available at GitHub: https://github.com/euantorano/mybb-prometheus

Configuring the plugin

Before using this plugin you need to configure your web server to set a couple of environment variables:
  • PROMETHEUS_USER: The username used to access Prometheus metrics. Defaults to prometheus
  • PROMETHEUS_PASSWORD: The password used to access Prometheus metrics.

These two configuration settings must match in both the MyBB web server configuration.

Configuring Prometheus

You must configure Prometheus to add a new scrape config. Below is an example scrape configuration to scrape metrics:
scrape_configs:
  - job_name: 'mybb'
    metrics_path: '/misc.php'
    scrape_interval: '5s'
    basic_auth:
      username: 'prometheus'
      password: 'change_me-123'
    params:
      action: ['prometheus_metrics']
    static_configs:
      - targets:
        - 'mybb.dev'


Obviously, you should change the target to your actual IP address/hostname and the username and password to those set as per the above section Configuring the plugin.

Supported metrics

This plugin currently reports the following set of metrics:
  • Number of users awaiting activation
  • Number of messages waiting in the mail queue
  • Maximum number of concurrent online users
  • Number of unread reports
  • Total number of reports
  • MyBB version code number
  • Number of threads in all forums
  • Number of unapproved threads in all forums
  • Number of deleted threads in all forums
  • Number of posts in all forums
  • Number of unapproved threads in all forums
  • Number of deleted posts in all forums
  • Number of registered users
  • ID of the last registered user
  • Total number of online users
  • Number of online members
  • Number of online bots
  • Number of online guests
  • Posts per day
  • Threads per day
  • Members per day
  • Posts per member
  • Threads per member
  • Replies per thread
  • Percentage of users who have posted

Using with Grafana

I've started work on a very basic Grafana dashboard, which currently looks like the following:

[Image: YsgWdGt%20-%20Imgur.png]

I've posted the exported Grafana config for this dashboard here - hopefully others can use this as a base to improve upon and share back with the community Smile https://gist.github.com/euantorano/64703...f15ef9bbfa