This example app serves as an example of how one can easily instrument HTTP handlers with Prometheus metrics. It uses the Prometheus go client to create a new Prometheus registry.
Usage is simple, on any request to /
the request will result in a 200
response code. This increments the counter for this response code. Similarly the /err
endpoint will result in a 404
response code, therefore increments that respective counter. Duration metrics are also exposed for any request to /
.
A Docker image is available at: quay.io/brancz/prometheus-example-app:v0.3.0
First, deploy one instance of this example application, which listens and exposes metrics on port 8080 using the following Deployment manifest.
Then, in order for Prometheus to be able to discover and scrape these metrics, in this repository we provide Pod Monitor custom resource as an example. For that, Prometheus Operator needs to be running in the cluster. To install it, follow this guide: quickstart.
For this example application, PodMonitor manifest describes how the metrics can be discovered and scrapped by Prometheus.