Skip to content

feat(cloud-query): introduce MetricsLabelSearch functionality#3789

Merged
michaeljguarino merged 2 commits into
masterfrom
sebastian/prod-4502-implement-metric-label-search-tool
Jul 2, 2026
Merged

feat(cloud-query): introduce MetricsLabelSearch functionality#3789
michaeljguarino merged 2 commits into
masterfrom
sebastian/prod-4502-implement-metric-label-search-tool

Conversation

@floreks

@floreks floreks commented Jul 1, 2026

Copy link
Copy Markdown
Member
  • Add MetricsLabelSearchInput, MetricsLabelSearchOptions, and AzureMetricsLabelSearchOptions to support label search in metrics.
  • Implement MetricsLabelSearchResult and MetricsLabelSearchOutput for returning search outcomes.
  • Extend ToolQuery interface with MetricsLabelSearch method for querying metrics labels.
  • Update proto message indexes to accommodate new structures.

Test Plan

Test environment: https://console.plrl-dev-aws.onplural.sh/

Checklist

  • I have added a meaningful title and summary to convey the impact of this PR to a user.
  • If required, I have updated the Plural documentation accordingly.
  • I have added tests to cover my changes.
  • I have deployed the agent to a test environment and verified that it works as expected (required only when changing agent code).

Plural Flow: console

- Add `MetricsLabelSearchInput`, `MetricsLabelSearchOptions`, and `AzureMetricsLabelSearchOptions` to support label search in metrics.
- Implement `MetricsLabelSearchResult` and `MetricsLabelSearchOutput` for returning search outcomes.
- Extend `ToolQuery` interface with `MetricsLabelSearch` method for querying metrics labels.
- Update proto message indexes to accommodate new structures.
@floreks floreks self-assigned this Jul 1, 2026
@floreks floreks added the enhancement New feature or request label Jul 1, 2026
@linear

linear Bot commented Jul 1, 2026

Copy link
Copy Markdown

PROD-4502

@soffi-ai

soffi-ai Bot commented Jul 1, 2026

Copy link
Copy Markdown

Soffi AI Summary

This PR extends the go/cloud-query gRPC service and the Elixir AI workbench with a new MetricsLabelSearch capability, enabling AI agents to discover and search metric label names/values across observability backends. This fills a gap in the existing MetricsSearch tool — previously agents could find metrics by name but couldn't enumerate the labels/dimensions on those metrics, which is essential for constructing precise queries.

What changed:

  • Proto contract (toolquery.proto + generated .pb.go/_grpc.pb.go): Added five new protobuf message types — MetricsLabelSearchInput, MetricsLabelSearchOptions, AzureMetricsLabelSearchOptions, MetricsLabelSearchResult, and MetricsLabelSearchOutput — and a new MetricsLabelSearch RPC on the ToolQuery service.
  • Go implementation (go/cloud-query/internal/tools/): Added a provider-agnostic MetricsLabelSearch interface method and implemented it for Prometheus, Azure Monitor, CloudWatch, Datadog, and Dynatrace. Azure gets a specialized AzureMetricsLabelSearchOptions to pass resource ID, metrics namespace, and endpoint overrides.
  • Elixir AI tools (lib/console/ai/tools/workbench/observability/): Added two new AI tool modules — MetricsLabelSearch (generic) and PlrlMetricsLabelSearch (Plural-specific) — backed by the new gRPC call, plus JSON tool-call schema files (priv/tools/) for LLM function-calling.
  • Observability subagent wiring: Minor update in lib/console/ai/workbench/subagents/observability.ex to expose the new tools to the agent.
  • Documentation: Updated go/cloud-query/docs/api-reference.md and README.md to document the new RPC and its parameters.
  • Tests: Added go/cloud-query/internal/tools/metrics_label_search_test.go with unit tests for the new functionality.
  • Token-handling refactor (provider_azure.go): Simplified Azure token acquisition as a preparatory cleanup.

Commits

Commit Summary
ad10171 Introduces the full MetricsLabelSearch feature end-to-end: new protobuf messages and RPC, provider implementations (Prometheus, Azure, CloudWatch, Datadog, Dynatrace), Elixir AI tool modules, JSON tool-call schemas, unit tests, and updated documentation.
6279b0b Refactors Azure provider token handling to simplify token acquisition logic, and adds Azure-specific MetricsLabelSearchOptions (resource ID, metrics namespace, endpoint overrides) to support Azure Monitor's label search requirements.

Deploy in Soffi


Updated: 2026-07-01 10:03 UTC

@greptile-apps

greptile-apps Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR introduces MetricsLabelSearch across the full cloud-query stack — proto definition, generated Go/Elixir code, per-provider implementations (Prometheus, Datadog, CloudWatch, Azure), and the Elixir workbench tool layer. The feature lets callers discover label names or label values for a specific metric, bridging the gap between MetricsSearch (metric names) and Metrics (time-series data).

  • Proto + generated code: Five new messages (MetricsLabelSearchInput, MetricsLabelSearchOptions, AzureMetricsLabelSearchOptions, MetricsLabelSearchResult, MetricsLabelSearchOutput) and one new RPC added; all message type indices are updated consistently.
  • Go providers: Prometheus uses LabelNames/LabelValues over a 24-hour window with metric-scoped matchers; Datadog delegates to ListTagsByMetricName; CloudWatch uses ListMetrics dimensions with the new cloudwatchMetricIdentifier splitter; Azure handles three paths (Managed Prometheus delegate, definition-based label names, and time-series metadata label values); Dynatrace explicitly returns ErrUnsupportedOperation.
  • Elixir layer: New MetricsLabelSearch workbench tool and Plrl.MetricsLabelSearch tool wired into the observability subagent alongside the existing Metrics and MetricsSearch tools.

Confidence Score: 5/5

Safe to merge — all provider implementations are consistent, nil/empty guards are present, the shared output helper correctly deduplicates and limits results, and error paths follow existing conventions throughout the stack.

The change is a clean additive feature with no modification of existing behavior. Each provider has input validation, the Azure client handles an empty metrics endpoint with its existing fallback, and the Dynatrace stub correctly signals unsupported operation. Generated protobuf code has consistent index updates. No logic errors or missing guard conditions were found.

No files require special attention.

Important Files Changed

Filename Overview
go/cloud-query/api/proto/toolquery.proto Added MetricsLabelSearchInput/Options/AzureMetricsLabelSearchOptions/Result/Output messages and MetricsLabelSearch RPC. Proto field numbers are correct and non-colliding.
go/cloud-query/internal/tools/metrics_label_search.go New shared helper: deduplicates, substring-filters, sorts, and truncates label results to the requested limit. Clean and correct.
go/cloud-query/internal/tools/provider_prometheus.go Added MetricsLabelSearch using Prometheus LabelNames/LabelValues APIs over a 24h window with metric-scoped match, filters name from label names results.
go/cloud-query/internal/tools/provider_cloudwatch.go Added MetricsLabelSearch via ListMetrics with the new cloudwatchMetricIdentifier helper that correctly splits namespace/metric on last slash. Bounded to maxPages=6.
go/cloud-query/internal/tools/provider_azure.go Added MetricsLabelSearch with three paths: Managed Prometheus delegate, native label names from metric definitions, and native label values from time-series metadata. Logic is consistent with existing Azure patterns.
go/cloud-query/internal/tools/provider_datadog.go Added MetricsLabelSearch using Datadog v2 ListTagsByMetricName; extracts label names or values from indexed tags. Correct and consistent.
go/cloud-query/internal/tools/provider_dynatrace.go MetricsLabelSearch stub returns ErrUnsupportedOperation as documented; consistent with feature matrix.
go/cloud-query/internal/service/toolquery.go New MetricsLabelSearch gRPC handler validates nil input, connection, and non-empty metric before delegating to provider. Consistent with MetricsSearch pattern.
lib/console/ai/tools/workbench/observability/metrics_label_search.ex New Elixir tool wrapping the gRPC call; correctly dispatches Azure options and delegates non-Azure connections to nil options. Schema selection based on azure prometheus_url is correct.
lib/console/ai/workbench/subagents/observability.ex MetricsLabelSearch tool added alongside Metrics and MetricsSearch in to_tool/2 and plrl_metric_tools/1. Integration looks correct.
lib/console/ai/tools/workbench/observability/plrl_metrics_label_search.ex Plural-native label search tool wrapping MetricsLabelSearch with the internal Prometheus connection. Straightforward delegation.
priv/tools/workbench/observability/metric_label_search.json JSON schema for non-Azure label search: requires only metric, with optional query/label/limit fields. Correct and minimal.

Reviews (2): Last reviewed commit: "feat(cloud-query): introduce MetricsLabe..." | Re-trigger Greptile

Comment thread go/cloud-query/internal/tools/provider_azure.go
@floreks

floreks commented Jul 1, 2026

Copy link
Copy Markdown
Member Author

@greptileai new is a valid go 1.26 syntax. Review again and ignore this issue. Build succeeds just fine.

@floreks

floreks commented Jul 1, 2026

Copy link
Copy Markdown
Member Author

plural deploy to dev

…tions

- Replace direct token assignment with inline `new` keyword for PrometheusConnection.
- Streamline metric query options by using `new()` for StartTime, EndTime, and Interval values.
@michaeljguarino michaeljguarino merged commit 01943d1 into master Jul 2, 2026
25 checks passed
@michaeljguarino michaeljguarino deleted the sebastian/prod-4502-implement-metric-label-search-tool branch July 2, 2026 14:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants