diff --git a/skills/dvpod-monitoring/SKILL.md b/skills/dvpod-monitoring/SKILL.md new file mode 100644 index 0000000..9e6d128 --- /dev/null +++ b/skills/dvpod-monitoring/SKILL.md @@ -0,0 +1,184 @@ +--- +name: dvpod-monitoring +description: | + Read-only queries against metrics and logs from a deployed Obol DVpod on Kubernetes. Use when + investigating cluster health, charon errors, peer connectivity, validator duty performance, or + beacon node behavior on a running DVpod. For deploying, configuring, or modifying a DVpod + (including enabling Prometheus or Loki shipping), use the `dvpod` skill. For Obol's hosted + Grafana with cross-cluster fleet view, use the `obol-monitoring` skill. +user-invocable: true +disable-model-invocation: false +allowed-tools: Read, Grep, Glob, Bash, Bash(kubectl get *), Bash(kubectl logs *), Bash(kubectl port-forward *), Bash(helm list *), Bash(helm get values *), Bash(curl -sG *), Bash(bash *dvpod-monitoring/health.sh*) +argument-hint: "[query type] [release] — e.g. health my-dv-pod, errors, peers, duties, logs" +--- + +# DVpod Monitoring — Read-Only Queries + +You investigate the health and behavior of a running DVpod by querying its metrics and logs. **You never modify state** — no `helm upgrade`, no `kubectl apply`, no secret writes. If the user wants to enable monitoring, change values, or deploy anything, hand off to the `dvpod` skill. + +## Scope and hand-offs + +- **This skill:** queries against a single deployed DVpod's metrics/logs. +- **`dvpod` skill:** deploy, configure (including enabling Prometheus and configuring Loki shipping), upgrade, troubleshoot, destroy. +- **`obol-monitoring` skill:** Obol's hosted Grafana, fleet-wide view across clusters. + +For namespace, release, pod, and current-values discovery, read [`skills/dvpod/discovery.md`](../dvpod/discovery.md). + +## Pre-flight: detect what is wired up + +Before any query, decide which path applies for **metrics** and **logs** by reading the release's current values: + +```bash +helm get values -n -o json +``` + +### Metrics path (in priority order) + +1. **Bundled Prometheus** — `centralMonitoring.enabled=true`. There will be a `prometheus` Service on port 9090 in the namespace: + ```bash + kubectl get svc prometheus -n + ``` + Query path: port-forward `svc/prometheus 9090` and hit the standard Prometheus HTTP API. +2. **Cluster Prometheus via ServiceMonitor** — `serviceMonitor.enabled=true`. Auto-discover a Prometheus the operator manages: + ```bash + kubectl get prometheus -A -o jsonpath='{range .items[*]}{.metadata.namespace}/{.metadata.name}{"\n"}{end}' 2>/dev/null + kubectl get svc -A -l app.kubernetes.io/name=prometheus 2>/dev/null + kubectl get svc -A -l app=kube-prometheus-stack-prometheus 2>/dev/null + ``` + Port-forward whichever service is found. If multiple, ask the user which. +3. **Direct Charon `/metrics`** — always available, but single-instance and text-format only: + ```bash + kubectl port-forward -n 3620:3620 + ``` + Use for spot checks; PromQL aggregation is not available against this endpoint. +4. **Nothing wired up** — tell the user, and suggest enabling `centralMonitoring` via the `dvpod` skill. + +### Logs path + +- **`kubectl logs`** is always available and is the default. Works even on a stock deployment with no monitoring enabled. +- **LogQL via Loki** is only useful if the user has set `charon.lokiAddresses` to a real Loki *and* can give you a queryable Loki HTTP endpoint. The chart configures *push* only — query routing is the user's responsibility. + +## Gather arguments + +Use `AskUserQuestion` to clarify, but skip if the request is already specific. + +1. **Investigation focus** — health snapshot, charon errors, peer connectivity, duty performance, beacon node, custom PromQL/LogQL. +2. **Time range** — default last 15m; ask if investigating a specific incident. +3. **Release scope** — usually inferred from discovery; only ask if more than one DVpod release is present. + +## Execution + +### Quick health snapshot (preferred for `health` action) + +For the standard health check (readyz, active validators, peer connectivity, beacon node visibility, recent error/warn summary), run the bundled script: + +```bash +bash skills/dvpod-monitoring/health.sh [release] [namespace] +``` + +- With no args, auto-detects the release if exactly one DVpod is deployed. +- With release only, looks up the namespace via `helm list -A`. +- Requires `centralMonitoring.enabled=true` (bundled Prometheus). Errors out with guidance if not. +- Exits non-zero only on infra failures (missing tools, Prometheus port-forward fails, etc.) — not on degraded health. Always show the script's stdout to the user. + +Use this for **all** routine `/dvpod-monitoring health` invocations. Fall through to the per-query path below only when the user asks for something the snapshot doesn't cover (custom PromQL, deep log search, specific incident windows). + +### PromQL via bundled or cluster Prometheus + +```bash +# Run port-forward in the background, then query. +kubectl port-forward -n svc/prometheus 9090:9090 >/dev/null 2>&1 & +PF_PID=$! +trap "kill $PF_PID 2>/dev/null" EXIT + +PROM=http://localhost:9090 + +# Instant query +curl -sG "$PROM/api/v1/query" --data-urlencode 'query=' + +# Range query (last 15m, 30s step) +curl -sG "$PROM/api/v1/query_range" \ + --data-urlencode 'query=' \ + --data-urlencode "start=$(date -u -d '15 minutes ago' +%s)" \ + --data-urlencode "end=$(date -u +%s)" \ + --data-urlencode 'step=30s' +``` + +### Direct Charon `/metrics` (no Prometheus) + +```bash +kubectl port-forward -n 3620:3620 >/dev/null 2>&1 & +PF_PID=$! +trap "kill $PF_PID 2>/dev/null" EXIT + +# Pull the whole metrics dump and grep for what you need +curl -s localhost:3620/metrics | grep -E '^(app_monitoring_readyz|core_scheduler_validators_active|p2p_ping_success)' +``` + +### Logs via `kubectl logs` + +```bash +# Recent charon log lines +kubectl logs -n -c charon --tail=200 + +# Errors in last 15 minutes +kubectl logs -n -c charon --since=15m | grep -iE 'error|warn' + +# Validator client logs +kubectl logs -n -c validator-client --since=15m + +# Across replicas in a release (if the StatefulSet has more than one pod) +kubectl logs -n -l app.kubernetes.io/instance= -c charon --tail=100 --prefix +``` + +### Logs via LogQL (only if Loki is reachable) + +```bash +LOKI= +curl -sG "$LOKI/loki/api/v1/query_range" \ + --data-urlencode 'query={service_name="charon"} |= "error"' \ + --data-urlencode "start=$(date -u -d '15 minutes ago' +%s)000000000" \ + --data-urlencode "end=$(date -u +%s)000000000" \ + --data-urlencode 'limit=200' +``` + +For a query cookbook, see [queries.md](queries.md). + +## Output handling + +- Parse JSON; surface labels and values; flag anomalies. +- For range queries, summarise min/max/avg over the window and call out spikes. +- For logs, group by container or `cluster_peer` if present; show error/warn lines verbatim with timestamps; suppress repetitive noise. +- Always echo the **exact query that was run** so the user can re-run it themselves. +- If a query returns `"status":"error"`, surface the `error`/`errorType` and stop — do not invent results. + +## Common diagnoses + +When showing results, watch for and explicitly call out: + +- **`app_monitoring_readyz != 1`** — node is not ready (BN unreachable, CL not synced, peer threshold not met). +- **High `p2p_ping_latency_secs` p90** — peer network is slow; check `p2p_peer_connection_types` for relayed vs direct. +- **`p2p_ping_success == 0`** for a peer — that operator is unreachable. +- **`core_scheduler_validators_active < cluster_validators`** — some validators not active yet (DKG just completed and deposit unconfirmed, or validator exited). +- **Error spikes in charon logs** — group by `topic` / `component` to identify the failing subsystem. +- **DKG sidecar polling forever** — see `skills/dvpod/troubleshooting.md` for the operator-address mismatch case. + +## Capabilities and limits + +- Read-only against a deployed DVpod's local metrics/logs. +- Cannot enable monitoring, change values, or modify the cluster — those belong to the `dvpod` skill. +- Direct Charon `/metrics` works without Prometheus but supports only point-in-time scalar lookups. +- LogQL requires the user to provide a queryable Loki URL — the chart only configures push. + +## Parsing $ARGUMENTS + +Parse the first word of `$ARGUMENTS` as the query type: + +- `/dvpod-monitoring health [release]` — readyz, peers, active validators +- `/dvpod-monitoring errors [release]` — recent charon errors +- `/dvpod-monitoring peers [release]` — peer connectivity / ping latency +- `/dvpod-monitoring duties [release]` — duty success/failure breakdown +- `/dvpod-monitoring beacon [release]` — beacon node latency / errors +- `/dvpod-monitoring query ` — raw PromQL passthrough +- `/dvpod-monitoring logs [release] [pattern]` — search logs (kubectl or Loki depending on what is available) +- `/dvpod-monitoring` (no args) — auto-detect a release, run pre-flight, and offer the menu diff --git a/skills/dvpod-monitoring/health.sh b/skills/dvpod-monitoring/health.sh new file mode 100755 index 0000000..da73940 --- /dev/null +++ b/skills/dvpod-monitoring/health.sh @@ -0,0 +1,149 @@ +#!/usr/bin/env bash +# DVpod health snapshot via bundled Prometheus + kubectl logs. +# Usage: health.sh [release] [namespace] +# - With no args: auto-detects if there is exactly one dv-pod release. +# - With release only: looks up its namespace via helm. + +set -euo pipefail + +RELEASE="${1:-}" +NAMESPACE="${2:-}" + +require() { + command -v "$1" >/dev/null 2>&1 || { echo "ERROR: '$1' not found in PATH" >&2; exit 1; } +} +require helm; require kubectl; require curl; require jq + +releases_json() { helm list -A --filter '.*dv-pod.*' -o json 2>/dev/null; } + +if [[ -z "$RELEASE" && -z "$NAMESPACE" ]]; then + rels=$(releases_json | jq -r '.[] | "\(.namespace)/\(.name)"') + count=$(printf '%s\n' "$rels" | grep -c . || true) + if [[ "$count" -eq 0 ]]; then + echo "ERROR: no dv-pod helm releases found in any namespace" >&2; exit 1 + fi + if [[ "$count" -gt 1 ]]; then + echo "ERROR: multiple dv-pod releases found; pass [namespace]:" >&2 + printf ' %s\n' $rels >&2 + exit 1 + fi + line="$rels" + NAMESPACE="${line%%/*}" + RELEASE="${line##*/}" +elif [[ -n "$RELEASE" && -z "$NAMESPACE" ]]; then + NAMESPACE=$(releases_json | jq -r ".[] | select(.name==\"$RELEASE\") | .namespace" | head -1) + [[ -n "$NAMESPACE" ]] || { echo "ERROR: release '$RELEASE' not found in any namespace" >&2; exit 1; } +fi + +echo "## DVpod: $RELEASE (namespace: $NAMESPACE)" +echo + +values=$(helm get values "$RELEASE" -n "$NAMESPACE" -o json) +central=$(echo "$values" | jq -r '.centralMonitoring.enabled // false') +nickname=$(echo "$values" | jq -r '.charon.nickname // ""') +bns=$(echo "$values" | jq -r '.charon.beaconNodeEndpoints[]?' | paste -sd, -) +fbns=$(echo "$values" | jq -r '.charon.fallbackBeaconNodeEndpoints[]?' | paste -sd, -) + +echo "### Pre-flight" +echo "- nickname: ${nickname:-}" +echo "- beaconNodeEndpoints: ${bns:-}" +[[ -n "$fbns" ]] && echo "- fallbackBeaconNodeEndpoints: $fbns" +echo "- centralMonitoring.enabled: $central" + +if [[ "$central" != "true" ]]; then + echo + echo "ERROR: centralMonitoring is not enabled. This script targets the bundled Prometheus path." >&2 + echo " Enable it via the dvpod skill, or query charon :3620 directly for spot checks." >&2 + exit 2 +fi + +LPORT=$(( RANDOM % 10000 + 30000 )) +PFLOG=$(mktemp) +kubectl port-forward -n "$NAMESPACE" svc/prometheus "${LPORT}:9090" >"$PFLOG" 2>&1 & +PF_PID=$! +trap 'kill "$PF_PID" 2>/dev/null || true; rm -f "$PFLOG"' EXIT + +for _ in 1 2 3 4 5 6 7 8 9 10; do + curl -sG "http://localhost:${LPORT}/-/ready" >/dev/null 2>&1 && break + sleep 0.5 +done +if ! curl -sG "http://localhost:${LPORT}/-/ready" >/dev/null 2>&1; then + echo "ERROR: prometheus port-forward did not become ready" >&2 + cat "$PFLOG" >&2 + exit 3 +fi + +PROM="http://localhost:${LPORT}" +q() { curl -sG "$PROM/api/v1/query" --data-urlencode "query=$1"; } + +readyz=$(q 'app_monitoring_readyz' | jq -r '.data.result[0].value[1] // "no-data"') +active=$(q 'core_scheduler_validators_active' | jq -r '.data.result[0].value[1] // "no-data"') + +echo +echo "### Health" +echo "- app_monitoring_readyz: $readyz (1 = ready, anything else = degraded)" +echo "- core_scheduler_validators_active: $active" + +echo +echo "### readyz histogram, last 30m" +curl -sG "$PROM/api/v1/query_range" \ + --data-urlencode 'query=app_monitoring_readyz' \ + --data-urlencode "start=$(date -u -d '30 minutes ago' +%s)" \ + --data-urlencode "end=$(date -u +%s)" \ + --data-urlencode 'step=60s' \ + | jq -r '[.data.result[0].values[]?[1]] | group_by(.) | map(" code=\(.[0]) count=\(length)") | .[]' + +echo +self=$(q 'app_monitoring_readyz' | jq -r '.data.result[0].metric.cluster_peer // "unknown"') +echo "### Peers (this node: $self${nickname:+ / nickname=$nickname})" + +peers_all=$(q 'p2p_peer_connection_types' | jq -r '.data.result[].metric.peer' | sort -u) +ping_kv=$(q 'p2p_ping_success' | jq -r '.data.result[] | "\(.metric.peer) \(.value[1])"') +conn_kv=$(q 'p2p_peer_connection_types' | jq -r '.data.result[] | "\(.metric.peer) \(.metric.type) \(.value[1])"') + +remote_seen=0 +while read -r p; do + [[ -z "$p" || "$p" == "$self" ]] && continue + remote_seen=$((remote_seen + 1)) + ping=$(awk -v p="$p" '$1==p{print $2; exit}' <<<"$ping_kv") + direct=$(awk -v p="$p" '$1==p && $2=="direct"{print $3; exit}' <<<"$conn_kv") + relay=$(awk -v p="$p" '$1==p && $2=="relay"{print $3; exit}' <<<"$conn_kv") + ping_int=${ping%%.*}; ping_int=${ping_int:-0} + direct_int=${direct%%.*}; direct_int=${direct_int:-0} + relay_int=${relay%%.*}; relay_int=${relay_int:-0} + + if [[ "$ping_int" -gt 0 ]]; then + if [[ "$direct_int" -gt 0 ]]; then status="ok (direct)" + elif [[ "$relay_int" -gt 0 ]]; then status="ok (relayed)" + else status="ok (pinging, no active connection)" + fi + else + status="UNREACHABLE (last ping failed)" + fi + printf " %-20s ping=%s direct=%s relay=%s %s\n" "$p" "$ping_int" "$direct_int" "$relay_int" "$status" +done <<< "$peers_all" + +if [[ "$remote_seen" -eq 0 ]]; then + echo " (no remote peers detected — this node may be alone in the cluster, or metrics not yet populated)" +fi + +echo +echo "### Beacon nodes seen by charon" +q 'app_beacon_node_version' | jq -r '.data.result[]? | " - \(.metric.version)"' +echo " peers reported by one BN: $(q 'app_beacon_node_peers' | jq -r '.data.result[0].value[1] // "no-data"')" + +echo +echo "### Recent charon errors/warns (last 15m, deduped)" +pod=$(kubectl get pods -n "$NAMESPACE" -l "app.kubernetes.io/instance=$RELEASE" -o jsonpath='{.items[0].metadata.name}') +container=$(kubectl get pod "$pod" -n "$NAMESPACE" -o jsonpath='{range .spec.containers[*]}{.name}{"\n"}{end}' \ + | { grep -E '^(charon|dv-pod)$' || true; } | head -1) +container="${container:-charon}" +errs=$(kubectl logs -n "$NAMESPACE" "$pod" -c "$container" --since=15m 2>/dev/null \ + | { grep -E '"level":"(error|warn)"' || true; } \ + | jq -r '"\(.level | ascii_upcase) [\(.topic // "?")] \(.msg)"' 2>/dev/null \ + | sort | uniq -c | sort -rn | head -10) || true +if [[ -z "$errs" ]]; then + echo " (none)" +else + printf '%s\n' "$errs" | sed 's/^/ /' +fi diff --git a/skills/dvpod-monitoring/queries.md b/skills/dvpod-monitoring/queries.md new file mode 100644 index 0000000..3aed713 --- /dev/null +++ b/skills/dvpod-monitoring/queries.md @@ -0,0 +1,134 @@ +# Query Cookbook + +Curated PromQL and LogQL examples for a deployed DVpod. PromQL examples assume you have port-forwarded a Prometheus that scrapes Charon (either the bundled `prometheus` service or your cluster Prometheus via ServiceMonitor). + +`cluster_name` is set on Charon metrics from cluster-lock metadata once DKG has completed (usually matches the cluster's nickname). `cluster_peer` distinguishes nodes within a cluster. Substitute real values before running, or drop the filter if you only have one DVpod scraped. + +## PromQL — Cluster health + +```promql +# Is this node ready? 1 = ready, anything else = degraded. +app_monitoring_readyz{cluster_name="$CLUSTER_NAME"} + +# Active validators on the local node +core_scheduler_validators_active{cluster_name="$CLUSTER_NAME"} + +# Total validators in the cluster (from cluster-lock) +cluster_validators{cluster_name="$CLUSTER_NAME"} + +# Operators and consensus threshold +cluster_operators{cluster_name="$CLUSTER_NAME"} +cluster_threshold{cluster_name="$CLUSTER_NAME"} +``` + +## PromQL — Peer connectivity + +```promql +# Per-peer ping success (0 = peer unreachable) +sum by (cluster_peer, peer) (p2p_ping_success{cluster_name="$CLUSTER_NAME"}) + +# p90 ping latency by peer over 5m +histogram_quantile( + 0.90, + sum by (le, peer) ( + rate(p2p_ping_latency_secs_bucket{cluster_name="$CLUSTER_NAME"}[5m]) + ) +) + +# Connection type breakdown (direct vs relayed) +max by (peer, type) (p2p_peer_connection_types{cluster_name="$CLUSTER_NAME"}) +``` + +## PromQL — Duty performance + +```promql +# Successful duties per type, last 5m +sum by (duty) ( + increase(core_tracker_success_duties_total{cluster_name="$CLUSTER_NAME"}[5m]) +) + +# Failed duties per type, last 5m (should be near zero) +sum by (duty, reason) ( + increase(core_tracker_failed_duties_total{cluster_name="$CLUSTER_NAME"}[5m]) +) +``` + +## PromQL — Beacon node health + +```promql +# BN call latency p95 by endpoint +histogram_quantile( + 0.95, + sum by (le, endpoint) ( + rate(app_beacon_node_latency_secs_bucket{cluster_name="$CLUSTER_NAME"}[5m]) + ) +) + +# BN errors per endpoint +sum by (endpoint) ( + rate(app_beacon_node_errors_total{cluster_name="$CLUSTER_NAME"}[5m]) +) + +# Detected BN client per peer (useful for diversity audit) +max by (cluster_peer, beacon_id) ( + app_beacon_node_version{cluster_name="$CLUSTER_NAME"} +) +``` + +## PromQL — Health checks / alerts + +```promql +# Currently failing health checks, with severity and description +max by (name, severity, description) ( + app_health_checks_failed_total{cluster_name="$CLUSTER_NAME"} > 0 +) +``` + +## kubectl logs — first-line log search + +`kubectl logs` is always available, regardless of monitoring config. Prefer it for ad-hoc debugging. + +```bash +# Recent charon errors / warnings +kubectl logs -n -c charon --since=15m | grep -iE 'error|warn' + +# Filter charon by component (logs are JSON when logFormat=json, the default) +kubectl logs -n -c charon --since=15m | jq -c 'select(.component=="p2p" and .level=="error")' + +# Lines around a specific slot +kubectl logs -n -c charon --since=1h | grep 'slot=12345678' + +# Validator client missed duties +kubectl logs -n -c validator-client --since=15m | grep -i 'missed\|fail' + +# Tail across all replicas of a release +kubectl logs -n -l app.kubernetes.io/instance= -c charon --tail=100 --prefix +``` + +## LogQL — for users with Charon shipping to Loki + +These only work if `charon.lokiAddresses` is set and the user provides a queryable Loki endpoint. Label set depends on the user's Loki ingest config; the examples below assume Charon's default labels (`service`, `level`). + +```logql +# All charon errors in the window +{service="charon"} |= "error" + +# Errors excluding noisy known-benign topics +{service="charon"} |= "error" != "context canceled" + +# Filter by component (charon logs as JSON by default) +{service="charon"} | json | component="p2p" | level="error" + +# Logs around a specific slot +{service="charon"} |= "slot=12345678" + +# Rate of errors per minute +sum(rate({service="charon"} |= "error" [1m])) +``` + +## Tips + +- All Charon metrics carry `cluster_peer` — add `by (cluster_peer)` to fan out per-operator. +- If a metric returns nothing, first check that the Prometheus you queried actually scrapes Charon. With the bundled Prom this is automatic; with a cluster Prom it depends on the ServiceMonitor selector matching. +- `kubectl logs --since=...` is your friend for incident timelines — the value of having Loki configured is multi-pod / multi-node aggregation, not single-pod debugging. +- For per-component or per-level filtering, leave `charon.logFormat=json` (the default) — it makes `jq` and LogQL filtering far easier than `logfmt`. diff --git a/skills/dvpod/SKILL.md b/skills/dvpod/SKILL.md index 732fdb5..6894057 100644 --- a/skills/dvpod/SKILL.md +++ b/skills/dvpod/SKILL.md @@ -1,14 +1,16 @@ --- name: dvpod description: | - Deploy, manage, monitor, and troubleshoot Obol DVpod (Distributed Validator Pod) deployments - on Kubernetes using the dv-pod Helm chart. Use when the user wants to deploy a new DVpod, + Deploy, manage, and troubleshoot Obol DVpod (Distributed Validator Pod) deployments on + Kubernetes using the dv-pod Helm chart. Use when the user wants to deploy a new DVpod, check status, troubleshoot issues, upgrade, backup, or recover a DVpod deployment. Covers fresh cluster creation, joining existing clusters, ENR management, DKG orchestration, - and validator client configuration. + validator client configuration, and configuring monitoring/log shipping. + For read-only metric and log queries against an already-deployed DVpod, use the + `dvpod-monitoring` skill instead. user-invocable: true disable-model-invocation: false -allowed-tools: Read, Grep, Glob, Bash +allowed-tools: Read, Grep, Glob, Bash, Bash(kubectl get *), Bash(kubectl logs *), Bash(kubectl wait *), Bash(helm list *), Bash(helm get values *) argument-hint: "[action] [options] — actions: deploy, status, logs, troubleshoot, upgrade, backup, recover, enr, destroy" --- @@ -42,6 +44,17 @@ Reference the chart's values, templates, and documentation when answering questi For the full values reference, see [values-reference.md](values-reference.md). For troubleshooting patterns, see [troubleshooting.md](troubleshooting.md). For deployment examples, see [examples.md](examples.md). +For namespace / release / pod resolution, see [discovery.md](discovery.md) — also used by the `dvpod-monitoring` skill. + +## Monitoring options + +The `dv-pod` chart exposes three independent monitoring paths (see [values-reference.md](values-reference.md#monitoring) for the full table): + +- `centralMonitoring.enabled=true` deploys a bundled Prometheus pod that scrapes Charon and remote-writes to `centralMonitoring.promEndpoint` (default: Obol's hosted backend; override for self-hosted). +- `serviceMonitor.enabled=true` creates a `ServiceMonitor` CRD for an existing in-cluster Prometheus Operator to scrape. +- `charon.lokiAddresses` makes Charon push logfmt logs directly to a Loki endpoint, in addition to stderr. + +These can be combined. Configuring or changing them is part of this skill (it's a `helm upgrade`). Querying the metrics or logs after they are wired up is the `dvpod-monitoring` skill's job — hand off there once the user is past configuration. ## Helm Repo Setup diff --git a/skills/dvpod/discovery.md b/skills/dvpod/discovery.md new file mode 100644 index 0000000..c375567 --- /dev/null +++ b/skills/dvpod/discovery.md @@ -0,0 +1,60 @@ +# DVpod Discovery + +Shared helper for finding the namespace, helm release, pod, and current values of a deployed DVpod. Used by both the `dvpod` skill (deploy/manage) and the `dvpod-monitoring` skill (read-only queries). + +## Find the namespace + +Try in order: + +1. User-specified namespace. +2. Existing DVpod releases across all namespaces: + ```bash + helm list -A --filter ".*dv-pod.*" -o json | jq -r '.[] | "\(.namespace)\t\(.name)"' + ``` +3. Default `dv-pod`. + +If multiple namespaces have DVpod releases, ask the user which to target. + +## Find the release + +```bash +helm list -n --filter ".*dv-pod.*" -o json | jq -r '.[].name' +``` + +Multiple releases can share a namespace. Each has its own ENR, pod, PVCs, and (if enabled) ServiceMonitor — never assume there is only one. + +## Find the pod + +```bash +kubectl get pods -n \ + -l app.kubernetes.io/instance= \ + -o jsonpath='{.items[0].metadata.name}' +``` + +## Containers in the pod + +| Container | Purpose | +|---|---| +| `charon` | Charon middleware — main process, exposes metrics on `:3620` | +| `validator-client` | Lighthouse / Teku / Prysm / Nimbus / Lodestar | +| `dkg-sidecar` | DKG orchestration; only active during cluster setup | +| `import-keystores` | Init container; runs once after DKG to load keys into VC | + +## Resolve current values + +```bash +helm get values -n -o json +``` + +Keys to inspect when reasoning about monitoring/logging: + +| Key | Meaning | +|---|---| +| `centralMonitoring.enabled` | Bundled Prometheus pod is deployed in this namespace | +| `centralMonitoring.promEndpoint` | Where the bundled Prom remote-writes | +| `serviceMonitor.enabled` | A ServiceMonitor CRD exists for an external Prometheus Operator | +| `charon.lokiAddresses` | Charon ships logfmt logs to this Loki endpoint (push only) | +| `charon.nickname` | Appears as `cluster_name` label on Charon metrics | +| `charon.logLevel` / `logFormat` | Verbosity and structure of stderr logs | +| `network` | mainnet / sepolia / hoodi | +| `validatorClient.type` | Which VC implementation is running | diff --git a/skills/dvpod/examples.md b/skills/dvpod/examples.md index fedbe72..87f1f1d 100644 --- a/skills/dvpod/examples.md +++ b/skills/dvpod/examples.md @@ -179,7 +179,9 @@ helm upgrade --install my-dv-pod obol/dv-pod \ --timeout=10m ``` -## Example 10: Enable Central Monitoring +## Example 10: Enable Bundled Prometheus + Central Remote-Write + +`centralMonitoring.enabled=true` deploys a local Prometheus pod (`prom/prometheus:v3.11.1`, in-cluster service `prometheus:9090`) that scrapes Charon every 12s and remote-writes to `centralMonitoring.promEndpoint` (default: Obol's hosted backend). ```bash helm upgrade --install my-dv-pod obol/dv-pod \ @@ -191,6 +193,27 @@ helm upgrade --install my-dv-pod obol/dv-pod \ --timeout=10m ``` +To remote-write to your own backend instead of Obol's, override `centralMonitoring.promEndpoint`: + +```bash + --set centralMonitoring.promEndpoint=https://prom.example.com/api/v1/write \ + --set centralMonitoring.token=YOUR_TOKEN +``` + +## Example 10b: Ship Logs to Loki + +Charon can push structured logs directly to a Loki endpoint (no log-shipping sidecar required), in addition to stderr: + +```bash +helm upgrade --install my-dv-pod obol/dv-pod \ + --namespace dv-pod --create-namespace \ + --set charon.operatorAddress=0xYOUR_ADDRESS \ + --set 'charon.beaconNodeEndpoints[0]=http://beacon:5052' \ + --set charon.lokiAddresses=http://loki.monitoring.svc:3100/loki/api/v1/push \ + --set charon.lokiService=my-dv-pod \ + --timeout=10m +``` + ## Example 11: Enable Prometheus ServiceMonitor For clusters running Prometheus Operator: diff --git a/skills/dvpod/troubleshooting.md b/skills/dvpod/troubleshooting.md index 4e13f3d..4063699 100644 --- a/skills/dvpod/troubleshooting.md +++ b/skills/dvpod/troubleshooting.md @@ -232,11 +232,24 @@ If DKG fails or gets stuck: ## Monitoring Endpoints ```bash -# Charon metrics +# Charon metrics (always exposed) kubectl port-forward -n 3620:3620 # Visit: http://localhost:3620/metrics # Validator client metrics (if enabled) kubectl port-forward -n 5064:5064 # Visit: http://localhost:5064/metrics + +# Bundled Prometheus UI (only when centralMonitoring.enabled=true) +kubectl port-forward -n svc/prometheus 9090:9090 +# Visit: http://localhost:9090 +``` + +If `centralMonitoring.enabled=true` was set, a `prometheus` Deployment runs in the +namespace and scrapes Charon at `:3620` every 12s, then remote-writes to +`centralMonitoring.promEndpoint`. Inspect it with: + +```bash +kubectl get deploy,svc,cm -n -l app=prometheus +kubectl logs -n deploy/prometheus ``` diff --git a/skills/dvpod/values-reference.md b/skills/dvpod/values-reference.md index fe10bd0..a14abb5 100644 --- a/skills/dvpod/values-reference.md +++ b/skills/dvpod/values-reference.md @@ -29,6 +29,9 @@ Quick reference for the most important `dv-pod` Helm chart values. For the compl | `charon.featureSet` | Feature set: alpha, beta, stable | `stable` | | `charon.logLevel` | Log level: debug, info, warn, error | `info` | | `charon.logFormat` | Log format: console, logfmt, json | `json` | +| `charon.lokiAddresses` | Loki server URL(s) — Charon ships logfmt logs here in addition to stderr | `""` | +| `charon.lokiService` | Service label sent with logs to Loki | `""` | +| `charon.monitoringAddress` | Listen address for monitoring API (Prometheus, pprof) | `0.0.0.0:3620` | | `charon.p2pRelays` | libp2p relay URLs | — | | `charon.p2pExternalHostname` | External P2P hostname | — | | `charon.directConnectionEnabled` | Pod-to-pod direct P2P | `true` | @@ -80,12 +83,22 @@ Quick reference for the most important `dv-pod` Helm chart values. For the compl ## Monitoring +The chart exposes three independent monitoring paths. They can be combined. + | Value | Description | Default | |-------|-------------|---------| -| `centralMonitoring.enabled` | Enable central monitoring | `false` | -| `centralMonitoring.promEndpoint` | Prometheus remote write URL | `https://vm.monitoring.gcp.obol.tech/write` | -| `centralMonitoring.token` | Monitoring auth token | — | -| `serviceMonitor.enabled` | Enable Prometheus ServiceMonitor | `false` | +| `centralMonitoring.enabled` | Deploy a bundled Prometheus pod (`prom/prometheus:v3.11.1`, port 9090) that scrapes Charon `:3620` every 12s and remote-writes to `promEndpoint` | `false` | +| `centralMonitoring.promEndpoint` | Remote-write target URL for the bundled Prometheus | `https://vm.monitoring.gcp.obol.tech/write` | +| `centralMonitoring.token` | Bearer token attached to remote-write requests | — | +| `serviceMonitor.enabled` | Create a `ServiceMonitor` CRD for an existing Prometheus Operator in the cluster to scrape | `false` | +| `serviceMonitor.interval` | Scrape interval | — | +| `serviceMonitor.scheme` | Scrape scheme (http/https) | — | +| `charon.lokiAddresses` | Push Charon logfmt logs to a Loki endpoint (no sidecar required) | `""` | + +Notes: +- `centralMonitoring.enabled` deploys a local Prometheus pod in the namespace in addition to configuring remote-write. Override `promEndpoint` to point at your own remote-write target if you don't want to ship to Obol's hosted backend. +- The bundled Prometheus is reachable in-cluster as `prometheus:9090` (you can port-forward or point a Grafana at it). +- `serviceMonitor` and `centralMonitoring` are independent — using one doesn't disable the other. ## Resources