Skip to content
Prometheus exporter for WordPress
Go Dockerfile Shell
Branch: master
Clone or download
Pull request Compare This branch is 3 commits ahead of kotsis:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore
Dockerfile
Gopkg.lock
Gopkg.toml
LICENSE
README.md
docker-compose.yml
docker-entrypoint.sh
wordpress_exporter.go
wordpress_grafana.json

README.md

wordpress_exporter

Prometheus exporter for WordPress

Install wordpress_exporter

$ go get github.com/kotsis/wordpress_exporter

Usage of wordpress_exporter

$ wordpress_exporter -wpconfig=/path/to/wp-config

or

$ wordpress_exporter -host=127.0.0.1 -port=3306 -user=uuuu -db=dddd -tableprefix=wp_ -pass=xxxx

It starts serving metrics at http://localhost:8888/metrics

Prometheus configuration for wordpress_exporter

For Prometheus to start scraping the metrics you have to edit /etc/prometheus/prometheus.yml and add:

  - job_name: 'wordpress'
    # metrics_path defaults to '/metrics'
    # scheme defaults to 'http'.
    static_configs:
    - targets: ['localhost:8888']

the above is valid if the exporter runs at the same host as prometheus service. If prometheus runs in a docker container perhaps you will need to change localhost with the IP of the host system, something like 172.17.0.1

WordPress service with docker-compose

Here is provided a quick WordPress service setup with docker-compose for testing the wordpress_exporter. You can go in $GOPATH/src/github.com/kotsis/wordress_exporter and run:

$ sudo docker-compose up -d

Now a wordpress is being served at : http://localhost:8000 where you must visit and create a user with a password. Then you can login in WordPress and create posts, users etc.

Next you must start the wordpress_exporter

$ wordpress_exporter -port=33306 -db=wordpress -user=wordpress -pass=wordpress1234

You will see the metrics from those actions.

Grafana

You can find a WordPress dashboard in $GOPATH/src/github.com/kotsis/wordress_exporter/wordpress_grafana.json

For it to work you must define in Grafana a new Prometheus data source as prom1 This must be the Prometheus instance that is scrapin metrics from wordpress_exporter. Then you can import the above json file and start viewing the metrics.

You can’t perform that action at this time.