-
Notifications
You must be signed in to change notification settings - Fork 10
feat: integrate Axiom MetricsDB/MPL querying and prioritize over Grafana #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Licenser
wants to merge
17
commits into
main
Choose a base branch
from
axiom-metrics
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 10 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
fbb2bc1
feat: integrate Axiom MetricsDB/MPL querying and prioritize over Grafana
Licenser d875a9b
refactor: extract range_to_rfc3339 into shared scripts/lib-time
Licenser dd4ec0d
fix: file_mtime tries GNU stat before BSD to avoid stdout pollution o…
Licenser dd64dfd
fix: add auth headers to --spec OPTIONS request
Licenser f5daae2
fix: error on partial --start/--end in axiom-metrics-discover
Licenser 5d7177d
fix(discover-axiom): tag MetricsDB datasets inline in fallback path
Licenser 89cf6ba
fix(lib-time): pluralize time units for GNU date compatibility
Licenser bd15d04
fix(metrics): validate time conversion results before API calls
Licenser 73730bc
fix: consolidate axiom-link for APL+MPL, fix discover-axiom dataset kind
tsenart b4f242f
Merge main into axiom-metrics — resolve conflicts in SKILL.core.md, s…
11bfe16
fix: copy metrics scripts to skill/scripts/ for distribution
Licenser 365e372
fix: suppress SIGPIPE in discover-axiom Strategy 2 fallback
Licenser b13e261
fix: remove priority encoding from grafana.md
Licenser c7154ea
fix: remove priority encoding from SKILL.core.md
Licenser 0d46335
fix: SIGPIPE in test-build frontmatter name check
Licenser 2be3ead
fix: URL-encode timestamps in axiom-metrics-discover query string
Licenser cd5bfb2
fix: add SIGPIPE guard to discover-axiom unlisted datasets pipeline
Licenser File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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,161 @@ | ||
| #!/usr/bin/env bash | ||
| # Axiom MetricsDB info endpoint helper - discover metrics, tags, and tag values | ||
| # | ||
| # Usage: axiom-metrics-discover <deployment> <dataset> [options] <command> [args...] | ||
| # | ||
| # Commands: | ||
| # metrics List all metrics in dataset | ||
| # tags List all tags in dataset | ||
| # tag-values <tag> List values for a tag | ||
| # metric-tags <metric> List tags for a metric | ||
| # metric-tag-values <metric> <tag> List tag values for metric+tag | ||
| # search <value> Find metrics matching a tag value (POST) | ||
| # | ||
| # Options: | ||
| # --range <r> Time range from now (e.g. 1h, 24h, 7d). Default: 1h | ||
| # --start <ts> Start time (RFC3339) | ||
| # --end <ts> End time (RFC3339) | ||
| # | ||
| # Examples: | ||
| # axiom-metrics-discover prod otel-metrics metrics | ||
| # axiom-metrics-discover prod otel-metrics --range 24h tags | ||
| # axiom-metrics-discover prod otel-metrics tag-values service.name | ||
| # axiom-metrics-discover prod otel-metrics metric-tags http.server.request.duration | ||
| # axiom-metrics-discover prod otel-metrics metric-tag-values http.server.request.duration service.name | ||
| # axiom-metrics-discover prod otel-metrics search "api-gateway" | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| if [[ $# -lt 3 ]]; then | ||
| echo "Usage: axiom-metrics-discover <deployment> <dataset> [options] <command> [args...]" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| DEPLOYMENT="$1" | ||
| DATASET="$2" | ||
| shift 2 | ||
|
|
||
| START_TIME="${START_TIME:-}" | ||
| END_TIME="${END_TIME:-}" | ||
| RANGE="${RANGE:-}" | ||
|
|
||
| # Parse options before command | ||
| while [[ $# -gt 0 ]]; do | ||
| case "$1" in | ||
| --start) | ||
| START_TIME="$2" | ||
| shift 2 | ||
| ;; | ||
| --end) | ||
| END_TIME="$2" | ||
| shift 2 | ||
| ;; | ||
| --range) | ||
| RANGE="$2" | ||
| shift 2 | ||
| ;; | ||
| -*) | ||
| echo "Error: Unknown option '$1'." >&2 | ||
| exit 1 | ||
| ;; | ||
| *) | ||
| break | ||
| ;; | ||
| esac | ||
| done | ||
|
|
||
| if [[ $# -lt 1 ]]; then | ||
| echo "Error: No command specified. Use: metrics, tags, tag-values, metric-tags, metric-tag-values, search." >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| COMMAND="$1" | ||
| shift | ||
|
|
||
| SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | ||
|
|
||
| # shellcheck disable=SC1091 | ||
| source "$SCRIPT_DIR/lib-time" | ||
|
|
||
| # Validate time arguments | ||
| if [[ -n "$RANGE" && ( -n "$START_TIME" || -n "$END_TIME" ) ]]; then | ||
| echo "Error: --range cannot be combined with --start/--end." >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| if [[ -n "$RANGE" ]]; then | ||
| START_TIME=$(range_to_rfc3339 "$RANGE") || exit 1 | ||
| END_TIME=$(date -u +%Y-%m-%dT%H:%M:%SZ) || exit 1 | ||
| if [[ -z "$START_TIME" || -z "$END_TIME" ]]; then | ||
| echo "Error: Failed to compute time range from '$RANGE'." >&2 | ||
| exit 1 | ||
| fi | ||
| elif [[ -n "$START_TIME" && -n "$END_TIME" ]]; then | ||
| : # explicit start/end provided | ||
| elif [[ -n "$START_TIME" || -n "$END_TIME" ]]; then | ||
| echo "Error: Both --start and --end are required when specifying explicit times." >&2 | ||
| exit 1 | ||
| else | ||
| # Default to 1h | ||
| START_TIME=$(range_to_rfc3339 "1h") || exit 1 | ||
| END_TIME=$(date -u +%Y-%m-%dT%H:%M:%SZ) || exit 1 | ||
| if [[ -z "$START_TIME" || -z "$END_TIME" ]]; then | ||
| echo "Error: Failed to compute default time range." >&2 | ||
| exit 1 | ||
| fi | ||
| fi | ||
cursor[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| # URL-encode a path segment | ||
| uriencode() { | ||
| jq -rn --arg x "$1" '$x|@uri' | ||
| } | ||
|
|
||
| DATASET_ENC=$(uriencode "$DATASET") | ||
| BASE="/v1/query/metrics/info/datasets/${DATASET_ENC}" | ||
| QS="start=${START_TIME}&end=${END_TIME}" | ||
cursor[bot] marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| case "$COMMAND" in | ||
| metrics) | ||
| "$SCRIPT_DIR/axiom-api" "$DEPLOYMENT" GET "${BASE}/metrics?${QS}" | jq . | ||
| ;; | ||
| tags) | ||
| "$SCRIPT_DIR/axiom-api" "$DEPLOYMENT" GET "${BASE}/tags?${QS}" | jq . | ||
| ;; | ||
| tag-values) | ||
| if [[ $# -lt 1 ]]; then | ||
| echo "Error: tag-values requires a <tag> argument." >&2 | ||
| exit 1 | ||
| fi | ||
| TAG_ENC=$(uriencode "$1") | ||
| "$SCRIPT_DIR/axiom-api" "$DEPLOYMENT" GET "${BASE}/tags/${TAG_ENC}/values?${QS}" | jq . | ||
| ;; | ||
| metric-tags) | ||
| if [[ $# -lt 1 ]]; then | ||
| echo "Error: metric-tags requires a <metric> argument." >&2 | ||
| exit 1 | ||
| fi | ||
| METRIC_ENC=$(uriencode "$1") | ||
| "$SCRIPT_DIR/axiom-api" "$DEPLOYMENT" GET "${BASE}/metrics/${METRIC_ENC}/tags?${QS}" | jq . | ||
| ;; | ||
| metric-tag-values) | ||
| if [[ $# -lt 2 ]]; then | ||
| echo "Error: metric-tag-values requires <metric> and <tag> arguments." >&2 | ||
| exit 1 | ||
| fi | ||
| METRIC_ENC=$(uriencode "$1") | ||
| TAG_ENC=$(uriencode "$2") | ||
| "$SCRIPT_DIR/axiom-api" "$DEPLOYMENT" GET "${BASE}/metrics/${METRIC_ENC}/tags/${TAG_ENC}/values?${QS}" | jq . | ||
| ;; | ||
| search) | ||
| if [[ $# -lt 1 ]]; then | ||
| echo "Error: search requires a <value> argument." >&2 | ||
| exit 1 | ||
| fi | ||
| BODY=$(jq -nc --arg v "$1" '{"value": $v}') | ||
| "$SCRIPT_DIR/axiom-api" "$DEPLOYMENT" POST "${BASE}/metrics?${QS}" "$BODY" | jq . | ||
| ;; | ||
| *) | ||
| echo "Error: Unknown command '$COMMAND'. Use: metrics, tags, tag-values, metric-tags, metric-tag-values, search." >&2 | ||
| exit 1 | ||
| ;; | ||
| esac | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.