mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
* Build out barebones Traces editor - Add Traces query type and operation ID prop to query type - Add necessary header types - Update resource picker to appropriately work with traces query type - Build out TracesQueryEditor component - Include logic to retrieve operationId's for AI Workspaces - Add backend route mapping - Update macro to use timestamp as default time field for traces * AzureMonitor: Traces - Response parsing (#65442) * Update FormatAsField component - Add trace ResultFormat type - Generalise FormatAsField component - Add component to TracesQueryEditor - Remove duplicate code in setQueryValue * Add custom filter function to improve performance * Add basic conversion for logs to trace - Add serviceTags converter - Pass through required parameters (queryType and resultFormat) - Appropriately set visualisation * Update parsing to also fill trace tags - Add constant values for each table schema (include legacy mapping for now if needed) - Add constant for list of table tags - Set the foundation for dynamic query building - Update query to build tags value - Appropriately set operationName - Update tagsConverter to filter empty values * Fix lint and test issues * AzureMonitor: Traces - Data links (#65566) * Add portal link for traces - Pull out necessary values (itemId and itemType) - Appropriately construct - Fix ordering * Set default format as value - Also set default visualisation * Fix event schema * Set default formatAsField value * Include logs link on traces results - Adapt config links to allow custom title to be set * Correctly set operationId for query * Update backend types - Include OperationID in query - Pass forward datasource name and UID * Ensure setTime doesn't consistently get called if operationID is defined * Add explore link - Update util functions to allow setting custom datalinks * Fix tests * AzureMonitor: Traces - Query and Editor updates (#66076) * Add initial query - Will query the resource as soon as a resource has been selected - Updates the data links for the query without operationId - Remove initial operationId query and timeRange dependency - Update query building * Add entirely separate traces query property - Update shared types (also including future types for Azure traces) - Update backend log analytics datasource to accept both azureLogAnalytics and azureTraces queries - Update backend specific types - Update frontend datasource for new properties - Update mock query * Update FormatAsField to be entirely generic * Update query building to be done in backend - Add required mappings in backend - Update frontend querying * Fix query and explore data link * Add trace type selection * Better method for setting explore link * Fix operationId updating * Run go mod tidy * Unnecessary changes * Fix tests * AzureMonitor: Traces - Add correlation API support (#65855) Add correlation API support - Add necessary types - Add correlation API request when conditions are met - Update query * Fix property from merge * AzureMonitor: Traces - Filtering (#66303) * Add initial query - Will query the resource as soon as a resource has been selected - Updates the data links for the query without operationId - Remove initial operationId query and timeRange dependency - Update query building * Add entirely separate traces query property - Update shared types (also including future types for Azure traces) - Update backend log analytics datasource to accept both azureLogAnalytics and azureTraces queries - Update backend specific types - Update frontend datasource for new properties - Update mock query * Update FormatAsField to be entirely generic * Update query building to be done in backend - Add required mappings in backend - Update frontend querying * Fix query and explore data link * Add trace type selection * Better method for setting explore link * Fix operationId updating * Run go mod tidy * Unnecessary changes * Fix tests * Start building out Filters component - Configure component to query for Filter property values when a filter property is set - Add setFilters function - Add typing to tablesSchema - Use component in TracesQueryEditor * Update Filters - Asynchronously pull property options - Setup list of Filter components * Update filters component - Remove unused imports - Have local filters state and query filters - Correctly set filters values - Don't update query every time a filter property changes (not performant) * Update properties query - Use current timeRange - Get count to provide informative labels * Reset map when time changes * Add operation selection * Reset filters when property changes * Appropriate label name for empty values * Add filtering to query * Update filter components - Fix rendering issue - Correctly compare and update timeRange - Split out files for simplicity * Add checkbox option to multiselect - Add custom option component - Correctly call onChange - Add variableOptionGroup for template variable selection * Fix adding template vars * Improve labels and refresh labels on query prop changes * AzureMonitor: Traces - Testing (#66474) * Select ds for template variable interpolation * Update az logs ds tests - Add templateVariables test - Add filter test - Update mock - Remove anys * Update QueryEditor test - Update mocks with timeSrv for log analytics datasource - Fix query mock - Use appropriate and consistent selectors * Add TracesQueryEditor test - Update resourcePickerRows mock to include app insights resources - Remove comments and extra new line * Add FormatAsField test - Remove unneeded condition * Update resourcePicker utils test * Don't hide selected options in filters * Fix multi-selection on filters * Add TraceTypeField test - Add test file - Update selectors (remove copy/paste mistake) - Update placeholder text for select and add label * Add basic filters test * Begin filters test * Update filters test * Add final tests and simplify/generalise addFilter helper * Minor update to datasource test * Update macros test * Update selectors in tests * Add response-table-frame tests * Add datasource tests - Use sorting where JSON models are inconsistent - Update filters clause - Dedupe tags - Correct operationId conditions * Don't set a default value for blurInputOnSelect * Simplify datasource test * Update to use CheckGoldenJSON utils - Update with generated frame files - Remove redundant expected frame code - Update all usages * Fix lint * AzureMonitor: Traces feedback (#67292) * Filter traces if the visualisation is set to trace - Update build query logic - Added additional test cases - Return an error if the traces type is set by itself with the trace visualisation - Add descriptions to event types - Update tests * Fix bug for error displaying traces * Update mappings and add error field - Update tests - Remove unnecessary comments * Switch location of Operation ID field * Re-order fields * Update link title * Update label for event type selection * Update correct link title * Update logs datalink to link to Azure Logs in explore * Fix lint
242 lines
10 KiB
CUE
242 lines
10 KiB
CUE
// Copyright 2023 Grafana Labs
|
|
//
|
|
// Licensed under the Apache License, Version 2.0 (the "License")
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
|
|
package grafanaplugin
|
|
|
|
import (
|
|
common "github.com/grafana/grafana/packages/grafana-schema/src/common"
|
|
"github.com/grafana/grafana/pkg/plugins/pfs"
|
|
)
|
|
|
|
// This file (with its sibling .cue files) implements pfs.GrafanaPlugin
|
|
pfs.GrafanaPlugin
|
|
|
|
composableKinds: DataQuery: {
|
|
maturity: "merged"
|
|
|
|
lineage: {
|
|
seqs: [
|
|
{
|
|
schemas: [
|
|
{
|
|
#AzureMonitorQuery: common.DataQuery & {
|
|
// Azure subscription containing the resource(s) to be queried.
|
|
subscription?: string
|
|
|
|
// Subscriptions to be queried via Azure Resource Graph.
|
|
subscriptions?: [...string]
|
|
|
|
// Azure Monitor Metrics sub-query properties.
|
|
azureMonitor?: #AzureMetricQuery
|
|
// Azure Monitor Logs sub-query properties.
|
|
azureLogAnalytics?: #AzureLogsQuery
|
|
// Azure Resource Graph sub-query properties.
|
|
azureResourceGraph?: #AzureResourceGraphQuery
|
|
// Application Insights Traces sub-query properties.
|
|
azureTraces?: #AzureTracesQuery
|
|
// @deprecated Legacy template variable support.
|
|
grafanaTemplateVariableFn?: #GrafanaTemplateVariableQuery
|
|
|
|
// Template variables params. These exist for backwards compatiblity with legacy template variables.
|
|
resourceGroup?: string
|
|
namespace?: string
|
|
resource?: string
|
|
region?: string
|
|
// Azure Monitor query type.
|
|
// queryType: #AzureQueryType
|
|
} @cuetsy(kind="interface") @grafana(TSVeneer="type")
|
|
|
|
// Defines the supported queryTypes. GrafanaTemplateVariableFn is deprecated
|
|
#AzureQueryType: "Azure Monitor" | "Azure Log Analytics" | "Azure Resource Graph" | "Azure Traces" | "Azure Subscriptions" | "Azure Resource Groups" | "Azure Namespaces" | "Azure Resource Names" | "Azure Metric Names" | "Azure Workspaces" | "Azure Regions" | "Grafana Template Variable Function" @cuetsy(kind="enum", memberNames="AzureMonitor|LogAnalytics|AzureResourceGraph|AzureTraces|SubscriptionsQuery|ResourceGroupsQuery|NamespacesQuery|ResourceNamesQuery|MetricNamesQuery|WorkspacesQuery|LocationsQuery|GrafanaTemplateVariableFn")
|
|
|
|
#AzureMetricQuery: {
|
|
// Array of resource URIs to be queried.
|
|
resources?: [...#AzureMonitorResource]
|
|
// 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
|
|
// Used as the value for the metricNamespace property when it's different from the resource namespace.
|
|
customNamespace?: string
|
|
// The metric to query data for within the specified metricNamespace. e.g. UsedCapacity
|
|
metricName?: string
|
|
// The Azure region containing the resource(s).
|
|
region?: string
|
|
// The granularity of data points to be queried. Defaults to auto.
|
|
timeGrain?: string
|
|
// The aggregation to be used within the query. Defaults to the primaryAggregationType defined by the metric.
|
|
aggregation?: string
|
|
// Filters to reduce the set of data returned. Dimensions that can be filtered on are defined by the metric.
|
|
dimensionFilters?: [...#AzureMetricDimension]
|
|
// Maximum number of records to return. Defaults to 10.
|
|
top?: string
|
|
// Time grains that are supported by the metric.
|
|
allowedTimeGrainsMs?: [...int64]
|
|
|
|
// Aliases can be set to modify the legend labels. e.g. {{ resourceGroup }}. See docs for more detail.
|
|
alias?: string
|
|
|
|
// @deprecated
|
|
timeGrainUnit?: string
|
|
|
|
// @deprecated This property was migrated to dimensionFilters and should only be accessed in the migration
|
|
dimension?: string
|
|
|
|
// @deprecated This property was migrated to dimensionFilters and should only be accessed in the migration
|
|
dimensionFilter?: string
|
|
|
|
// @deprecated Use metricNamespace instead
|
|
metricDefinition?: string
|
|
|
|
// @deprecated Use resourceGroup, resourceName and metricNamespace instead
|
|
resourceUri?: string
|
|
|
|
// @deprecated Use resources instead
|
|
resourceGroup?: string
|
|
// @deprecated Use resources instead
|
|
resourceName?: string
|
|
} @cuetsy(kind="interface")
|
|
|
|
// Azure Monitor Logs sub-query properties
|
|
#AzureLogsQuery: {
|
|
// KQL query to be executed.
|
|
query?: string
|
|
// Specifies the format results should be returned as.
|
|
resultFormat?: #ResultFormat
|
|
// Array of resource URIs to be queried.
|
|
resources?: [...string]
|
|
// Workspace ID. This was removed in Grafana 8, but remains for backwards compat
|
|
workspace?: string
|
|
|
|
// @deprecated Use resources instead
|
|
resource?: string
|
|
} @cuetsy(kind="interface")
|
|
|
|
// Application Insights Traces sub-query properties
|
|
#AzureTracesQuery: {
|
|
// Specifies the format results should be returned as.
|
|
resultFormat?: #ResultFormat
|
|
// Array of resource URIs to be queried.
|
|
resources?: [...string]
|
|
// Operation ID. Used only for Traces queries.
|
|
operationId?: string
|
|
// Types of events to filter by.
|
|
traceTypes?: [...string]
|
|
// Filters for property values.
|
|
filters?: [...#AzureTracesFilter]
|
|
// KQL query to be executed.
|
|
query?: string
|
|
} @cuetsy(kind="interface")
|
|
|
|
#AzureTracesFilter: {
|
|
// Property name, auto-populated based on available traces.
|
|
property: string
|
|
// Comparison operator to use. Either equals or not equals.
|
|
operation: string
|
|
// Values to filter by.
|
|
filters: [...string]
|
|
} @cuetsy(kind="interface")
|
|
|
|
#ResultFormat: "table" | "time_series" | "trace" @cuetsy(kind="enum", memberNames="Table|TimeSeries|Trace")
|
|
|
|
#AzureResourceGraphQuery: {
|
|
// Azure Resource Graph KQL query to be executed.
|
|
query?: string
|
|
// Specifies the format results should be returned as. Defaults to table.
|
|
resultFormat?: string
|
|
} @cuetsy(kind="interface")
|
|
|
|
#AzureMonitorResource: {
|
|
subscription?: string
|
|
resourceGroup?: string
|
|
resourceName?: string
|
|
metricNamespace?: string
|
|
region?: string
|
|
} @cuetsy(kind="interface")
|
|
|
|
#AzureMetricDimension: {
|
|
// Name of Dimension to be filtered on.
|
|
dimension?: string
|
|
// 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
|
|
// Values to match with the filter.
|
|
filters?: [...string]
|
|
// @deprecated filter is deprecated in favour of filters to support multiselect.
|
|
filter?: string
|
|
} @cuetsy(kind="interface")
|
|
|
|
#GrafanaTemplateVariableQueryType: "AppInsightsMetricNameQuery" | "AppInsightsGroupByQuery" | "SubscriptionsQuery" | "ResourceGroupsQuery" | "ResourceNamesQuery" | "MetricNamespaceQuery" | "MetricNamesQuery" | "WorkspacesQuery" | "UnknownQuery" @cuetsy(kind="type")
|
|
#BaseGrafanaTemplateVariableQuery: {
|
|
rawQuery?: string
|
|
...
|
|
} @cuetsy(kind="interface")
|
|
#UnknownQuery: #BaseGrafanaTemplateVariableQuery & {
|
|
kind: "UnknownQuery"
|
|
} @cuetsy(kind="interface")
|
|
#AppInsightsMetricNameQuery: #BaseGrafanaTemplateVariableQuery & {
|
|
kind: "AppInsightsMetricNameQuery"
|
|
} @cuetsy(kind="interface")
|
|
#AppInsightsGroupByQuery: #BaseGrafanaTemplateVariableQuery & {
|
|
kind: "AppInsightsGroupByQuery"
|
|
metricName: string
|
|
} @cuetsy(kind="interface")
|
|
#SubscriptionsQuery: #BaseGrafanaTemplateVariableQuery & {
|
|
kind: "SubscriptionsQuery"
|
|
} @cuetsy(kind="interface")
|
|
#ResourceGroupsQuery: #BaseGrafanaTemplateVariableQuery & {
|
|
kind: "ResourceGroupsQuery"
|
|
subscription: string
|
|
} @cuetsy(kind="interface")
|
|
#ResourceNamesQuery: #BaseGrafanaTemplateVariableQuery & {
|
|
kind: "ResourceNamesQuery"
|
|
subscription: string
|
|
resourceGroup: string
|
|
metricNamespace: string
|
|
} @cuetsy(kind="interface")
|
|
#MetricNamespaceQuery: #BaseGrafanaTemplateVariableQuery & {
|
|
kind: "MetricNamespaceQuery"
|
|
subscription: string
|
|
resourceGroup: string
|
|
metricNamespace?: string
|
|
resourceName?: string
|
|
} @cuetsy(kind="interface")
|
|
|
|
// @deprecated Use MetricNamespaceQuery instead
|
|
#MetricDefinitionsQuery: #BaseGrafanaTemplateVariableQuery & {
|
|
kind: "MetricDefinitionsQuery"
|
|
subscription: string
|
|
resourceGroup: string
|
|
metricNamespace?: string
|
|
resourceName?: string
|
|
} @cuetsy(kind="interface")
|
|
#MetricNamesQuery: #BaseGrafanaTemplateVariableQuery & {
|
|
kind: "MetricNamesQuery"
|
|
subscription: string
|
|
resourceGroup: string
|
|
resourceName: string
|
|
metricNamespace: string
|
|
} @cuetsy(kind="interface")
|
|
#WorkspacesQuery: #BaseGrafanaTemplateVariableQuery & {
|
|
kind: "WorkspacesQuery"
|
|
subscription: string
|
|
} @cuetsy(kind="interface")
|
|
|
|
#GrafanaTemplateVariableQuery: #AppInsightsMetricNameQuery | #AppInsightsGroupByQuery | #SubscriptionsQuery | #ResourceGroupsQuery | #ResourceNamesQuery | #MetricNamespaceQuery | #MetricDefinitionsQuery | #MetricNamesQuery | #WorkspacesQuery | #UnknownQuery @cuetsy(kind="type")
|
|
},
|
|
]
|
|
},
|
|
]
|
|
}
|
|
}
|