A WordPress plugin, based on https://github.com/CodeAtCode/WPDB-Status.
Grafana dashboard avalaible on official website.
- You need Composer
- Run
composer update -o
In wp-config.php you need to settings that constant that will be used to expose those metrics in the url.
define( 'PROMETHEUS_KEY', 'fg98dfgkj' );
To add a new target:
- job_name: "WordPress metrics"
static_configs:
- targets: ["domain.tld"]
scrape_interval: "5m"
metrics_path: "/wp-json/metrics"
params:
prometheus: ['fg98dfgkj']
users: ['yes']
posts: ['yes']
pages: ['yes']
autoload: ['yes']
transient: ['yes']
user_sessions: ['yes']
posts_without_content: ['yes']
posts_without_title: ['yes']
db_size: ['yes']
pending_updates: ['yes']
scheme: "https"
This plugin includes a hook to append new metrics: prometheus_custom_metrics
all=yes
enables all of the default filters at once
See the included page at Tools
-> Site Health
-> Prometheus
with specific metric parameters.
- Major rewrite, which may break your current metrics!
- Requires at least WordPress 5.6 and PHP 7.3
- Added PHP 8.0 polyfill
- Use 'gauge' instead of 'counter'
- Define
PROMETHEUS_LEGACY_TYPE
with true to change this
- Define
- Added more metrics
- You can add custom metrics by implementing WP_Prometheus_Metrics\Metric
- Added timestamps to metrics
- Metrics will be cached for 1h by default (use filter
prometheus-metrics-for-wp/timeout
to change this) - Seperated metrics for different post types
- Site health check integration
- View url for endpoint
- Ability to generate authentication keys
Legacy support
To use 'counter' instead of 'gauge', add the following to your wp-config.php
define('PROMETHEUS_LEGACY_TYPE', true);