Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add script to configure metrics and log collection from a local node #3517

Merged
merged 4 commits into from
Nov 5, 2024
Merged
Changes from 2 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
47 changes: 47 additions & 0 deletions scripts/configure-local-metrics-collection.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/usr/bin/env bash

set -euo pipefail

# Configures prometheus and promtail to collect metrics and logs from
# a local node.

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 <<EOL
[
{
"labels": {
"network_uuid": "${METRICS_UUID}"
},
"targets": [
"127.0.0.1:${API_PORT}"
]
}
]
EOL

mkdir -p "${HOME}"/.tmpnet/promtail/file_sd_configs
cat >"${HOME}"/.tmpnet/promtail/file_sd_configs/local.json <<EOL
[
{
"labels": {
"__path__": "${LOG_PATH}/*.log",
"network_uuid": "${METRICS_UUID}"
},
"targets": [
"localhost"
]
}
]
EOL

echo "Prometheus and Loki have been configured to collect metrics and logs from the local node."
echo "Metrics collection by prometheus can be started with ./scripts/run_prometheus.sh"
echo "Log collection by promtail can be started with ./scripts/run_promtail.sh"
echo "Grafana link: https://grafana-poc.avax-dev.network/d/kBQpRdWnk/avalanche-main-dashboard?var-filter=network_uuid%7C%3D%7C${METRICS_UUID}"
Loading