There few information about how to do it and the big problem is that refer to incomplete WordPress plugins without real site health information from the database.
Based on my experience with another script that I built to check the WordPress’s DB status I created a new plugin.
The new plugin is exposing an endpoint to scrape with Prometheus, with URL parameters to turn them off. In this way it is possible to do different scrapers with different timings for ddifferent parameters.
Last but not last there is also a WordPress hook so it is possible to extend it with new rules.
I was forgetting that include also a constant to pass as URL parameter to show the output, in this way those informations are not exposed to internet.
The plugin is on GitHub at https://github.com/CodeAtCode/Prometheus-Metrics-in-WordPress.
I built also a Grafana Dashboard to use with this plugin and the plugin readme include the configs for Prometheus.
This is the first dashboard that I built for Grafana so expect some changes in the future, probably also to the plugin for other informations.