feat: add experimental metrics list command for metric name discovery#112
Open
sagivoulu-0 wants to merge 15 commits intomainfrom
Open
feat: add experimental metrics list command for metric name discovery#112sagivoulu-0 wants to merge 15 commits intomainfrom
sagivoulu-0 wants to merge 15 commits intomainfrom
Conversation
The Prometheus label values and metadata APIs require start/end as Unix epoch seconds, unlike the Dash0 API which accepts relative expressions. This utility handles "now", "now-1h", "now-7d", and absolute ISO 8601 timestamps. Also adds .claude/settings.local.json to .gitignore. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Adds `dash0 -X metrics list` for metric name discovery. Supports: - table output (names only, via label values API) - wide output (name + type + unit + description, via metadata API) - json and csv output formats - --filter for substring/regex matching on metric names - --from/--to time range (default: last 1 hour) - --limit to cap results - --skip-header for table/wide/csv Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
24 tests covering: table/wide/json/csv output, skip-header, filter (substring + regex), limit, empty results, API errors, experimental gate, time range params, dataset handling, auth header, alias (ls), endpoint selection (label values vs metadata), and missing config. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Updates docs/commands.md with full flag reference, examples, and output samples. Adds metrics list examples to README.md. Creates changelog entry for the new experimental command. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Contributor
|
All contributors have signed the CLA ✍️ ✅ |
Wide/json/csv formats now fetch both label values (time-scoped names) and metadata (type/unit/help), then enrich only the names present in the time range. This makes results consistent across all output formats. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Prevents env var leaks between tests by using t.Setenv which automatically restores the original value after the test. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Package-level httpClient enables connection reuse between the label values and metadata API calls in the wide/json/csv code path. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Avoids checking regexErr on every iteration. Also caches the lowercased filter string for the substring path. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Ensures users see "unknown output format" instead of a misleading "--skip-header is not supported" error when both are invalid. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Covers two previously untested paths: --skip-header with -o wide, and agent mode auto-defaulting to JSON output when -o is omitted. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Author
|
I have read the CLA Document and I hereby sign the CLA |
Other commands use a single sentence for the Long description. Removes implementation details about the label values API, metadata API, and filter regex behavior. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Adds explanatory notes at the end of the Examples section (matching the pattern used by logs query and spans query for column aliases). Clarifies filter regex behavior and which formats include metadata. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Matches the convention used by logs query, spans query, traces get, and teams commands throughout the codebase. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Adds now-1h as an example in the --to flag description so users know relative time expressions work for both --from and --to. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
mmanciop
requested changes
Apr 3, 2026
Member
mmanciop
left a comment
There was a problem hiding this comment.
The filters have a different syntax than with other commands, that is going to be very surprising in a bad way.
mmanciop
requested changes
Apr 3, 2026
| $ dash0 metrics instant --query 'sum(rate(http_requests_total[5m]))' | ||
| ``` | ||
|
|
||
| ### `metrics list` (experimental) |
Member
There was a problem hiding this comment.
Better make it a metrics get like traces get. List commands do not have filters and might never have, and metrics query is already planned to do something else.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Why
The CLI has no way to discover available metric names. Users writing PromQL queries via
dash0 metrics instantmust already know exact metric names. The only discovery path today is the Dash0 UI Metric Explorer.What
Adds
dash0 -X metrics listfor metric name discovery, backed by the Prometheus-compatible label values and metadata APIs.-o table(default): Single NAME column via label values API (~850ms, ~348KB)-o wide: NAME + TYPE + UNIT + DESCRIPTION via metadata API (~2s, ~1.1MB)-o json: Array of objects with full metadata-o csv: Same columns as wide--filterfor substring/regex matching on metric names (client-side)--from/--totime range (default: last 1 hour)--limit,--skip-header,--datasetflagsResolveToEpochSeconds()utility for Prometheus API time paramsLinear: ENG-7969
🤖 Generated with Claude Code