Creates arbitrary prometheus metrics.
When creating Grafana dashboards or Prometheus alerts, it is common to make mistakes. You define a threshold that they have to meet, but when modified the next time you may forget those thresholds.
Using this tool, you can create data with the format you want and thus being able to base alerts and graphics on data that resemble reality.
To use this, you'll create a configuration file in which you will define a metric name, description, type and labels and sequences of certain operations.
For example, you'll be able to create a alarm called http_requests
with the
labels {path=/login/, return_code=200}
which will be updated as you wish.
There's an example configuration file called config.yml
in the root of the
repository. It has the next format:
config:
- name: number_of_fruits
description: The number of fruits we have.
type: gauge
labels: [name, color]
sequence:
- time: 5
eval_time: 5
values: 0-20
operation: inc
labels:
name: apple
color: red
- time: 5
eval_time: 5
values: 0-20
operation: inc
labels:
name: apple
color: green
- time: 5
eval_time: 5
values: 0-5
operation: dec
labels:
name: apple
color: green
- time: 5
eval_time: 5
value: 3
operation: inc
labels:
name: apple
color: yellow
The generated metric will be like this:
number_of_fruits{color="red",name="apple"} 14.0
number_of_fruits{color="green",name="apple"} 10.0
number_of_fruits{color="yellow",name="apple"} 4.0
name
: The . [Type: string] [Required]description
: The description to be shown as . [Type: string] [Required]type
: It should be one of the metric types. [Type: string] [Required]labels
: The labels that will be used with the metric. [Type: list of strings] [Optional]sequence.eval_time
: Number of seconds that the sequence will be running. [Type: int] [Required]sequence.interval
: The interval of seconds between each operation will be performed. 1 second is a sane number. [Type: int] [Required]sequence.value
: The value that the operation will apply. It must be a single value. You must choose betweenvalue
andvalues
. [Type: int] [Optional]sequence.values
: The range of values that will randomly be choosed and the operation will apply. It must be two values separed by a dash. You must choose betweenvalue
andvalues
. [Type: string (int-int / float-float)] [Optional]sequence.operation
: The operation that will be applied. It only will be used with the gauge type, and you can choose betweeninc
,dec
orset
. [Optional]sequence.labels
: The labels of the sequence. They must be used iflabels
are declared. [Optional]
- Counter
- Gauge
- Histogram
- Summary
git clone https://github.com/little-angry-clouds/prometheus-data-generator.git
virtualenv -p python3 venv
pip install -r requirements.txt
python prometheus-data-generator/main.py
curl localhost:9000/metrics/
wget https://raw.githubusercontent.com/little-angry-clouds/prometheus-data-generator/master/config.yml
docker run -ti -v `pwd`/config.yml:/config.yml -p 127.0.0.1:9000:9000 \
littleangryclouds/prometheus-data-generator
curl localhost:9000/metrics/
There's some example manifests in the kubernetes
directory. There's defined a
service, configmap, deployment (with
configured)
and a Service Monitor to be used with the .
You may deploy the manifests:
kubectl apply -f kubernetes/ -n monitoring
kubectl port-forward service/prometheus-data-generator 9000:9000
curl localhost:9000/metrics/
You can edit the configmap as you wish and the configmap-reload will eventually reload the configuration without killing the pod.
TODO
TODO