...
This script simply creates (and/or runs) our Prometheus container. So what's going on here?
...
View Git file | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
Line(s) number | Comment | ||
---|---|---|---|
1 | bash script header (tells shell that it's a bash script when it gets executed) | ||
2 | removes / deletes the container. This deletes the already running container (if it exists) before creating a new one.
| ||
3 | main docker run command. The | ||
4 | this data-binds our prometheus.yml config file to | ||
5 | this instructs Docker to create a data volume (for storing our persistent Prometheus data) and call it "prom-data". It's kind of similar to a data-bind but it's managed by Docker and provides many advantages. The actual files (and persistent data) can be found at: | ||
6 | binds port 10090 on the host to post 10090 on the container (in other words exposes the prometheus port on the host).
| ||
7 | Tells Docker that this container should start/restart whenever Docker starts/restarts (for example on boot etc.). | ||
8 | Points Docker to the official Prometheus image. Docker will download this image if it hasn't already. | ||
9-13 | Commands for configuration sent to the Prometheus executable in the container. Most of these are pointing to the various locations were have previous bound with data-binds or data-volumes. | ||
14 | Disabled. Uncomment to enable the admin-api (so can accept POST queries to modify / delete data etc.). |
Anchor | ||||
---|---|---|---|---|
|
This file is the main Prometheus.yml scrape configuration file. It defines things like how often Prometheus should scrape (query) data and from where (and how) it should scrape this data.
...
View Git file | ||||||||
---|---|---|---|---|---|---|---|---|
|
Line(s) number | Comment | ||
---|---|---|---|
1-5 | Default scraping config for how often Prometheus should scrape. Note, these can be overridden for specific scrape configs (see from line 22). | ||
23-29 | Prometheus (be default) monitors itself and can report on scrape query duration, samples added to db, data compaction stats etc.
| ||
31-34 | Scrape configutation for node_exporter, an exporter which scrape server machine metrics. We haven't set this up yet but will in the following sections.
| ||
36-57 | Scrape configuration for blackbox, a prober that can probe endpoints over HTTP, HTTPS, DNS, TCP and ICMP. We haven't set this up yet but will in the following sections.
|
Updating Prometheus with Docker
...
Finally let's enable it (to start on boot) and start the service
Code Block | ||
---|---|---|
| ||
sudo systemctl daemon-reload sudo systemctl enable --now node_exporter |
...