Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 55 additions & 19 deletions docker/config/prometheus/config-template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,31 @@ anchors:
tls_config:
insecure_skip_verify: true

relabel_strip_scheme: &relabel_strip_scheme
source_labels:
- __address__
target_label: __address__
regex: (.*)://(.*)
replacement: ${2}
action: replace
relabel_strip_metrics: &relabel_strip_metrics
source_labels:
- __address__
target_label: __address__
regex: (.*?)/(.*)
replacement: ${1}
action: replace
relabel_prevent_mismatch_job: &relabel_prevent_mismatch_job
source_labels: ["job"]
target_label: __dropped
regex: "<job-relabel-placeholder>"
action: keep

relabelings: &relabelings
relabel_configs:
- # Strip the scheme from the discovery generated address.
source_labels:
- __address__
target_label: __address__
regex: (.*)://(.*)
replacement: ${2}
action: replace
- # Strip the metrics path from the discovery generated address.
source_labels:
- __address__
target_label: __address__
regex: (.*?)/(.*)
replacement: ${1}
action: replace
- # Prevent all scrapes that do not match this job.
source_labels: ["job"]
target_label: __dropped
regex: "<job-relabel-placeholder>"
action: keep
- *relabel_strip_scheme
- *relabel_strip_metrics
- *relabel_prevent_mismatch_job

http_configs: &http_configs
http_sd_configs:
Expand Down Expand Up @@ -77,3 +81,35 @@ scrape_configs:

<<: *relabelings

- job_name: node_reward_canister
metrics_path: /metrics
scheme: https

<<: *tls

static_configs:
- targets:
- uuew5-iiaaa-aaaaa-qbx4q-cai.raw.icp0.io
- sgymv-uiaaa-aaaaa-aaaia-cai.raw.icp0.io

# Don't need to filter on job
relabel_configs:
# Strip the address
- source_labels:
- __address__
target_label: canister_id
regex: (.*)\.raw\.icp0\.io
replacement: ${1}
action: replace
# Assign env="dev" to all
- source_labels: ["canister_id"]
target_label: env
regex: .*
replacement: dev
action: replace
# Assign env="prod" to sgymv-uiaaa-aaaaa-aaaia-cai
- source_labels: ["canister_id"]
target_label: env
regex: sgymv-uiaaa-aaaaa-aaaia-cai
replacement: prod
action: replace
5 changes: 5 additions & 0 deletions docker/tools/prom-config-builder/prom_config_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ def ignore_aliases(self, data):
)


SKIP_JOBS = ["node_reward_canister"]

if __name__ == "__main__":
args = parse_args()

Expand All @@ -71,6 +73,9 @@ def ignore_aliases(self, data):
for scrape_config in template["scrape_configs"]:
job_name = scrape_config["job_name"]

if job_name in SKIP_JOBS:
continue

# Restrict job
scrape_config["relabel_configs"][2]["regex"] = job_name

Expand Down