Schema: Initial Azure Monitor query schema (#62018)

* Initial schema

- Add types based off of current frontend

* Rename and field-level comments

* Update report and regenerate files

* Rename frontend Azure folder

- Doing this for consistency and to ensure code-generation works
- Update betterer results due to file renames

* Remove default and add back enum vals that I deleted

* Set workspace prop as optional

* Replace template variable types

* Connect frontend query types

- Keep properties optional for now to avoid major changes
- Rename AzureMetricResource
- Correctly use ResultFormat

* Add TSVeneer decorator

* Update schema

* Update type

* Update CODEOWNERS

* Fix gen-cue issue

* Fix backend test

* Fix e2e test

* Update code coverage

* Remove references to old Azure Monitor path

* Review

* Regen files
This commit is contained in:
Andreas Christou 2023-02-03 16:06:54 +00:00 committed by GitHub
parent 57ac59c7f6
commit d7f7cd1e61
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
170 changed files with 1208 additions and 395 deletions

View File

@ -5169,6 +5169,125 @@ exports[`better eslint`] = {
[0, 0, 0, "Unexpected any. Specify a different type.", "7"],
[0, 0, 0, "Unexpected any. Specify a different type.", "8"]
],
"public/app/plugins/datasource/azuremonitor/__mocks__/query_ctrl.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
[0, 0, 0, "Unexpected any. Specify a different type.", "2"],
[0, 0, 0, "Unexpected any. Specify a different type.", "3"],
[0, 0, 0, "Unexpected any. Specify a different type.", "4"]
],
"public/app/plugins/datasource/azuremonitor/azure_log_analytics/__mocks__/schema.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
],
"public/app/plugins/datasource/azuremonitor/azure_log_analytics/azure_log_analytics_datasource.test.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
[0, 0, 0, "Unexpected any. Specify a different type.", "2"],
[0, 0, 0, "Unexpected any. Specify a different type.", "3"]
],
"public/app/plugins/datasource/azuremonitor/azure_log_analytics/azure_log_analytics_datasource.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
[0, 0, 0, "Unexpected any. Specify a different type.", "2"],
[0, 0, 0, "Unexpected any. Specify a different type.", "3"],
[0, 0, 0, "Unexpected any. Specify a different type.", "4"],
[0, 0, 0, "Unexpected any. Specify a different type.", "5"],
[0, 0, 0, "Unexpected any. Specify a different type.", "6"],
[0, 0, 0, "Unexpected any. Specify a different type.", "7"],
[0, 0, 0, "Unexpected any. Specify a different type.", "8"],
[0, 0, 0, "Unexpected any. Specify a different type.", "9"]
],
"public/app/plugins/datasource/azuremonitor/azure_log_analytics/response_parser.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
[0, 0, 0, "Unexpected any. Specify a different type.", "2"],
[0, 0, 0, "Unexpected any. Specify a different type.", "3"],
[0, 0, 0, "Unexpected any. Specify a different type.", "4"],
[0, 0, 0, "Unexpected any. Specify a different type.", "5"],
[0, 0, 0, "Unexpected any. Specify a different type.", "6"],
[0, 0, 0, "Unexpected any. Specify a different type.", "7"],
[0, 0, 0, "Unexpected any. Specify a different type.", "8"],
[0, 0, 0, "Do not use any type assertions.", "9"],
[0, 0, 0, "Unexpected any. Specify a different type.", "10"],
[0, 0, 0, "Unexpected any. Specify a different type.", "11"],
[0, 0, 0, "Unexpected any. Specify a different type.", "12"],
[0, 0, 0, "Unexpected any. Specify a different type.", "13"],
[0, 0, 0, "Unexpected any. Specify a different type.", "14"]
],
"public/app/plugins/datasource/azuremonitor/azure_monitor/azure_monitor_datasource.test.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
[0, 0, 0, "Unexpected any. Specify a different type.", "2"]
],
"public/app/plugins/datasource/azuremonitor/azure_monitor/azure_monitor_datasource.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
[0, 0, 0, "Do not use any type assertions.", "2"]
],
"public/app/plugins/datasource/azuremonitor/azure_monitor/response_parser.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
[0, 0, 0, "Unexpected any. Specify a different type.", "2"],
[0, 0, 0, "Unexpected any. Specify a different type.", "3"],
[0, 0, 0, "Unexpected any. Specify a different type.", "4"]
],
"public/app/plugins/datasource/azuremonitor/azure_resource_graph/azure_resource_graph_datasource.test.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
],
"public/app/plugins/datasource/azuremonitor/azure_resource_graph/azure_resource_graph_datasource.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
],
"public/app/plugins/datasource/azuremonitor/components/LogsQueryEditor/QueryField.tsx:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
[0, 0, 0, "Do not use any type assertions.", "2"],
[0, 0, 0, "Do not use any type assertions.", "3"]
],
"public/app/plugins/datasource/azuremonitor/components/MetricsQueryEditor/dataHooks.test.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
[0, 0, 0, "Unexpected any. Specify a different type.", "2"],
[0, 0, 0, "Unexpected any. Specify a different type.", "3"]
],
"public/app/plugins/datasource/azuremonitor/components/MonitorConfig.tsx:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"]
],
"public/app/plugins/datasource/azuremonitor/components/QueryEditor/QueryEditor.tsx:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"]
],
"public/app/plugins/datasource/azuremonitor/components/ResourcePicker/ResourcePicker.test.tsx:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
],
"public/app/plugins/datasource/azuremonitor/datasource.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
],
"public/app/plugins/datasource/azuremonitor/log_analytics/querystring_builder.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
[0, 0, 0, "Unexpected any. Specify a different type.", "2"],
[0, 0, 0, "Unexpected any. Specify a different type.", "3"],
[0, 0, 0, "Unexpected any. Specify a different type.", "4"],
[0, 0, 0, "Unexpected any. Specify a different type.", "5"]
],
"public/app/plugins/datasource/azuremonitor/time_grain_converter.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
],
"public/app/plugins/datasource/azuremonitor/types/types.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
],
"public/app/plugins/datasource/azuremonitor/utils/common.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
],
"public/app/plugins/datasource/azuremonitor/utils/messageFromError.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
],
"public/app/plugins/datasource/azuremonitor/utils/useAsyncState.test.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
],
"public/app/plugins/datasource/cloud-monitoring/CloudMonitoringMetricFindQuery.ts:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"],
[0, 0, 0, "Do not use any type assertions.", "1"],
@ -5472,125 +5591,6 @@ exports[`better eslint`] = {
"public/app/plugins/datasource/elasticsearch/test-helpers/render.tsx:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"]
],
"public/app/plugins/datasource/grafana-azure-monitor-datasource/__mocks__/query_ctrl.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
[0, 0, 0, "Unexpected any. Specify a different type.", "2"],
[0, 0, 0, "Unexpected any. Specify a different type.", "3"],
[0, 0, 0, "Unexpected any. Specify a different type.", "4"]
],
"public/app/plugins/datasource/grafana-azure-monitor-datasource/azure_log_analytics/__mocks__/schema.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
],
"public/app/plugins/datasource/grafana-azure-monitor-datasource/azure_log_analytics/azure_log_analytics_datasource.test.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
[0, 0, 0, "Unexpected any. Specify a different type.", "2"],
[0, 0, 0, "Unexpected any. Specify a different type.", "3"]
],
"public/app/plugins/datasource/grafana-azure-monitor-datasource/azure_log_analytics/azure_log_analytics_datasource.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
[0, 0, 0, "Unexpected any. Specify a different type.", "2"],
[0, 0, 0, "Unexpected any. Specify a different type.", "3"],
[0, 0, 0, "Unexpected any. Specify a different type.", "4"],
[0, 0, 0, "Unexpected any. Specify a different type.", "5"],
[0, 0, 0, "Unexpected any. Specify a different type.", "6"],
[0, 0, 0, "Unexpected any. Specify a different type.", "7"],
[0, 0, 0, "Unexpected any. Specify a different type.", "8"],
[0, 0, 0, "Unexpected any. Specify a different type.", "9"]
],
"public/app/plugins/datasource/grafana-azure-monitor-datasource/azure_log_analytics/response_parser.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
[0, 0, 0, "Unexpected any. Specify a different type.", "2"],
[0, 0, 0, "Unexpected any. Specify a different type.", "3"],
[0, 0, 0, "Unexpected any. Specify a different type.", "4"],
[0, 0, 0, "Unexpected any. Specify a different type.", "5"],
[0, 0, 0, "Unexpected any. Specify a different type.", "6"],
[0, 0, 0, "Unexpected any. Specify a different type.", "7"],
[0, 0, 0, "Unexpected any. Specify a different type.", "8"],
[0, 0, 0, "Do not use any type assertions.", "9"],
[0, 0, 0, "Unexpected any. Specify a different type.", "10"],
[0, 0, 0, "Unexpected any. Specify a different type.", "11"],
[0, 0, 0, "Unexpected any. Specify a different type.", "12"],
[0, 0, 0, "Unexpected any. Specify a different type.", "13"],
[0, 0, 0, "Unexpected any. Specify a different type.", "14"]
],
"public/app/plugins/datasource/grafana-azure-monitor-datasource/azure_monitor/azure_monitor_datasource.test.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
[0, 0, 0, "Unexpected any. Specify a different type.", "2"]
],
"public/app/plugins/datasource/grafana-azure-monitor-datasource/azure_monitor/azure_monitor_datasource.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
[0, 0, 0, "Do not use any type assertions.", "2"]
],
"public/app/plugins/datasource/grafana-azure-monitor-datasource/azure_monitor/response_parser.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
[0, 0, 0, "Unexpected any. Specify a different type.", "2"],
[0, 0, 0, "Unexpected any. Specify a different type.", "3"],
[0, 0, 0, "Unexpected any. Specify a different type.", "4"]
],
"public/app/plugins/datasource/grafana-azure-monitor-datasource/azure_resource_graph/azure_resource_graph_datasource.test.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
],
"public/app/plugins/datasource/grafana-azure-monitor-datasource/azure_resource_graph/azure_resource_graph_datasource.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
],
"public/app/plugins/datasource/grafana-azure-monitor-datasource/components/LogsQueryEditor/QueryField.tsx:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
[0, 0, 0, "Do not use any type assertions.", "2"],
[0, 0, 0, "Do not use any type assertions.", "3"]
],
"public/app/plugins/datasource/grafana-azure-monitor-datasource/components/MetricsQueryEditor/dataHooks.test.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
[0, 0, 0, "Unexpected any. Specify a different type.", "2"],
[0, 0, 0, "Unexpected any. Specify a different type.", "3"]
],
"public/app/plugins/datasource/grafana-azure-monitor-datasource/components/MonitorConfig.tsx:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"]
],
"public/app/plugins/datasource/grafana-azure-monitor-datasource/components/QueryEditor/QueryEditor.tsx:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"]
],
"public/app/plugins/datasource/grafana-azure-monitor-datasource/components/ResourcePicker/ResourcePicker.test.tsx:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
],
"public/app/plugins/datasource/grafana-azure-monitor-datasource/datasource.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
],
"public/app/plugins/datasource/grafana-azure-monitor-datasource/log_analytics/querystring_builder.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
[0, 0, 0, "Unexpected any. Specify a different type.", "2"],
[0, 0, 0, "Unexpected any. Specify a different type.", "3"],
[0, 0, 0, "Unexpected any. Specify a different type.", "4"],
[0, 0, 0, "Unexpected any. Specify a different type.", "5"]
],
"public/app/plugins/datasource/grafana-azure-monitor-datasource/time_grain_converter.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
],
"public/app/plugins/datasource/grafana-azure-monitor-datasource/types/types.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
],
"public/app/plugins/datasource/grafana-azure-monitor-datasource/utils/common.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
],
"public/app/plugins/datasource/grafana-azure-monitor-datasource/utils/messageFromError.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
],
"public/app/plugins/datasource/grafana-azure-monitor-datasource/utils/useAsyncState.test.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
],
"public/app/plugins/datasource/grafana/components/AnnotationQueryEditor.tsx:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"]
],

View File

@ -680,7 +680,7 @@ steps:
paths:
include:
- pkg/tsdb/azuremonitor/**
- public/app/plugins/datasource/grafana-azure-monitor-datasource/**
- public/app/plugins/datasource/azuremonitor/**
- e2e/cloud-plugins-suite/azure-monitor.spec.ts
repo:
- grafana/grafana
@ -1558,7 +1558,7 @@ steps:
paths:
include:
- pkg/tsdb/azuremonitor/**
- public/app/plugins/datasource/grafana-azure-monitor-datasource/**
- public/app/plugins/datasource/azuremonitor/**
- e2e/cloud-plugins-suite/azure-monitor.spec.ts
repo:
- grafana/grafana
@ -6656,6 +6656,6 @@ kind: secret
name: aws_secret_access_key
---
kind: signature
hmac: 3e72bf092e103764489c02760188a3529c06c2e91ea34fa234794491f274a5a0
hmac: 9fb8fede2b16c30dd646d16f157f8647de8ef9faddcb1eb071d02ec8405ad586
...

2
.github/CODEOWNERS vendored
View File

@ -490,7 +490,7 @@ lerna.json @grafana/frontend-ops
/public/app/plugins/datasource/elasticsearch/ @grafana/observability-logs
/public/app/plugins/datasource/grafana/ @grafana/user-essentials
/public/app/plugins/datasource/testdata/ @grafana/plugins-platform-frontend
/public/app/plugins/datasource/grafana-azure-monitor-datasource/ @grafana/partner-plugins
/public/app/plugins/datasource/azuremonitor/ @grafana/partner-plugins
/public/app/plugins/datasource/graphite/ @grafana/observability-metrics
/public/app/plugins/datasource/influxdb/ @grafana/observability-metrics
/public/app/plugins/datasource/jaeger/ @grafana/observability-traces-and-profiling

View File

@ -83,7 +83,7 @@
},
{
"type": "changedfiles",
"matches": [ "public/app/plugins/datasource/grafana-azure-monitor-datasource/**/*", "pkg/tsdb/azuremonitor/**/*"],
"matches": [ "public/app/plugins/datasource/azuremonitor/**/*", "pkg/tsdb/azuremonitor/**/*"],
"action": "updateLabel",
"addLabel": "datasource/Azure"
},

View File

@ -5,7 +5,7 @@ on:
- 'pkg/tsdb/azuremonitor/**'
- 'pkg/tsdb/cloudwatch/**'
- 'pkg/tsdb/cloudmonitoring/**'
- 'public/app/plugins/datasource/grafana-azure-monitor-datasource/**'
- 'public/app/plugins/datasource/azuremonitor/**'
- 'public/app/plugins/datasource/cloudwatch/**'
- 'public/app/plugins/datasource/cloud-monitoring/**'
branches-ignore:
@ -16,5 +16,5 @@ jobs:
workflow-call:
uses: grafana/code-coverage/.github/workflows/code-coverage.yml@v0.1.17
with:
frontend-path-regexp: public\/app\/plugins\/datasource\/(grafana-azure-monitor-datasource|cloud-monitoring|cloudwatch)
frontend-path-regexp: public\/app\/plugins\/datasource\/(azuremonitor|cloud-monitoring|cloudwatch)
backend-path-regexp: pkg\/tsdb\/(azuremonitor|cloudmonitoring|cloudwatch)

View File

@ -0,0 +1,19 @@
---
keywords:
- grafana
- schema
title: AzureMonitorDataQuery kind
---
> Both documentation generation and kinds schemas are in active development and subject to change without prior notice.
## AzureMonitorDataQuery
#### Maturity: merged
#### Version: 0.0
| Property | Type | Required | Description |
|----------|------|----------|-------------|

View File

@ -3,12 +3,12 @@ import { v4 as uuidv4 } from 'uuid';
import { e2e } from '@grafana/e2e';
import { selectors } from '../../public/app/plugins/datasource/grafana-azure-monitor-datasource/e2e/selectors';
import { selectors } from '../../public/app/plugins/datasource/azuremonitor/e2e/selectors';
import {
AzureDataSourceJsonData,
AzureDataSourceSecureJsonData,
AzureQueryType,
} from '../../public/app/plugins/datasource/grafana-azure-monitor-datasource/types';
} from '../../public/app/plugins/datasource/azuremonitor/types';
const provisioningPath = `../../provisioning/datasources/azmonitor-ds.yaml`;
const e2eSelectors = e2e.getSelectors(selectors.components);

View File

@ -150,13 +150,13 @@
"grafanaMaturityCount": 0,
"lineageIsGroup": false,
"links": {
"docs": "n/a",
"go": "n/a",
"schema": "n/a",
"ts": "n/a"
"docs": "https://grafana.com/docs/grafana/next/developers/kinds/composable/azuremonitordataquery/schema-reference",
"go": "https://github.com/grafana/grafana/tree/main/pkg/tsdb/grafana-azure-monitor-datasource/kinds/dataquery/types_dataquery_gen.go",
"schema": "https://github.com/grafana/grafana/tree/main/public/app/plugins/datasource/grafana-azure-monitor-datasource/dataquery.cue",
"ts": "https://github.com/grafana/grafana/tree/main/public/app/plugins/datasource/grafana-azure-monitor-datasource/dataquery.gen.ts"
},
"machineName": "azuremonitordataquery",
"maturity": "planned",
"maturity": "merged",
"name": "AzureMonitorDataQuery",
"pluralMachineName": "azuremonitordataquerys",
"pluralName": "AzureMonitorDataQuerys",
@ -2010,6 +2010,7 @@
"name": "merged",
"items": [
"alertgroupspanelcfg",
"azuremonitordataquery",
"elasticsearchdataquery",
"playlist",
"preferences",
@ -2017,7 +2018,7 @@
"serviceaccount",
"team"
],
"count": 7
"count": 8
},
"planned": {
"name": "planned",
@ -2026,7 +2027,6 @@
"alertmanagerdataquery",
"alertmanagerdatasourcecfg",
"apikey",
"azuremonitordataquery",
"azuremonitordatasourcecfg",
"cloudwatchdataquery",
"cloudwatchdatasourcecfg",
@ -2074,7 +2074,7 @@
"zipkindataquery",
"zipkindatasourcecfg"
],
"count": 51
"count": 50
},
"stable": {
"name": "stable",

View File

@ -33,12 +33,12 @@ func parsePluginOrPanic(path string, pkgname string, rt *thema.Runtime) pfs.Pars
func corePlugins(rt *thema.Runtime) []pfs.ParsedPlugin {
return []pfs.ParsedPlugin{
parsePluginOrPanic("public/app/plugins/datasource/alertmanager", "alertmanager", rt),
parsePluginOrPanic("public/app/plugins/datasource/azuremonitor", "grafana_azure_monitor_datasource", rt),
parsePluginOrPanic("public/app/plugins/datasource/cloud-monitoring", "stackdriver", rt),
parsePluginOrPanic("public/app/plugins/datasource/cloudwatch", "cloudwatch", rt),
parsePluginOrPanic("public/app/plugins/datasource/dashboard", "dashboard", rt),
parsePluginOrPanic("public/app/plugins/datasource/elasticsearch", "elasticsearch", rt),
parsePluginOrPanic("public/app/plugins/datasource/grafana", "grafana", rt),
parsePluginOrPanic("public/app/plugins/datasource/grafana-azure-monitor-datasource", "grafana_azure_monitor_datasource", rt),
parsePluginOrPanic("public/app/plugins/datasource/graphite", "graphite", rt),
parsePluginOrPanic("public/app/plugins/datasource/jaeger", "jaeger", rt),
parsePluginOrPanic("public/app/plugins/datasource/loki", "loki", rt),

View File

@ -135,22 +135,22 @@
}
],
"logos": {
"small": "public/app/plugins/datasource/grafana-azure-monitor-datasource/img/logo.jpg",
"large": "public/app/plugins/datasource/grafana-azure-monitor-datasource/img/logo.jpg"
"small": "public/app/plugins/datasource/azuremonitor/img/logo.jpg",
"large": "public/app/plugins/datasource/azuremonitor/img/logo.jpg"
},
"build": {},
"screenshots": [
{
"name": "Azure Contoso Loans",
"path": "public/app/plugins/datasource/grafana-azure-monitor-datasource/img/contoso_loans_grafana_dashboard.png"
"path": "public/app/plugins/datasource/azuremonitor/img/contoso_loans_grafana_dashboard.png"
},
{
"name": "Azure Monitor Network",
"path": "public/app/plugins/datasource/grafana-azure-monitor-datasource/img/azure_monitor_network.png"
"path": "public/app/plugins/datasource/azuremonitor/img/azure_monitor_network.png"
},
{
"name": "Azure Monitor CPU",
"path": "public/app/plugins/datasource/grafana-azure-monitor-datasource/img/azure_monitor_cpu.png"
"path": "public/app/plugins/datasource/azuremonitor/img/azure_monitor_cpu.png"
}
],
"version": "1.0.0",

View File

@ -119,7 +119,7 @@ func (s *Service) handleResourceReq(subDataSource string) func(rw http.ResponseW
}
// newResourceMux provides route definitions shared with the frontend.
// Check: /public/app/plugins/datasource/grafana-azure-monitor-datasource/utils/common.ts <routeNames>
// Check: /public/app/plugins/datasource/azuremonitor/utils/common.ts <routeNames>
func (s *Service) newResourceMux() *http.ServeMux {
mux := http.NewServeMux()
mux.HandleFunc("/azuremonitor/", s.handleResourceReq(azureMonitor))

View File

@ -0,0 +1,450 @@
// Code generated - EDITING IS FUTILE. DO NOT EDIT.
//
// Generated by:
// public/app/plugins/gen.go
// Using jennies:
// PluginGoTypesJenny
//
// Run 'make gen-cue' from repository root to regenerate.
package dataquery
// Defines values for AppInsightsGroupByQueryKind.
const (
AppInsightsGroupByQueryKindAppInsightsGroupByQuery AppInsightsGroupByQueryKind = "AppInsightsGroupByQuery"
)
// Defines values for AppInsightsMetricNameQueryKind.
const (
AppInsightsMetricNameQueryKindAppInsightsMetricNameQuery AppInsightsMetricNameQueryKind = "AppInsightsMetricNameQuery"
)
// Defines values for AzureLogsQueryResultFormat.
const (
AzureLogsQueryResultFormatTable AzureLogsQueryResultFormat = "table"
AzureLogsQueryResultFormatTimeSeries AzureLogsQueryResultFormat = "time_series"
)
// Defines values for AzureMonitorQueryAzureLogAnalyticsResultFormat.
const (
AzureMonitorQueryAzureLogAnalyticsResultFormatTable AzureMonitorQueryAzureLogAnalyticsResultFormat = "table"
AzureMonitorQueryAzureLogAnalyticsResultFormatTimeSeries AzureMonitorQueryAzureLogAnalyticsResultFormat = "time_series"
)
// Defines values for AzureQueryType.
const (
AzureQueryTypeAzureLogAnalytics AzureQueryType = "Azure Log Analytics"
AzureQueryTypeAzureMetricNames AzureQueryType = "Azure Metric Names"
AzureQueryTypeAzureMonitor AzureQueryType = "Azure Monitor"
AzureQueryTypeAzureNamespaces AzureQueryType = "Azure Namespaces"
AzureQueryTypeAzureRegions AzureQueryType = "Azure Regions"
AzureQueryTypeAzureResourceGraph AzureQueryType = "Azure Resource Graph"
AzureQueryTypeAzureResourceGroups AzureQueryType = "Azure Resource Groups"
AzureQueryTypeAzureResourceNames AzureQueryType = "Azure Resource Names"
AzureQueryTypeAzureSubscriptions AzureQueryType = "Azure Subscriptions"
AzureQueryTypeAzureWorkspaces AzureQueryType = "Azure Workspaces"
AzureQueryTypeGrafanaTemplateVariableFunction AzureQueryType = "Grafana Template Variable Function"
)
// Defines values for GrafanaTemplateVariableQueryType.
const (
GrafanaTemplateVariableQueryTypeAppInsightsGroupByQuery GrafanaTemplateVariableQueryType = "AppInsightsGroupByQuery"
GrafanaTemplateVariableQueryTypeAppInsightsMetricNameQuery GrafanaTemplateVariableQueryType = "AppInsightsMetricNameQuery"
GrafanaTemplateVariableQueryTypeMetricNamesQuery GrafanaTemplateVariableQueryType = "MetricNamesQuery"
GrafanaTemplateVariableQueryTypeMetricNamespaceQuery GrafanaTemplateVariableQueryType = "MetricNamespaceQuery"
GrafanaTemplateVariableQueryTypeResourceGroupsQuery GrafanaTemplateVariableQueryType = "ResourceGroupsQuery"
GrafanaTemplateVariableQueryTypeResourceNamesQuery GrafanaTemplateVariableQueryType = "ResourceNamesQuery"
GrafanaTemplateVariableQueryTypeSubscriptionsQuery GrafanaTemplateVariableQueryType = "SubscriptionsQuery"
GrafanaTemplateVariableQueryTypeUnknownQuery GrafanaTemplateVariableQueryType = "UnknownQuery"
GrafanaTemplateVariableQueryTypeWorkspacesQuery GrafanaTemplateVariableQueryType = "WorkspacesQuery"
)
// Defines values for MetricDefinitionsQueryKind.
const (
MetricDefinitionsQueryKindMetricDefinitionsQuery MetricDefinitionsQueryKind = "MetricDefinitionsQuery"
)
// Defines values for MetricNamesQueryKind.
const (
MetricNamesQueryKindMetricNamesQuery MetricNamesQueryKind = "MetricNamesQuery"
)
// Defines values for MetricNamespaceQueryKind.
const (
MetricNamespaceQueryKindMetricNamespaceQuery MetricNamespaceQueryKind = "MetricNamespaceQuery"
)
// Defines values for ResourceGroupsQueryKind.
const (
ResourceGroupsQueryKindResourceGroupsQuery ResourceGroupsQueryKind = "ResourceGroupsQuery"
)
// Defines values for ResourceNamesQueryKind.
const (
ResourceNamesQueryKindResourceNamesQuery ResourceNamesQueryKind = "ResourceNamesQuery"
)
// Defines values for ResultFormat.
const (
ResultFormatTable ResultFormat = "table"
ResultFormatTimeSeries ResultFormat = "time_series"
)
// Defines values for SubscriptionsQueryKind.
const (
SubscriptionsQueryKindSubscriptionsQuery SubscriptionsQueryKind = "SubscriptionsQuery"
)
// Defines values for UnknownQueryKind.
const (
UnknownQueryKindUnknownQuery UnknownQueryKind = "UnknownQuery"
)
// Defines values for WorkspacesQueryKind.
const (
WorkspacesQueryKindWorkspacesQuery WorkspacesQueryKind = "WorkspacesQuery"
)
// AppInsightsGroupByQueryKind defines model for AppInsightsGroupByQuery.Kind.
type AppInsightsGroupByQueryKind string
// AppInsightsMetricNameQueryKind defines model for AppInsightsMetricNameQuery.Kind.
type AppInsightsMetricNameQueryKind string
// Azure Monitor Logs sub-query properties
type AzureLogsQuery struct {
// KQL query to be executed.
Query *string `json:"query,omitempty"`
// @deprecated Use resources instead
Resource *string `json:"resource,omitempty"`
// Array of resource URIs to be queried.
Resources *[]string `json:"resources,omitempty"`
// Specifies the format results should be returned as.
ResultFormat *AzureLogsQueryResultFormat `json:"resultFormat,omitempty"`
// Workspace ID. This was removed in Grafana 8, but remains for backwards compat
Workspace *string `json:"workspace,omitempty"`
}
// Specifies the format results should be returned as.
type AzureLogsQueryResultFormat string
// AzureMetricDimension defines model for AzureMetricDimension.
type AzureMetricDimension struct {
// Name of Dimension to be filtered on.
Dimension *string `json:"dimension,omitempty"`
// @deprecated filter is deprecated in favour of filters to support multiselect.
Filter *string `json:"filter,omitempty"`
// Values to match with the filter.
Filters *[]string `json:"filters,omitempty"`
// String denoting the filter operation. Supports 'eq' - equals,'ne' - not equals, 'sw' - starts with. Note that some dimensions may not support all operators.
Operator *string `json:"operator,omitempty"`
}
// AzureMetricQuery defines model for AzureMetricQuery.
type AzureMetricQuery struct {
// The aggregation to be used within the query. Defaults to the primaryAggregationType defined by the metric.
Aggregation *string `json:"aggregation,omitempty"`
// Aliases can be set to modify the legend labels. e.g. {{ resourceGroup }}. See docs for more detail.
Alias *string `json:"alias,omitempty"`
// Time grains that are supported by the metric.
AllowedTimeGrainsMs *[]int64 `json:"allowedTimeGrainsMs,omitempty"`
// Used as the value for the metricNamespace property when it's different from the resource namespace.
CustomNamespace *string `json:"customNamespace,omitempty"`
// @deprecated This property was migrated to dimensionFilters and should only be accessed in the migration
Dimension *string `json:"dimension,omitempty"`
// @deprecated This property was migrated to dimensionFilters and should only be accessed in the migration
DimensionFilter *string `json:"dimensionFilter,omitempty"`
// Filters to reduce the set of data returned. Dimensions that can be filtered on are defined by the metric.
DimensionFilters *[]struct {
// Name of Dimension to be filtered on.
Dimension *string `json:"dimension,omitempty"`
// @deprecated filter is deprecated in favour of filters to support multiselect.
Filter *string `json:"filter,omitempty"`
// Values to match with the filter.
Filters *[]string `json:"filters,omitempty"`
// String denoting the filter operation. Supports 'eq' - equals,'ne' - not equals, 'sw' - starts with. Note that some dimensions may not support all operators.
Operator *string `json:"operator,omitempty"`
} `json:"dimensionFilters,omitempty"`
// @deprecated Use metricNamespace instead
MetricDefinition *string `json:"metricDefinition,omitempty"`
// The metric to query data for within the specified metricNamespace. e.g. UsedCapacity
MetricName *string `json:"metricName,omitempty"`
// metricNamespace is used as the resource type (or resource namespace).
// It's usually equal to the target metric namespace. e.g. microsoft.storage/storageaccounts
// Kept the name of the variable as metricNamespace to avoid backward incompatibility issues.
MetricNamespace *string `json:"metricNamespace,omitempty"`
// The Azure region containing the resource(s).
Region *string `json:"region,omitempty"`
// @deprecated Use resources instead
ResourceGroup *string `json:"resourceGroup,omitempty"`
// @deprecated Use resources instead
ResourceName *string `json:"resourceName,omitempty"`
// @deprecated Use resourceGroup, resourceName and metricNamespace instead
ResourceUri *string `json:"resourceUri,omitempty"`
// Array of resource URIs to be queried.
Resources *[]struct {
MetricNamespace *string `json:"metricNamespace,omitempty"`
Region *string `json:"region,omitempty"`
ResourceGroup *string `json:"resourceGroup,omitempty"`
ResourceName *string `json:"resourceName,omitempty"`
Subscription *string `json:"subscription,omitempty"`
} `json:"resources,omitempty"`
// The granularity of data points to be queried. Defaults to auto.
TimeGrain *string `json:"timeGrain,omitempty"`
// @deprecated
TimeGrainUnit *string `json:"timeGrainUnit,omitempty"`
// Maximum number of records to return. Defaults to 10.
Top *string `json:"top,omitempty"`
}
// AzureMonitorDataQuery defines model for AzureMonitorDataQuery.
type AzureMonitorDataQuery map[string]interface{}
// AzureMonitorQuery defines model for AzureMonitorQuery.
type AzureMonitorQuery struct {
// Azure Monitor Logs sub-query properties.
AzureLogAnalytics *struct {
// KQL query to be executed.
Query *string `json:"query,omitempty"`
// @deprecated Use resources instead
Resource *string `json:"resource,omitempty"`
// Array of resource URIs to be queried.
Resources *[]string `json:"resources,omitempty"`
// Specifies the format results should be returned as.
ResultFormat *AzureMonitorQueryAzureLogAnalyticsResultFormat `json:"resultFormat,omitempty"`
// Workspace ID. This was removed in Grafana 8, but remains for backwards compat
Workspace *string `json:"workspace,omitempty"`
} `json:"azureLogAnalytics,omitempty"`
// Azure Monitor Metrics sub-query properties.
AzureMonitor *struct {
// The aggregation to be used within the query. Defaults to the primaryAggregationType defined by the metric.
Aggregation *string `json:"aggregation,omitempty"`
// Aliases can be set to modify the legend labels. e.g. {{ resourceGroup }}. See docs for more detail.
Alias *string `json:"alias,omitempty"`
// Time grains that are supported by the metric.
AllowedTimeGrainsMs *[]int64 `json:"allowedTimeGrainsMs,omitempty"`
// Used as the value for the metricNamespace property when it's different from the resource namespace.
CustomNamespace *string `json:"customNamespace,omitempty"`
// @deprecated This property was migrated to dimensionFilters and should only be accessed in the migration
Dimension *string `json:"dimension,omitempty"`
// @deprecated This property was migrated to dimensionFilters and should only be accessed in the migration
DimensionFilter *string `json:"dimensionFilter,omitempty"`
// Filters to reduce the set of data returned. Dimensions that can be filtered on are defined by the metric.
DimensionFilters *[]struct {
// Name of Dimension to be filtered on.
Dimension *string `json:"dimension,omitempty"`
// @deprecated filter is deprecated in favour of filters to support multiselect.
Filter *string `json:"filter,omitempty"`
// Values to match with the filter.
Filters *[]string `json:"filters,omitempty"`
// String denoting the filter operation. Supports 'eq' - equals,'ne' - not equals, 'sw' - starts with. Note that some dimensions may not support all operators.
Operator *string `json:"operator,omitempty"`
} `json:"dimensionFilters,omitempty"`
// @deprecated Use metricNamespace instead
MetricDefinition *string `json:"metricDefinition,omitempty"`
// The metric to query data for within the specified metricNamespace. e.g. UsedCapacity
MetricName *string `json:"metricName,omitempty"`
// metricNamespace is used as the resource type (or resource namespace).
// It's usually equal to the target metric namespace. e.g. microsoft.storage/storageaccounts
// Kept the name of the variable as metricNamespace to avoid backward incompatibility issues.
MetricNamespace *string `json:"metricNamespace,omitempty"`
// The Azure region containing the resource(s).
Region *string `json:"region,omitempty"`
// @deprecated Use resources instead
ResourceGroup *string `json:"resourceGroup,omitempty"`
// @deprecated Use resources instead
ResourceName *string `json:"resourceName,omitempty"`
// @deprecated Use resourceGroup, resourceName and metricNamespace instead
ResourceUri *string `json:"resourceUri,omitempty"`
// Array of resource URIs to be queried.
Resources *[]struct {
MetricNamespace *string `json:"metricNamespace,omitempty"`
Region *string `json:"region,omitempty"`
ResourceGroup *string `json:"resourceGroup,omitempty"`
ResourceName *string `json:"resourceName,omitempty"`
Subscription *string `json:"subscription,omitempty"`
} `json:"resources,omitempty"`
// The granularity of data points to be queried. Defaults to auto.
TimeGrain *string `json:"timeGrain,omitempty"`
// @deprecated
TimeGrainUnit *string `json:"timeGrainUnit,omitempty"`
// Maximum number of records to return. Defaults to 10.
Top *string `json:"top,omitempty"`
} `json:"azureMonitor,omitempty"`
// Azure Resource Graph sub-query properties.
AzureResourceGraph *struct {
// Azure Resource Graph KQL query to be executed.
Query *string `json:"query,omitempty"`
// Specifies the format results should be returned as. Defaults to table.
ResultFormat *string `json:"resultFormat,omitempty"`
} `json:"azureResourceGraph,omitempty"`
// For mixed data sources the selected datasource is on the query level.
// For non mixed scenarios this is undefined.
// TODO find a better way to do this ^ that's friendly to schema
// TODO this shouldn't be unknown but DataSourceRef | null
Datasource *interface{} `json:"datasource,omitempty"`
// @deprecated Legacy template variable support.
GrafanaTemplateVariableFn *interface{} `json:"grafanaTemplateVariableFn,omitempty"`
// true if query is disabled (ie should not be returned to the dashboard)
Hide *bool `json:"hide,omitempty"`
// Unique, guid like, string used in explore mode
Key *string `json:"key,omitempty"`
Namespace *string `json:"namespace,omitempty"`
// Specify the query flavor
// TODO make this required and give it a default
QueryType *string `json:"queryType,omitempty"`
// A - Z
RefId string `json:"refId"`
// Azure Monitor query type.
// queryType: #AzureQueryType
Region *string `json:"region,omitempty"`
Resource *string `json:"resource,omitempty"`
// Template variables params. These exist for backwards compatiblity with legacy template variables.
ResourceGroup *string `json:"resourceGroup,omitempty"`
// Azure subscription containing the resource(s) to be queried.
Subscription *string `json:"subscription,omitempty"`
// Subscriptions to be queried via Azure Resource Graph.
Subscriptions *[]string `json:"subscriptions,omitempty"`
}
// Specifies the format results should be returned as.
type AzureMonitorQueryAzureLogAnalyticsResultFormat string
// AzureMonitorResource defines model for AzureMonitorResource.
type AzureMonitorResource struct {
MetricNamespace *string `json:"metricNamespace,omitempty"`
Region *string `json:"region,omitempty"`
ResourceGroup *string `json:"resourceGroup,omitempty"`
ResourceName *string `json:"resourceName,omitempty"`
Subscription *string `json:"subscription,omitempty"`
}
// Defines the supported queryTypes. GrafanaTemplateVariableFn is deprecated
type AzureQueryType string
// AzureResourceGraphQuery defines model for AzureResourceGraphQuery.
type AzureResourceGraphQuery struct {
// Azure Resource Graph KQL query to be executed.
Query *string `json:"query,omitempty"`
// Specifies the format results should be returned as. Defaults to table.
ResultFormat *string `json:"resultFormat,omitempty"`
}
// GrafanaTemplateVariableQuery defines model for GrafanaTemplateVariableQuery.
type GrafanaTemplateVariableQuery interface{}
// GrafanaTemplateVariableQueryType defines model for GrafanaTemplateVariableQueryType.
type GrafanaTemplateVariableQueryType string
// MetricDefinitionsQueryKind defines model for MetricDefinitionsQuery.Kind.
type MetricDefinitionsQueryKind string
// MetricNamesQueryKind defines model for MetricNamesQuery.Kind.
type MetricNamesQueryKind string
// MetricNamespaceQueryKind defines model for MetricNamespaceQuery.Kind.
type MetricNamespaceQueryKind string
// ResourceGroupsQueryKind defines model for ResourceGroupsQuery.Kind.
type ResourceGroupsQueryKind string
// ResourceNamesQueryKind defines model for ResourceNamesQuery.Kind.
type ResourceNamesQueryKind string
// ResultFormat defines model for ResultFormat.
type ResultFormat string
// SubscriptionsQueryKind defines model for SubscriptionsQuery.Kind.
type SubscriptionsQueryKind string
// UnknownQueryKind defines model for UnknownQuery.Kind.
type UnknownQueryKind string
// WorkspacesQueryKind defines model for WorkspacesQuery.Kind.
type WorkspacesQueryKind string

View File

@ -32,9 +32,7 @@ const testDataDSPlugin = async () =>
const cloudMonitoringPlugin = async () =>
await import(/* webpackChunkName: "cloudMonitoringPlugin" */ 'app/plugins/datasource/cloud-monitoring/module');
const azureMonitorPlugin = async () =>
await import(
/* webpackChunkName: "azureMonitorPlugin" */ 'app/plugins/datasource/grafana-azure-monitor-datasource/module'
);
await import(/* webpackChunkName: "azureMonitorPlugin" */ 'app/plugins/datasource/azuremonitor/module');
const tempoPlugin = async () =>
await import(/* webpackChunkName: "tempoPlugin" */ 'app/plugins/datasource/tempo/module');
const alertmanagerPlugin = async () =>
@ -100,7 +98,7 @@ const builtInPlugins: any = {
'app/plugins/datasource/prometheus/module': prometheusPlugin,
'app/plugins/datasource/testdata/module': testDataDSPlugin,
'app/plugins/datasource/cloud-monitoring/module': cloudMonitoringPlugin,
'app/plugins/datasource/grafana-azure-monitor-datasource/module': azureMonitorPlugin,
'app/plugins/datasource/azuremonitor/module': azureMonitorPlugin,
'app/plugins/datasource/tempo/module': tempoPlugin,
'app/plugins/datasource/alertmanager/module': alertmanagerPlugin,
'app/plugins/datasource/phlare/module': phlarePlugin,

View File

@ -1,4 +1,4 @@
import { AzureMonitorQuery, AzureQueryType } from '../types';
import { AzureMonitorQuery, AzureQueryType, ResultFormat } from '../types';
export default function createMockQuery(overrides?: Partial<AzureMonitorQuery>): AzureMonitorQuery {
return {
@ -15,7 +15,7 @@ export default function createMockQuery(overrides?: Partial<AzureMonitorQuery>):
azureLogAnalytics: {
query:
'//change this example to create your own time series query\n<table name> //the table to query (e.g. Usage, Heartbeat, Perf)\n| where $__timeFilter(TimeGenerated) //this is a macro used to show the full charts time range, choose the datetime column here\n| summarize count() by <group by column>, bin(TimeGenerated, $__interval) //change “group by column” to a column in your table, such as “Computer”. The $__interval macro is used to auto-select the time grain. Can also use 1h, 5m etc.\n| order by TimeGenerated asc',
resultFormat: 'time_series',
resultFormat: ResultFormat.Table,
workspace: 'e3fe4fde-ad5e-4d60-9974-e2f3562ffdf2',
resources: ['test-resource'],
...overrides?.azureLogAnalytics,

View File

@ -1,9 +1,9 @@
import { TemplateSrv } from '@grafana/runtime';
import { AzureMetricResource, GetMetricNamespacesQuery, GetMetricNamesQuery } from '../types';
import { AzureMonitorResource, GetMetricNamespacesQuery, GetMetricNamesQuery } from '../types';
export default class UrlBuilder {
static buildResourceUri(templateSrv: TemplateSrv, resource: AzureMetricResource) {
static buildResourceUri(templateSrv: TemplateSrv, resource: AzureMonitorResource) {
const urlArray = [];
const { subscription, resourceGroup, metricNamespace, resourceName } = resource;

View File

@ -4,21 +4,21 @@ import { SelectableValue } from '@grafana/data';
import { Select } from '@grafana/ui';
import { selectors } from '../../e2e/selectors';
import { AzureQueryEditorFieldProps } from '../../types';
import { AzureQueryEditorFieldProps, ResultFormat } from '../../types';
import { Field } from '../Field';
import { setFormatAs } from './setQueryValue';
const FORMAT_OPTIONS: Array<SelectableValue<string>> = [
{ label: 'Time series', value: 'time_series' },
{ label: 'Table', value: 'table' },
const FORMAT_OPTIONS: Array<SelectableValue<ResultFormat>> = [
{ label: 'Time series', value: ResultFormat.TimeSeries },
{ label: 'Table', value: ResultFormat.Table },
];
const FormatAsField: React.FC<AzureQueryEditorFieldProps> = ({ query, variableOptionGroup, onQueryChange }) => {
const options = useMemo(() => [...FORMAT_OPTIONS, variableOptionGroup], [variableOptionGroup]);
const handleChange = useCallback(
(change: SelectableValue<string>) => {
(change: SelectableValue<ResultFormat>) => {
const { value } = change;
if (!value) {
return;

View File

@ -73,7 +73,7 @@ const LogsQueryEditor: React.FC<LogsQueryEditorProps> = ({
disableRow={disableRow}
renderAdvanced={(resources, onChange) => (
// It's required to cast resources because the resource picker
// specifies the type to string | AzureMetricResource.
// specifies the type to string | AzureMonitorResource.
// eslint-disable-next-line
<AdvancedResourcePicker resources={resources as string[]} onChange={onChange} />
)}

View File

@ -1,4 +1,4 @@
import { AzureMonitorQuery } from '../../types';
import { AzureMonitorQuery, ResultFormat } from '../../types';
export function setKustoQuery(query: AzureMonitorQuery, kustoQuery: string): AzureMonitorQuery {
return {
@ -10,7 +10,7 @@ export function setKustoQuery(query: AzureMonitorQuery, kustoQuery: string): Azu
};
}
export function setFormatAs(query: AzureMonitorQuery, formatAs: string): AzureMonitorQuery {
export function setFormatAs(query: AzureMonitorQuery, formatAs: ResultFormat): AzureMonitorQuery {
return {
...query,
azureLogAnalytics: {

View File

@ -6,7 +6,7 @@ import { AccessoryButton } from '@grafana/experimental';
import { Input, Label, InlineField, Button, useStyles2 } from '@grafana/ui';
import { selectors } from '../../e2e/selectors';
import { AzureMetricResource } from '../../types';
import { AzureMonitorResource } from '../../types';
export interface ResourcePickerProps<T> {
resources: T[];
@ -20,7 +20,7 @@ const getStyles = (theme: GrafanaTheme2) => ({
resourceGroupAndName: css({ display: 'flex', columnGap: theme.spacing(0.5) }),
});
const AdvancedResourcePicker = ({ resources, onChange }: ResourcePickerProps<AzureMetricResource>) => {
const AdvancedResourcePicker = ({ resources, onChange }: ResourcePickerProps<AzureMonitorResource>) => {
const styles = useStyles2(getStyles);
useEffect(() => {
@ -30,7 +30,7 @@ const AdvancedResourcePicker = ({ resources, onChange }: ResourcePickerProps<Azu
}
}, [resources, onChange]);
const onResourceChange = (index: number, resource: AzureMetricResource) => {
const onResourceChange = (index: number, resource: AzureMonitorResource) => {
const newResources = [...resources];
newResources[index] = resource;
onChange(newResources);
@ -53,7 +53,7 @@ const AdvancedResourcePicker = ({ resources, onChange }: ResourcePickerProps<Azu
);
};
const onCommonPropChange = (r: Partial<AzureMetricResource>) => {
const onCommonPropChange = (r: Partial<AzureMonitorResource>) => {
onChange(resources.map((resource) => ({ ...resource, ...r })));
};

View File

@ -5,7 +5,7 @@ import { EditorRows, EditorRow, EditorFieldGroup } from '@grafana/experimental';
import { multiResourceCompatibleTypes } from '../../azureMetadata';
import type Datasource from '../../datasource';
import type { AzureMonitorQuery, AzureMonitorOption, AzureMonitorErrorish, AzureMetricResource } from '../../types';
import type { AzureMonitorQuery, AzureMonitorOption, AzureMonitorErrorish, AzureMonitorResource } from '../../types';
import ResourceField from '../ResourceField';
import { ResourceRow, ResourceRowGroup, ResourceRowType } from '../ResourcePicker/types';
import { parseResourceDetails } from '../ResourcePicker/utils';
@ -101,9 +101,9 @@ const MetricsQueryEditor: React.FC<MetricsQueryEditorProps> = ({
disableRow={disableRow}
renderAdvanced={(resources, onChange) => (
// It's required to cast resources because the resource picker
// specifies the type to string | AzureMetricResource.
// specifies the type to string | AzureMonitorResource.
// eslint-disable-next-line
<AdvancedResourcePicker resources={resources as AzureMetricResource[]} onChange={onChange} />
<AdvancedResourcePicker resources={resources as AzureMonitorResource[]} onChange={onChange} />
)}
selectionNotice={selectionNotice}
/>

View File

@ -6,7 +6,7 @@ import { Button, Icon, Modal, useStyles2, IconName } from '@grafana/ui';
import Datasource from '../../datasource';
import { selectors } from '../../e2e/selectors';
import { ResourcePickerQueryType } from '../../resourcePicker/resourcePickerData';
import { AzureQueryEditorFieldProps, AzureMetricResource } from '../../types';
import { AzureQueryEditorFieldProps, AzureMonitorResource } from '../../types';
import { Field } from '../Field';
import ResourcePicker from '../ResourcePicker';
import getStyles from '../ResourcePicker/styles';
@ -24,7 +24,7 @@ interface ResourceFieldProps<T> extends AzureQueryEditorFieldProps {
selectionNotice?: (selectedRows: ResourceRowGroup) => string;
}
const ResourceField: React.FC<ResourceFieldProps<string | AzureMetricResource>> = ({
const ResourceField: React.FC<ResourceFieldProps<string | AzureMonitorResource>> = ({
query,
datasource,
onQueryChange,
@ -49,7 +49,7 @@ const ResourceField: React.FC<ResourceFieldProps<string | AzureMetricResource>>
}, []);
const handleApply = useCallback(
(resources: Array<string | AzureMetricResource>) => {
(resources: Array<string | AzureMonitorResource>) => {
onQueryChange(setResources(query, queryType, resources));
closePicker();
},
@ -93,7 +93,7 @@ interface ResourceLabelProps<T> {
datasource: Datasource;
}
const ResourceLabel = ({ resources, datasource }: ResourceLabelProps<string | AzureMetricResource>) => {
const ResourceLabel = ({ resources, datasource }: ResourceLabelProps<string | AzureMonitorResource>) => {
const [resourcesComponents, setResourcesComponents] = useState(parseMultipleResourceDetails(resources));
useEffect(() => {
@ -108,7 +108,7 @@ const ResourceLabel = ({ resources, datasource }: ResourceLabelProps<string | Az
};
interface FormattedResourceProps {
resources: AzureMetricResource[];
resources: AzureMonitorResource[];
}
const FormattedResource = ({ resources }: FormattedResourceProps) => {

View File

@ -3,7 +3,7 @@ import React, { useState } from 'react';
import { Collapse } from '@grafana/ui';
import { selectors } from '../../e2e/selectors';
import { AzureMetricResource } from '../../types';
import { AzureMonitorResource } from '../../types';
import { Space } from '../Space';
export interface ResourcePickerProps<T> {
@ -12,7 +12,7 @@ export interface ResourcePickerProps<T> {
renderAdvanced: (resources: T[], onChange: (resources: T[]) => void) => React.ReactNode;
}
const AdvancedMulti = ({ resources, onChange, renderAdvanced }: ResourcePickerProps<string | AzureMetricResource>) => {
const AdvancedMulti = ({ resources, onChange, renderAdvanced }: ResourcePickerProps<string | AzureMonitorResource>) => {
const [isAdvancedOpen, setIsAdvancedOpen] = useState(!!resources.length && JSON.stringify(resources).includes('$'));
return (

View File

@ -6,7 +6,7 @@ import { Alert, Button, LoadingPlaceholder, useStyles2 } from '@grafana/ui';
import { selectors } from '../../e2e/selectors';
import ResourcePickerData, { ResourcePickerQueryType } from '../../resourcePicker/resourcePickerData';
import { AzureMetricResource } from '../../types';
import { AzureMonitorResource } from '../../types';
import messageFromError from '../../utils/messageFromError';
import { Space } from '../Space';
@ -40,7 +40,7 @@ const ResourcePicker = ({
disableRow,
renderAdvanced,
selectionNotice,
}: ResourcePickerProps<string | AzureMetricResource>) => {
}: ResourcePickerProps<string | AzureMonitorResource>) => {
const styles = useStyles2(getStyles);
const [isLoading, setIsLoading] = useState(false);
@ -77,7 +77,7 @@ const ResourcePicker = ({
});
// Avoid using empty resources
const isValid = (r: string | AzureMetricResource) =>
const isValid = (r: string | AzureMonitorResource) =>
typeof r === 'string' ? r !== '' : r.subscription && r.resourceGroup && r.resourceName && r.metricNamespace;
// set selected row data whenever row or selection changes

Some files were not shown because too many files have changed in this diff Show More