Skip to content

Commit c20de07

Browse files
committed
fixup: Further refine metrics links
1 parent 3ee11c3 commit c20de07

File tree

3 files changed

+24
-11
lines changed

3 files changed

+24
-11
lines changed

.github/workflows/ci.yml

+7-10
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ concurrency:
2222
env:
2323
go_version: '~1.21.8'
2424
tmpnet_data_path: ~/.tmpnet
25-
prometheus_url: https://grafana-experimental.avax-dev.network/d/kBQpRdWnk/avalanche-main-dashboard?orgId=1&refresh=10s&var-adhoc=gh_repo%7C%3D%7Cava-labs%2Favalanchego&var-adhoc=gh_run_id%7C%3D%7C${{ github.run_id }}&var-adhoc=gh_run_attempt%7C%3D%7C${{ github.run_attempt }}
25+
prometheus_url: https://grafana-experimental.avax-dev.network/d/kBQpRdWnk/avalanche-main-dashboard?orgId=1&refresh=10s&var-filter=is_ephemeral_node%7C%3D%7Cfalse&var-filter=gh_repo%7C%3D%7Cava-labs%2Favalanchego&var-filter=gh_run_id%7C%3D%7C${{ github.run_id }}&var-filter=gh_run_attempt%7C%3D%7C${{ github.run_attempt }}
2626

2727
jobs:
2828
Unit:
@@ -75,9 +75,8 @@ jobs:
7575
PROMETHEUS_ID: ${{ secrets.PROMETHEUS_ID }}
7676
PROMETHEUS_PASSWORD: ${{ secrets.PROMETHEUS_PASSWORD }}
7777
- name: Notify of metrics availability
78-
run: |
79-
msg="Metrics for this job: ${PROMETHEUS_URL}&var-adhoc=gh_job_id%7C%3D%7C${GH_JOB_ID}&from=$(date '+%s')000&to=now"
80-
echo "::notice::${msg}"
78+
shell: bash
79+
run: .github/workflows/notify-metrics-availability.sh
8180
env:
8281
PROMETHEUS_URL: ${{ env.prometheus_url }}
8382
GH_JOB_ID: ${{ github.job }}
@@ -117,9 +116,8 @@ jobs:
117116
PROMETHEUS_ID: ${{ secrets.PROMETHEUS_ID }}
118117
PROMETHEUS_PASSWORD: ${{ secrets.PROMETHEUS_PASSWORD }}
119118
- name: Notify of metrics availability
120-
run: |
121-
msg="Metrics for this job: ${PROMETHEUS_URL}&var-gh_job_id=${GH_JOB_ID}"
122-
echo "::notice::${msg}"
119+
shell: bash
120+
run: .github/workflows/notify-metrics-availability.sh
123121
env:
124122
PROMETHEUS_URL: ${{ env.prometheus_url }}
125123
GH_JOB_ID: ${{ github.job }}
@@ -158,9 +156,8 @@ jobs:
158156
PROMETHEUS_ID: ${{ secrets.PROMETHEUS_ID }}
159157
PROMETHEUS_PASSWORD: ${{ secrets.PROMETHEUS_PASSWORD }}
160158
- name: Notify of metrics availability
161-
run: |
162-
msg="Metrics for this job: ${PROMETHEUS_URL}&var-gh_job_id=${GH_JOB_ID}"
163-
echo "::notice::${msg}"
159+
shell: bash
160+
run: .github/workflows/notify-metrics-availability.sh
164161
env:
165162
PROMETHEUS_URL: ${{ env.prometheus_url }}
166163
GH_JOB_ID: ${{ github.job }}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
5+
# Timestamps are in seconds
6+
from_timestamp="$(date '+%s')"
7+
monitoring_period=1800
8+
to_timestamp="$((${from_timestamp} + ${monitoring_period}))"
9+
10+
# Grafana expects microseconds, so just pad out with 3 zeros
11+
metrics_url="Metrics for this job: ${PROMETHEUS_URL}&var-filter=gh_job_id%7C%3D%7C${GH_JOB_ID}&from=${from_timestamp}000&to=${to_timestamp}000"
12+
13+
echo "::notice links::metrics ${metrics_url}"

tests/fixture/tmpnet/network.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,9 @@ func (n *Network) Start(ctx context.Context, w io.Writer) error {
302302
return err
303303
}
304304

305+
// Record the time before nodes are started to ensure visibility of subsequently collected metrics via the emitted link
306+
startTime := time.Now()
307+
305308
// Configure the networking for each node and start
306309
for _, node := range n.Nodes {
307310
if err := n.StartNode(ctx, w, node); err != nil {
@@ -319,7 +322,7 @@ func (n *Network) Start(ctx context.Context, w io.Writer) error {
319322
return err
320323
}
321324
// Provide a link the main dashboard filtered by the uuid and showing results for now till whenever the link is viewed
322-
if _, err := fmt.Fprintf(w, "\nMetrics: https://grafana-experimental.avax-dev.network/d/kBQpRdWnk/avalanche-main-dashboard?&var-adhoc=network_uuid%%7C%%3D%%7C%s&from=%d&to=now\n", n.UUID, time.Now().UnixMilli()); err != nil {
325+
if _, err := fmt.Fprintf(w, "\nMetrics: https://grafana-experimental.avax-dev.network/d/kBQpRdWnk/avalanche-main-dashboard?&var-filter=network_uuid%%7C%%3D%%7C%s&var-filter=is_ephemeral_node%%7C%%3D%%7Cfalse&from=%d&to=now\n", n.UUID, startTime.UnixMilli()); err != nil {
323326
return err
324327
}
325328

0 commit comments

Comments
 (0)