Skip to content

[FEATURE] Azure: Add resource graph & metrics (batched) datasource, query, and variable plugins - #943

Open
RicardG wants to merge 1 commit into
perses:mainfrom
RicardG:azure-module
Open

RicardG wants to merge 1 commit into
perses:mainfrom
RicardG:azure-module

Conversation

@RicardG

@RicardG RicardG commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Description

Depends on perses/shared#449 within the context of the new Query and Variable plugins to properly support variables containing multiple values (using :csv format).

Soft dependency on #949 to allow the table plugin to render individual rows from JsonData when an array is returned. Without this fix it is basically impossible to list the results of Azure Resource Graph KQL Query in a meaningful way (like in the Azure Resource Graph KQL Query Editor screenshot).

New plugins:

  • Azure Resource Manager Datasource: Retrieves resource information from https://management.azure.com
  • Azure Resource Graph KQL Query: Queries the resource graph for configuration information on resources, returning it in table format (implements Azure Resource Graph API)
  • Azure Resource Graph KQL Variable: Same as the query but populates a variable using the result of the query
  • Azure Regional Metrics Datasource: Retrieves metrics for multiple resources from https://{region_name}.metrics.monitor.azure.com (in batches for efficiency)
  • Azure Metrics Batch Query: Queries Azure for possibly multiple metrics with multiple aggregations on a provided list of resource IDs and returns multiple timeseries (implements Azure Metrics Batch API)

Using the above plugins, some examples of usecases:

  1. Azure Resource Graph KQL Query to retrieve the list of all Virtual Machines of a given VM size from Azure Resource Manager Datasource which are then displayed in a table
  2. Azure Resource Graph KQL Variable to retrieve a list of resource IDs of Virtual Machines from Azure Resource Manager Datasource and populate a variable which is then used in Azure Metrics Batch Query to retrieve metrics for all those resources from Azure Regional Metrics Datasource which are then displayed in a time series chart

Screenshots

Azure Resource Manager Datasource Editor (with proxy configuration since a secret is typically required to access Azure)

AzureResourceManagerDatasourceEditor

Azure Resource Graph KQL Query Editor

AzureResourceGraphKqlQueryEditor

Azure Resource Graph KQL Variable Editor

AzureResourceGraphKqlVariableEditor

Azure Regional Metrics Datasource Editor (with proxy configuration since a secret is typically required to access Azure)

AzureRegionalMetricsDatasourceEditor

Azure Metrics Batch Query Editor

AzureMetricsBatchQueryEditor

Checklist

  • Pull request has a descriptive title and context useful to a reviewer.
  • Pull request title follows the [<catalog_entry>] <commit message> naming convention using one of the
    following catalog_entry values: FEATURE, ENHANCEMENT, BUGFIX, BREAKINGCHANGE, DOC,IGNORE.
  • All commits have DCO signoffs.

UI Changes

  • Changes that impact the UI include screenshots and/or screencasts of the relevant changes.
  • Code follows the UI guidelines.

@RicardG
RicardG requested review from a team, AntoineThebaud and Nexucis as code owners November 19, 2026 04:25
@RicardG
RicardG requested review from jgbernalp and removed request for a team November 19, 2026 04:26

@Nexucis Nexucis left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot @RicardG for this contribution! 🎉 It's really nice to see Azure support coming to Perses. Combining Resource Graph (for discovery and variables) with the Metrics Batch API is a great approach.

The plugin follows the structure of the other plugins well: runtime, CUE schemas, Go SDK, docs and tests are all there. The requests match the Azure REST APIs (resource IDs batched by 50, $skipToken paging, the right api-versions), and the proxy examples using allowedEndpoints and secrets are a nice touch.

I went through it locally, and there are a few things to fix before we can merge. Details are in the inline comments.

To fix before merging

  • CI lint-npm: npm run format:check fails on azure/package.json, AzureRegionalMetricsDatasource.tsx and AzureMetricsBatchQuery.test.ts. Running npm run format should fix it.
  • CI Validate plugin schemas: tests/valid/spec_with_variables.json is rejected because the shared variable regex doesn't accept ${var:csv}. This is linked to how multi-value variables are handled at runtime.
  • The "Single Point" and "Flatten Metrics" checkboxes are never saved in the query spec.
  • Azure error messages are displayed as [object Object].
  • The CUE module path should be github.com/perses/plugins/azure@v0.
  • react-compiler-runtime is missing from azure/package.json.
  • The interval and top docs don't match the implementation and the Azure API.
  • Datasource variables are accepted by the schema but don't work for the Resource Graph query and variable.

Also

Could you move the table fix to a dedicated [BUGFIX] PR? It changes the existing behaviour of the table, so it deserves its own review and changelog entry.

The other comments are suggestions or nits, and they're marked as such. Feel free to push back, or to address them in a follow-up PR.

For the record, everything else passes locally on 3cd2b7d: type-check and test (azure and table), the azure build, go build/go vet/go test, golangci-lint, percli plugin lint, cue fmt --check, and the license and docs checks.

Thanks again, looking forward to having this merged! 🚀

Comment thread docs/azure/model.md Resolved
Comment thread docs/azure/model.md Resolved
Comment thread docs/azure/model.md Resolved
Comment thread table/src/table-data-utils.ts Resolved
Comment thread .gitignore Outdated
.DS_Store
*.local
*.log*
local-module.cue

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this needed for this PR? I couldn't find any reference to local-module.cue in the repository. If it's part of your local setup, a global gitignore would be a better place for it.

@RicardG RicardG Nov 20, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not strictly related to this PR, but rather cue v0.17.0. It now supports using a local module configuration which was useful for testing against local changes to cue specs in perses/shared (similar to what link-with-perses.sh does). I accidently committed the local-module file at least once, hence the gitignore. I thought it could be a worthwhile addition to the repo in case someone else tries a similar testing setup. I removed it from this PR so it does not block it - up to you if it is something worth adding in another PR.

@RicardG
RicardG force-pushed the azure-module branch 2 times, most recently from 35ada58 to 5640f42 Compare November 23, 2026 07:12
@RicardG
RicardG force-pushed the azure-module branch 5 times, most recently from c625b4c to 2b23070 Compare December 2, 2026 05:57
@RicardG
RicardG requested a review from Nexucis December 2, 2026 06:12
…uery, and variable plugins

- Azure Resource Manager Datasource: Retrieves resource information from https://management.azure.com
- Azure Resource Graph KQL Query: Queries the resource graph for configuration information on resources (in table format)
- Azure Resource Graph KQL Variable: Same as the query but populates a variable using the result of the query
- Azure Regional Metrics Datasource: Retrieves metrics for multiple resources from https://{region_name}.metrics.monitor.azure.com (in batches for efficiency)
- Azure Metrics Batch Query: Queries Azure for possibly multiple metrics with multiple aggregations on a provided list of resource IDs

Signed-off-by: Ricard Grace <ricard.grace@amadeus.com>
@RicardG

RicardG commented Dec 3, 2026

Copy link
Copy Markdown
Contributor Author

Hi @Nexucis, the PR should be ready for another review, whenever you get the chance.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Azure requests bypass host-provided authentication and routing, valid responses with missing metadata can crash queries, and incompatible scopes can be submitted together.

6 open issues
What changed in this PR

Adds an Azure plugin workspace to Perses for resource discovery, dashboard variables, and batched metrics queries.

Changes:

  • Introduces two datasources, two query plugins, and a Resource Graph variable plugin.
  • Adds editors, pagination, batching, variable substitution, and automated tests.
  • Provides CUE schemas, Go SDK builders, documentation, and workspace registration.
File Description
package.json Registers Azure workspace.
package-lock.json Records Azure workspace dependencies.
docs/​nav.yaml Adds Azure documentation navigation.
docs/​azure/​README.md Introduces Azure plugins.
docs/​azure/​go-sdk/​variable/​resource-graph-kql.md Documents variable builders.
docs/​azure/​go-sdk/​query/​resource-graph-kql.md Documents Resource Graph builders.
docs/​azure/​go-sdk/​query/​metrics-batch.md Documents metrics query builders.
docs/​azure/​go-sdk/​datasource/​resource-manager.md Documents Resource Manager configuration.
docs/​azure/​go-sdk/​datasource/​regional-metrics.md Documents regional metrics configuration.
azure/​vitest.config.ts Configures workspace tests.
azure/​tsconfig.json Configures TypeScript checking.
azure/​tsconfig.build.json Configures declaration output.
azure/​src/​variables/​index.ts Exports variable plugins.
azure/​src/​variables/​azure-resource-graph-kql-variable/​resource-graph-rows-to-variable-options.ts Maps rows to variable options.
azure/​src/​variables/​azure-resource-graph-kql-variable/​resource-graph-rows-to-variable-options.test.ts Tests option mapping.
azure/​src/​variables/​azure-resource-graph-kql-variable/​index.ts Exports variable implementation.
azure/​src/​variables/​azure-resource-graph-kql-variable/​constants.ts Defines variable defaults.
azure/​src/​variables/​azure-resource-graph-kql-variable/​AzureResourceGraphKqlVariableEditor.tsx Adds variable configuration UI.
azure/​src/​variables/​azure-resource-graph-kql-variable/​AzureResourceGraphKqlVariableEditor.test.tsx Tests variable editor interactions.
azure/​src/​variables/​azure-resource-graph-kql-variable/​AzureResourceGraphKqlVariable.tsx Registers Resource Graph variables.
azure/​src/​variables/​azure-resource-graph-kql-variable/​AzureResourceGraphKqlVariable.test.ts Tests variable execution and dependencies.
azure/​src/​variables/​azure-resource-graph-kql-variable/​azure-resource-graph-kql-variable-types.ts Defines variable configuration types.
azure/​src/​utils/​utils.ts Adds numeric input parsing.
azure/​src/​utils/​index.ts Exports utilities.
azure/​src/​setup-tests.ts Sets up UI testing.
azure/​src/​queries/​index.ts Exports query plugins.
azure/​src/​queries/​azure-resource-graph-kql-query/​index.ts Exports Resource Graph query APIs.
azure/​src/​queries/​azure-resource-graph-kql-query/​get-json-data.ts Resolves variables and retrieves JSON.
azure/​src/​queries/​azure-resource-graph-kql-query/​get-json-data.test.ts Tests JSON query execution.
azure/​src/​queries/​azure-resource-graph-kql-query/​constants.ts Defines query datasource defaults.
azure/​src/​queries/​azure-resource-graph-kql-query/​AzureResourceGraphKqlQueryEditor.tsx Adds KQL query editor.
azure/​src/​queries/​azure-resource-graph-kql-query/​AzureResourceGraphKqlQueryEditor.test.tsx Tests KQL editor interactions.
azure/​src/​queries/​azure-resource-graph-kql-query/​AzureResourceGraphKqlQuery.tsx Registers Resource Graph queries.
azure/​src/​queries/​azure-resource-graph-kql-query/​AzureResourceGraphKqlQuery.test.ts Tests query registration and dependencies.
azure/​src/​queries/​azure-resource-graph-kql-query/​azure-resource-graph-kql-query-types.ts Defines Resource Graph query types.
azure/​src/​queries/​azure-metrics-batch-query/​iso8601-duration.ts Parses metric intervals.
azure/​src/​queries/​azure-metrics-batch-query/​iso8601-duration.test.ts Tests interval parsing.
azure/​src/​queries/​azure-metrics-batch-query/​index.ts Exports metrics query APIs.
azure/​src/​queries/​azure-metrics-batch-query/​constants.ts Defines intervals and aggregations.
azure/​src/​queries/​azure-metrics-batch-query/​AzureMetricsBatchQueryEditor.tsx Adds metrics query editor.
azure/​src/​queries/​azure-metrics-batch-query/​AzureMetricsBatchQueryEditor.test.tsx Tests metrics editor interactions.
azure/​src/​queries/​azure-metrics-batch-query/​AzureMetricsBatchQuery.tsx Registers batched metrics queries.
azure/​src/​queries/​azure-metrics-batch-query/​AzureMetricsBatchQuery.test.ts Tests metrics query integration.
azure/​src/​queries/​azure-metrics-batch-query/​azure-metrics-batch-query-types.ts Defines metrics query configuration.
azure/​src/​index.ts Exports module registration.
azure/​src/​index-federation.ts Adds federation entry point.
azure/​src/​getPluginModule.ts Exposes plugin metadata.
azure/​src/​env.d.ts Adds build environment types.
azure/​src/​datasources/​index.ts Exports Azure datasources.
azure/​src/​datasources/​azure-resource-manager-datasource/​index.ts Exports Resource Manager APIs.
azure/​src/​datasources/​azure-resource-manager-datasource/​constants.ts Defines Resource Graph API defaults.
azure/​src/​datasources/​azure-resource-manager-datasource/​AzureResourceManagerDatasourceEditor.tsx Adds Resource Manager settings UI.
azure/​src/​datasources/​azure-resource-manager-datasource/​AzureResourceManagerDatasourceEditor.test.tsx Tests datasource settings.
azure/​src/​datasources/​azure-resource-manager-datasource/​AzureResourceManagerDatasource.tsx Implements paginated Resource Graph requests.
azure/​src/​datasources/​azure-resource-manager-datasource/​AzureResourceManagerDatasource.test.ts Tests requests and pagination.
azure/​src/​datasources/​azure-resource-manager-datasource/​azure-resource-manager-datasource-types.ts Defines Resource Graph API contracts.
azure/​src/​datasources/​azure-resource-manager-datasource/​azure-resource-manager-datasource-selectors.ts Adds datasource selector helpers.
azure/​src/​datasources/​azure-regional-metrics-datasource/​index.ts Exports regional metrics APIs.
azure/​src/​datasources/​azure-regional-metrics-datasource/​constants.ts Defines batching limits and API version.
azure/​src/​datasources/​azure-regional-metrics-datasource/​AzureRegionalMetricsDatasourceEditor.tsx Adds regional metrics settings UI.
azure/​src/​datasources/​azure-regional-metrics-datasource/​AzureRegionalMetricsDatasourceEditor.test.tsx Tests regional datasource settings.
azure/​src/​datasources/​azure-regional-metrics-datasource/​AzureRegionalMetricsDatasource.tsx Implements batched metrics requests.
azure/​src/​datasources/​azure-regional-metrics-datasource/​azure-regional-metrics-datasource-types.ts Defines metrics API contracts.
azure/​src/​datasources/​azure-regional-metrics-datasource/​azure-regional-metrics-datasource-selectors.ts Adds regional datasource selectors.
azure/​src/​bootstrap.tsx Adds development bootstrap.
azure/​sdk/​go/​variable/​azure-resource-graph-kql-variable/​variable.go Adds variable builder.
azure/​sdk/​go/​variable/​azure-resource-graph-kql-variable/​options.go Adds variable builder options.
azure/​sdk/​go/​query/​azure-resource-graph-kql-query/​query.go Adds Resource Graph query builder.
azure/​sdk/​go/​query/​azure-resource-graph-kql-query/​options.go Adds Resource Graph query options.
azure/​sdk/​go/​query/​azure-metrics-batch-query/​query.go Adds metrics query builder.
azure/​sdk/​go/​query/​azure-metrics-batch-query/​options.go Adds metrics query options.
azure/​sdk/​go/​datasource/​azure-resource-manager-datasource/​options.go Adds Resource Manager connection options.
azure/​sdk/​go/​datasource/​azure-resource-manager-datasource/​datasource.go Adds Resource Manager datasource builder.
azure/​sdk/​go/​datasource/​azure-regional-metrics-datasource/​options.go Adds regional metrics connection options.
azure/​sdk/​go/​datasource/​azure-regional-metrics-datasource/​datasource.go Adds regional metrics datasource builder.
azure/​schemas/​variables/​azure-resource-graph-kql-variable/​tests/​valid/​simple_spec.json Adds valid variable fixture.
azure/​schemas/​variables/​azure-resource-graph-kql-variable/​tests/​invalid/​bad_subscription_id.json Covers invalid subscription IDs.
azure/​schemas/​variables/​azure-resource-graph-kql-variable/​azure-resource-graph-kql-variable.cue Defines variable schema.
azure/​schemas/​queries/​azure-resource-graph-kql-query/​tests/​valid/​simple_spec.json Adds valid KQL query fixture.
azure/​schemas/​queries/​azure-resource-graph-kql-query/​tests/​invalid/​bad_subscription_id.json Covers invalid subscription IDs.
azure/​schemas/​queries/​azure-resource-graph-kql-query/​azure-resource-graph-kql-query.cue Defines KQL query schema.
azure/​schemas/​queries/​azure-metrics-batch-query/​tests/​valid/​spec_with_variables.json Covers variable-based metrics configuration.
azure/​schemas/​queries/​azure-metrics-batch-query/​tests/​valid/​simple_spec.json Covers metrics query options.
azure/​schemas/​queries/​azure-metrics-batch-query/​tests/​valid/​multiple_resources.json Covers multiple resource IDs.
azure/​schemas/​queries/​azure-metrics-batch-query/​tests/​invalid/​bad_top.json Covers invalid record limits.
azure/​schemas/​queries/​azure-metrics-batch-query/​tests/​invalid/​bad_subscription_id.json Covers invalid subscription IDs.
azure/​schemas/​queries/​azure-metrics-batch-query/​tests/​invalid/​bad_interval_4.json Covers dangling time designators.
azure/​schemas/​queries/​azure-metrics-batch-query/​tests/​invalid/​bad_interval_3.json Covers empty durations.
azure/​schemas/​queries/​azure-metrics-batch-query/​tests/​invalid/​bad_interval_2.json Covers empty time components.
azure/​schemas/​queries/​azure-metrics-batch-query/​tests/​invalid/​bad_interval_1.json Covers malformed intervals.
azure/​schemas/​queries/​azure-metrics-batch-query/​tests/​invalid/​bad_aggregation.json Covers unsupported aggregations.
azure/​schemas/​queries/​azure-metrics-batch-query/​azure-metrics-batch-query.cue Defines metrics query schema.
azure/​schemas/​datasources/​azure-resource-manager-datasource/​tests/​valid/​simple_spec.json Adds valid datasource fixture.
azure/​schemas/​datasources/​azure-resource-manager-datasource/​tests/​invalid/​bad_max_requests.json Covers invalid pagination limits.
azure/​schemas/​datasources/​azure-resource-manager-datasource/​azure-resource-manager-datasource.cue Defines Resource Manager datasource schema.
azure/​schemas/​datasources/​azure-regional-metrics-datasource/​tests/​valid/​simple_spec.json Adds valid regional datasource fixture.
azure/​schemas/​datasources/​azure-regional-metrics-datasource/​tests/​invalid/​bad_max_requests.json Covers invalid batching limits.
azure/​schemas/​datasources/​azure-regional-metrics-datasource/​azure-regional-metrics-datasource.cue Defines regional metrics datasource schema.
azure/​rsbuild.config.ts Exposes five federated plugins.
azure/​README.md Documents installation and development.
azure/​package.json Declares package and plugin metadata.
azure/​go.sum Records Go dependency checksums.
azure/​go.mod Declares Azure Go module dependencies.
azure/​cue.mod/​module.cue Declares CUE module dependencies.

Review effort: Balanced

body: JSON.stringify(buildMetricsBatchRequestBody({ ...metricsBatchOptions, resourceIds })),
};

const response = await globalThis.fetch(url, { ...init, signal: abortSignal });

export interface TimeSeriesElement {
data: MetricValue[]; // One MetricValue per timestamp
metadatavalues: MetadataValue[];
Comment on lines +137 to +138
managementGroups: resourceGraphParams.managementGroups,
subscriptions: resourceGraphParams.subscriptions,
Comment on lines +129 to +131
} else if (response.status === 'fulfilled') {
success = true;
}
Comment on lines +84 to +85
if (successBody.$skipToken === undefined) {
return { responses: [successBody], truncated: false };
function HelpInfoTooltip(props: { description: string }): ReactElement {
return (
<InfoTooltip description={props.description} enterDelay={100}>
<IconButton
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants