From aed5e2a36dec0dd37e8185855bf196a335628b4b Mon Sep 17 00:00:00 2001 From: Oluwatobi Bamidele Date: Fri, 27 Dec 2024 11:44:10 +0100 Subject: [PATCH 1/2] chore: setup jarvis in prometheus config --- prometheus/prometheus.yml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/prometheus/prometheus.yml b/prometheus/prometheus.yml index 401a5e8d9..8714aa8e4 100644 --- a/prometheus/prometheus.yml +++ b/prometheus/prometheus.yml @@ -19,6 +19,27 @@ scrape_configs: target_label: __address__ replacement: "${1}:9100" + # Label the instances with their name and availability zone + - source_labels: [__meta_ec2_tag_Name, __meta_ec2_availability_zone] + target_label: instance + + - job_name: 'jarvis' + ec2_sd_configs: + - region: us-east-1 + port: 8444 + scheme: http # Ensure Prometheus uses HTTP + relabel_configs: + # Keep only the EC2 instances with the tag Swarm set to superadmin + - source_labels: [__meta_ec2_tag_Swarm] + regex: superadmin + action: keep + + # Extract the public IP from EC2 metadata and assign it to __address__ + - source_labels: [__meta_ec2_private_ip] + regex: (.*) + target_label: __address__ + replacement: "${1}:8444/jarvis" + # Label the instances with their name and availability zone - source_labels: [__meta_ec2_tag_Name, __meta_ec2_availability_zone] target_label: instance \ No newline at end of file From 2c3cdc0e50aac0bad8f9dca13732d7a624cb5a47 Mon Sep 17 00:00:00 2001 From: Oluwatobi Bamidele Date: Fri, 27 Dec 2024 11:59:01 +0100 Subject: [PATCH 2/2] fix: explictly added metrics --- prometheus/prometheus.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/prometheus/prometheus.yml b/prometheus/prometheus.yml index 8714aa8e4..f02c5d8bd 100644 --- a/prometheus/prometheus.yml +++ b/prometheus/prometheus.yml @@ -22,12 +22,14 @@ scrape_configs: # Label the instances with their name and availability zone - source_labels: [__meta_ec2_tag_Name, __meta_ec2_availability_zone] target_label: instance + replacement: "${1}-${2}" - job_name: 'jarvis' ec2_sd_configs: - region: us-east-1 port: 8444 scheme: http # Ensure Prometheus uses HTTP + metrics_path: /jarvis/metrics relabel_configs: # Keep only the EC2 instances with the tag Swarm set to superadmin - source_labels: [__meta_ec2_tag_Swarm] @@ -38,8 +40,9 @@ scrape_configs: - source_labels: [__meta_ec2_private_ip] regex: (.*) target_label: __address__ - replacement: "${1}:8444/jarvis" + replacement: "${1}:8444" # Label the instances with their name and availability zone - source_labels: [__meta_ec2_tag_Name, __meta_ec2_availability_zone] - target_label: instance \ No newline at end of file + target_label: instance + replacement: "${1}-${2}" \ No newline at end of file