-
Notifications
You must be signed in to change notification settings - Fork 710
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add script to configure metrics and log collection from a local node (#…
- Loading branch information
Showing
1 changed file
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#!/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}" | ||
|
||
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 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" | ||
mkdir -p "${PROMETHEUS_CONFIG_PATH}" | ||
cat > "${PROMETHEUS_CONFIG_FILE}" <<EOL | ||
[ | ||
{ | ||
"labels": { | ||
"network_uuid": "${METRICS_UUID}" | ||
}, | ||
"targets": [ | ||
"127.0.0.1:${API_PORT}" | ||
] | ||
} | ||
] | ||
EOL | ||
echo "Wrote prometheus configuration to ${PROMETHEUS_CONFIG_FILE}" | ||
|
||
PROMTAIL_CONFIG_PATH="${HOME}/.tmpnet/promtail/file_sd_configs" | ||
PROMTAIL_CONFIG_FILE="${PROMTAIL_CONFIG_PATH}/local.json" | ||
mkdir -p "${PROMTAIL_CONFIG_PATH}" | ||
cat > "${PROMTAIL_CONFIG_FILE}" <<EOL | ||
[ | ||
{ | ||
"labels": { | ||
"__path__": "${LOGS_PATH}/*.log", | ||
"network_uuid": "${METRICS_UUID}" | ||
}, | ||
"targets": [ | ||
"localhost" | ||
] | ||
} | ||
] | ||
EOL | ||
echo "Wrote promtail configuration to ${PROMTAIL_CONFIG_FILE}" | ||
|
||
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}" |