This service simulates Prometheus metrics for what would be a simple HTTP API microservice.
The simplest way to use this simulator is through the published docker image:
docker run -p 8080:8080 pierrevincent/prom-http-simulator:0.1
It exposes the following Prometheus metrics under the /metrics
endpoint:
- Standard Golang metrics
http_requests_total
: Request counter, label byendpoint
andstatus
http_request_duration_milliseconds
: Request latency histogram
Endpoints, request rate and latency profiles are hardcoded, but come with some uncertainty so that metrics look somewhat realistic.
It is also possible to simulate variation of metrics while the service is running,
Under spike mode, the number of requests is multiplied by a factor between 5 and 15, and latency is doubled.
Spike mode can be on, off or random. Changing spike mode can be done with:
# ON
curl -X POST http://SERVICE_URL:8080/spike/on
# OFF
curl -X POST http://SERVICE_URL:8080/spike/off
# RANDOM
curl -X POST http://SERVICE_URL:8080/spike/random
Error rate by default is 1%. It can be changed to a number between 0 and 100 with:
# Setting error rate to 50%
curl -H 'Content-Type: application/json' -X PUT -d '{"error_rate": 50}' http://SERVICE_URL:8080/error_rate