From e3cac8bb9814982e704152495f83dc3ffdbf73c5 Mon Sep 17 00:00:00 2001 From: Maru Newby Date: Mon, 4 Nov 2024 16:01:21 +0100 Subject: [PATCH 1/4] Add script to configure metrics and log collection from a local node --- scripts/configure-local-metrics-collection.sh | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100755 scripts/configure-local-metrics-collection.sh diff --git a/scripts/configure-local-metrics-collection.sh b/scripts/configure-local-metrics-collection.sh new file mode 100755 index 000000000000..f9de48f836f0 --- /dev/null +++ b/scripts/configure-local-metrics-collection.sh @@ -0,0 +1,48 @@ +#!/usr/bin/env bash + +set -euo pipefail + +# Configures prometheus and promtail to collect metrics and logs from +# a local node. +# +# To start metrics collection: ./scripts/run_prometheus.sh +# To start log collection: ./scripts/run_promtail.sh + +API_PORT="${API_PORT:-9650}" + +LOG_PATH="${LOG_PATH:-${HOME}/.avalanchego/logs}" + +# Generate a uuid to uniquely identify the collected metrics +METRICS_UUID="$(uuidgen)" + +mkdir -p "${HOME}"/.tmpnet/prometheus/file_sd_configs +cat >"${HOME}"/.tmpnet/prometheus/file_sd_configs/local.json <"${HOME}"/.tmpnet/promtail/file_sd_configs/local.json < Date: Mon, 4 Nov 2024 16:14:16 +0100 Subject: [PATCH 2/4] fixup: Emit instructions for starting collectors --- scripts/configure-local-metrics-collection.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/scripts/configure-local-metrics-collection.sh b/scripts/configure-local-metrics-collection.sh index f9de48f836f0..90b28da3a2ed 100755 --- a/scripts/configure-local-metrics-collection.sh +++ b/scripts/configure-local-metrics-collection.sh @@ -4,9 +4,6 @@ set -euo pipefail # Configures prometheus and promtail to collect metrics and logs from # a local node. -# -# To start metrics collection: ./scripts/run_prometheus.sh -# To start log collection: ./scripts/run_promtail.sh API_PORT="${API_PORT:-9650}" @@ -45,4 +42,6 @@ cat >"${HOME}"/.tmpnet/promtail/file_sd_configs/local.json < Date: Mon, 4 Nov 2024 16:24:44 +0100 Subject: [PATCH 3/4] fixup: Output the location of configuration files that are written --- scripts/configure-local-metrics-collection.sh | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/scripts/configure-local-metrics-collection.sh b/scripts/configure-local-metrics-collection.sh index 90b28da3a2ed..a357acde450a 100755 --- a/scripts/configure-local-metrics-collection.sh +++ b/scripts/configure-local-metrics-collection.sh @@ -12,8 +12,12 @@ LOG_PATH="${LOG_PATH:-${HOME}/.avalanchego/logs}" # Generate a uuid to uniquely identify the collected metrics METRICS_UUID="$(uuidgen)" -mkdir -p "${HOME}"/.tmpnet/prometheus/file_sd_configs -cat >"${HOME}"/.tmpnet/prometheus/file_sd_configs/local.json < "${PROMETHEUS_CONFIG_FILE}" <"${HOME}"/.tmpnet/prometheus/file_sd_configs/local.json <"${HOME}"/.tmpnet/promtail/file_sd_configs/local.json < "${PROMTAIL_CONFIG_FILE}" <"${HOME}"/.tmpnet/promtail/file_sd_configs/local.json < Date: Mon, 4 Nov 2024 16:27:06 +0100 Subject: [PATCH 4/4] fixup: Include api port and logs path in output --- scripts/configure-local-metrics-collection.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/configure-local-metrics-collection.sh b/scripts/configure-local-metrics-collection.sh index a357acde450a..1b86f98b4050 100755 --- a/scripts/configure-local-metrics-collection.sh +++ b/scripts/configure-local-metrics-collection.sh @@ -7,12 +7,12 @@ set -euo pipefail API_PORT="${API_PORT:-9650}" -LOG_PATH="${LOG_PATH:-${HOME}/.avalanchego/logs}" +LOGS_PATH="${LOGS_PATH:-${HOME}/.avalanchego/logs}" # Generate a uuid to uniquely identify the collected metrics METRICS_UUID="$(uuidgen)" -echo "Configuring metrics and log collection for a local node" +echo "Configuring metrics and log collection for a local node with API port ${API_PORT} and logs path ${LOGS_PATH}" PROMETHEUS_CONFIG_PATH="${HOME}/.tmpnet/prometheus/file_sd_configs" PROMETHEUS_CONFIG_FILE="${PROMETHEUS_CONFIG_PATH}/local.json" @@ -38,7 +38,7 @@ cat > "${PROMTAIL_CONFIG_FILE}" <