Repository navigation
feat(metrics): metrics query runs an ad-hoc timeseries query - #244
Merged
Merged
Conversation
bronto metrics query runs POST /timeseries/search once, saving nothing, and prints the same series table as metrics definitions query. One query from --select, -d/--from-expr, --where, --group-by and --agg (built by the manifest's query resolver), or a whole body with --input. Formula range values reuse the definition query's one-slice request. Assisted-By: Claude
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Explicit --limit 0 can send an invalid request, and conflicting --select and --agg values can silently return the wrong aggregation.
2 open issues
What changed in this PR
Adds bronto metrics query for ad-hoc timeseries queries without saving a metric definition, completing the remaining scope of #189 alongside the saved-definition queries introduced in #205.
Changes:
- Supports flag-based queries and JSON request bodies, with explicit time flags overriding body values.
- Reuses timeseries output and formula range-value handling across query commands.
- Adds unit and integration coverage, endpoint mappings, telemetry classification, and documentation.
| File | Description |
|---|---|
skill.md |
Documents ad-hoc queries and output behavior for agents. |
internal/cli/telemetryargs.go |
Classifies the new --agg flag for telemetry. |
internal/cli/root.go |
Registers metrics query. |
internal/cli/metricdefs.go |
Implements ad-hoc queries and shares timeseries processing. |
internal/cli/metricdefs_test.go |
Tests request construction, precedence, formulas, and validation. |
internal/cli/endpoints.go |
Maps endpoints to the new command. |
internal/cli/endpoints_test.go |
Adds an endpoint probe for metrics query. |
integration/metric_definitions_test.go |
Checks ad-hoc queries against seeded trace data. |
docs/cli/reference/commands/metrics.mdx |
Adds generated command help, flags, and examples. |
docs/cli/guides/resources.mdx |
Lists the new query command. |
docs/cli/guides/monitors-and-dashboards.mdx |
Explains querying before saving a definition. |
Review effort: Balanced
…elect Assisted-By: Claude
This branch was successfully deployed
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.

Completes the remaining half of #189: ad-hoc
POST /timeseries/search. The per-metric half (GET /timeseries/{id}) shipped in #205. Nothing from the issue is left, so:Closes #189
Command
metrics query: it sits next tometrics definitions queryandmetrics top-keys, and it runs the same kind of query unsaved. Its flags are the fields one manifest/definition query holds (--select,-d/--from-expr,--where,--group-by,--agg), with the namessearchalready uses.--inputtakes a full body for several queries or formulas. That is the samequeries/formulasa metric definition holds, so a definition JSON works as-is.manQuery, andmanQuery.resolve(the code dashboard manifests use) builds the API query: the dataset becomesfrom_expr, and the aggregation defaults from the select.timeseriesFlags, and the output goes throughprintTimeseries.queryDefinition's one-slice logic, which now sits in a sharedquerySeriesbehind a fetch func.printTimeseriestakes the window string and a "what to check" hint, so the all-zero warning doesn't point ad-hoc users atdefinitions get.--input: time flags you set override the body'stime_range/num_of_slices/limit, and the body's values beat the flag defaults. This is the same rule assearch --saved.usage_invalid_flags, exit 2), for a missing--select, a missing dataset,-dtogether with--from-expr, a bare field without--agg, an unknown--agg, or more than 5 group keys. Each error names the flag that fixes it. Combining--inputwith the query flags givesusage_conflicting_flags, and an--inputbody with no queries givesusage_invalid_body.--dry-run: the query still runs under--dry-run, as indashboards validate --live, because the POST saves nothing.Spec / #233
#233 re-vendors the spec. For this endpoint it adds only error-response examples, and
MetricQuery.from_exprloses itsmaxLength: 255.SearchTimeseries, the request body and the 200 response are unchanged, so this PR builds onmain, not onchore/spec-revendor-2702ae33.Tests
internal/cli/metricdefs_test.go, fake server viarunResource):--inputprecedence and the formula range-value second call./logsand/timeseries/searchmappings, and the telemetry class for--agg.go test ./...passes andmake lintreports 0 issues.TestMetricDefinitionsLivenow also runsmetrics queryover the seeded spans once they are visible, and asserts a count of 2. That adds one request to the suite and seeds nothing new. It runs in CI's integration job.Docs
skill.md.metrics.mdxreference.🤖 Generated with Claude Code