6.11.18

Ridiculously simple way to get a feel for prometheus in 30 minutes.

0) Deploy your prometheus master from docker....

docker run -p 9090:9090 prom/prometheus


1) Convinced it works ?  Now kill the docker process :)

2) Make a scrape file.


global:
  scrape_interval: 5s
scrape_configs:
- job_name: perceptor-scrape
  scrape_interval: 5s
  static_configs:
  - targets:
    - localhost:9091/mymetrics
~                     


2) Run the above command (in 0) but add path to the file you made above -v /tmp/prometheus.yml:/etc/prometheus/prometheus.yml 

3) Ok, now write a simple program that outputs something this, to localhost:9091


cat << EOF > mymetrics 
metric1 1
metric1 2
metric1 3
EOF

4) cd to the directory havint the 'mymetrics' file above, and Start a Python simple HTTP server from the above directory, on port 9091 

python -m SimpleHTTPServer 9091

Thats it !!!

Now, dont ever do step (3) again, and instead use https://github.com/prometheus/client_python#prometheus-python-client And start up the server in a place that your scrape file (above) can see.


No comments:

Post a Comment