This example demonstrates publishing metrics from GemFire to a monitoring system comprised of Prometheus and Grafana.
From the gemfire-examples/micrometerMetrics directory, run the start task to build the example
and start a cluster. The cluster will have one locator, one server, and a single region. The
locator and server will expose HTTP endpoints for Prometheus to scrape.
$ ../gradlew start
Run the example to put entries into the region and verify that the HTTP endpoints are working.
$ ../gradlew run
The previous command should produce output like the following:
The entry count for region example-region on the server is 10.
A Prometheus endpoint is running at http://localhost:9914.
A Prometheus endpoint is running at http://localhost:9915.
To validate the example, navigate to the endpoints above in a browser. You should see text
resembling the Prometheus exposition
Download and run Prometheus. Go to https://prometheus.io/download to download the
latest release. Then, run the commands below to extract and run it:
$ tar xvfz prometheus-*.tar.gz
$ cd prometheus-*
$ ./prometheus --config.file=../prometheus.yml
The provided prometheus.yml file configures Prometheus to scrape GemFire’s Prometheus endpoints
at two-second intervals.
In a browser, navigate to http://localhost:9090/targets. This page shows GemFire’s Prometheus
endpoints, and their state should be “UP” as shown below:
http://localhost:9090/graph?g0.range_input=30m&g0.expr=geode_cache_entries&g0.tab=0. This page
shows the result of the PromQL query geode_cache_entries over the last 30 minutes. It should
show a value of “10” as the entry count for region example-region on the server:
Download and run Grafana. Add a new Prometheus data source with the address of the Prometheus
server from the previous step. For detailed instructions, see Grafana’s Getting Started
Once you have added the Prometheus data source, you can import this
dashboard from Grafana.com.
To import, select the “plus” icon on the left-hand side and choose the “Import” option. Use the
ID from the link above for the dashboard and specify the Prometheus data source you created in
the last step.
Shut down the cluster.
$ cd ..
$ ../gradlew stop