This project is for use testing custom metrics from a Java application againt the Monitoring-as-code framework.
The demo Java application can be run using Docker.
There is a Dockerfile in the root of this repository, which can be built simply by running:
docker build -t sre-demo-java-app .
Once built, the application can be run using the following command:
docker run -ti -p 8081:8080 sre-demo-java-app
Navigate to http://localhost:8081 and the application should serve a simple HTML page for testing purposes.
-
Add a new target file definition into
prometheus/file_sd_configs/<your-app-name>_target.json
. See here for more information.The file should contain a target definition of the format:
[ { "labels": { "job": "custom-java-app", "__metrics_path__": "/actuator/prometheus", "namespace": "localhost" }, "targets": [ "host.docker.internal:8081" ] } ]
-
Ensure that the custom java application is reachable from the prometheus container.
If running a local environment using Docker compose, both containers should be on the same network and have the ability to communicate.
-
Interact with the exposed HTML page to generate some custom metrics.
-
Define the custom metric types configuration based on the metrics exported from this demo application and configure appropriate SLI config in the mixin files.
-
Modify the
deploy.sh
file within the MaC framework, or run the MaC docker image to generate the recording and alerting rules for the custom metric type. -
The metrics should then be visible from within the Prometheus web client and available to see within Grafana dashboards.