From d8e82df7a13694315a4707850410c2268361ca70 Mon Sep 17 00:00:00 2001 From: rafsalas19 <70273488+rafsalas19@users.noreply.github.com> Date: Wed, 14 Jun 2023 14:51:08 -0400 Subject: [PATCH] adding physical host name to labels (#61) Co-authored-by: Ubuntu --- .gitignore | 3 +++ src/worker/prometheus.yml | 1 + src/worker/start_managed_prometheus.sh | 12 ++++++++++++ 3 files changed, 16 insertions(+) diff --git a/.gitignore b/.gitignore index 8c804e6..e1cbb7e 100644 --- a/.gitignore +++ b/.gitignore @@ -130,6 +130,9 @@ dmypy.json #config files *.ini +*prom_sidecar_config.json +*publisher_config.json +*geneva_config.json # IDE .vs/ diff --git a/src/worker/prometheus.yml b/src/worker/prometheus.yml index cf73fa9..3f8cb30 100644 --- a/src/worker/prometheus.yml +++ b/src/worker/prometheus.yml @@ -5,6 +5,7 @@ global: subscription: subscription_id cluster: cluster_name instance: instance_name + physical_host: physical_host_name remote_write: - url: "http://localhost:8081/api/v1/write" scrape_configs: diff --git a/src/worker/start_managed_prometheus.sh b/src/worker/start_managed_prometheus.sh index fe050f5..f9ed305 100755 --- a/src/worker/start_managed_prometheus.sh +++ b/src/worker/start_managed_prometheus.sh @@ -20,8 +20,19 @@ get_cluster_name(){ echo $cluster_name } +get_physical_host_name(){ + KVP_PATH='/opt/azurehpc/tools/kvp_client' + if [ -f "$KVP_PATH" ]; then + HOST_NAME=$("$KVP_PATH" 3 | grep -i 'PhysicalHostName;' | awk -F 'Value:' '{print $2}'); + echo $HOST_NAME + else + echo "physical_host_name" + fi +} + SUBSCRIPTION_NAME=$(get_subscription) CLUSTER_NAME=$(get_cluster_name) +PHYS_HOST_NAME=$(get_physical_host_name) generate_prom(){ DCMG_TARGET=" - $INSTANCE_NAME:8000\n" @@ -32,6 +43,7 @@ generate_prom(){ sed -i -r "s/subscription_id/$SUBSCRIPTION_NAME/" $PROM_CONFIG sed -i -r "s/cluster_name/$CLUSTER_NAME/" $PROM_CONFIG sed -i -r "s/instance_name/$INSTANCE_NAME/" $PROM_CONFIG + sed -i -r "s/physical_host_name/$PHYS_HOST_NAME/" $PROM_CONFIG sed -i -r "s/\s+- moneo-worker-0:8000/$DCMG_TARGET/" $PROM_CONFIG sed -i -r "s/\s+- moneo-worker-0:8001/$NET_TARRGET/" $PROM_CONFIG