From c0068318cb8351bdc97d6802c040bfe8387ae956 Mon Sep 17 00:00:00 2001 From: Stephen Gutekanst Date: Wed, 11 Sep 2019 16:55:59 -0700 Subject: [PATCH] Cleanup some monitoring changes (#40) * prometheus: cleanup README * prometheus: use new disk folder to make upgrading seamless * undo whitespace change * prometheus: add back docker.rules --- deploy-grafana.sh | 1 - deploy-prometheus.sh | 3 +-- prometheus/README.md | 7 ++----- prometheus/docker_rules.yml | 13 +++++++++++++ 4 files changed, 16 insertions(+), 8 deletions(-) create mode 100644 prometheus/docker_rules.yml diff --git a/deploy-grafana.sh b/deploy-grafana.sh index 1cd3538..b4cc2fd 100755 --- a/deploy-grafana.sh +++ b/deploy-grafana.sh @@ -1,5 +1,4 @@ #!/usr/bin/env bash - set -e # Description: Dashboards and graphs for Prometheus metrics. diff --git a/deploy-prometheus.sh b/deploy-prometheus.sh index d76ae96..d55b922 100755 --- a/deploy-prometheus.sh +++ b/deploy-prometheus.sh @@ -1,5 +1,4 @@ #!/usr/bin/env bash - set -e # Description: Prometheus collects metrics and aggregates them into graphs. @@ -17,6 +16,6 @@ docker run --detach \ --cpus=4 \ --memory=8g \ -p 0.0.0.0:9090:9090 \ - -v ~/sourcegraph-docker/prometheus-disk:/prometheus \ + -v ~/sourcegraph-docker/prometheus-v2-disk:/prometheus \ -v $(pwd)/prometheus:/sg_prometheus_add_ons \ sourcegraph/prometheus:v2.12.0@sha256:aca8cf12d41cbf5d8885ed675fa017b83ad73af96d86bbe5bcead45ca8e958f3 diff --git a/prometheus/README.md b/prometheus/README.md index c2ff40d..5bb0319 100644 --- a/prometheus/README.md +++ b/prometheus/README.md @@ -7,24 +7,21 @@ simply `docker restart prometheus` for your changes to take effect (depending on may respond to it as soon as you save the file). You can add `_rules.yml` and `_targets.yml` files to this directory and they will be picked up automatically. -For example see below on how to add a target for docker itself. ### Docker metrics scraping - + To scrape Docker itself for metrics, add the following file depending on your host machine OS: #### Linux Create `prometheus/docker_targets.yml`: -#### Linux - ```yaml - labels: job: docker targets: - localhost:9323 - ``` +``` #### Mac & Windows diff --git a/prometheus/docker_rules.yml b/prometheus/docker_rules.yml new file mode 100644 index 0000000..0786eb7 --- /dev/null +++ b/prometheus/docker_rules.yml @@ -0,0 +1,13 @@ +# Docker container monitoring rules + +groups: + - name: docker.rules + rules: + - record: container:process_cpu_seconds_total:ratio_rate5m + expr: sum by (instance) (rate(process_cpu_seconds_total[5m])) / engine_daemon_engine_cpus_cpus + - record: container:process_cpu_seconds_total:sum + expr: sum by (instance) (irate(process_cpu_seconds_total[1m])) + - record: container:process_resident_memory_bytes:max + expr: max by (instance) (process_resident_memory_bytes) + - record: container:process_virtual_memory_bytes:max + expr: max by (instance) (process_virtual_memory_bytes)