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,MAAMuB,QAAQK,GAChBH,EAAuBA,EAAqBK,OAAOF,GAEnDH,EAAqBM,KAAKH,MAGvBH,GElRJ,MAAMO,GAAS,IAAIC,EAAAA,iBAAkEvF,IACzFwF,mBAAmBtP,GACnBuP,eAAetE,EAAAA,GACfuE,gBAAgBnP,GAChBoP,uBAAuBhP","sources":["webpack://grafana/./public/app/plugins/datasource/cloud-monitoring/components/CloudMonitoringCheatSheet.tsx","webpack://grafana/./public/app/plugins/datasource/cloud-monitoring/components/ConfigEditor/ConfigEditor.tsx","webpack://grafana/./public/app/plugins/datasource/cloud-monitoring/components/VariableQueryEditor.tsx","webpack://grafana/./public/app/plugins/datasource/cloud-monitoring/components/AnnotationQueryEditor.tsx","webpack://grafana/./public/app/plugins/datasource/cloud-monitoring/CloudMonitoringMetricFindQuery.ts","webpack://grafana/./public/app/plugins/datasource/cloud-monitoring/variables.ts","webpack://grafana/./public/app/plugins/datasource/cloud-monitoring/datasource.ts","webpack://grafana/./public/app/plugins/datasource/cloud-monitoring/annotationSupport.ts","webpack://grafana/./public/app/plugins/datasource/cloud-monitoring/module.ts"],"sourcesContent":["import { css } from '@emotion/css';\nimport React, { PureComponent } from 'react';\n\nimport { QueryEditorHelpProps } from '@grafana/data';\n\nimport { CloudMonitoringQuery } from '../types';\n\nexport default class CloudMonitoringCheatSheet extends PureComponent<\n QueryEditorHelpProps<CloudMonitoringQuery>,\n { userExamples: string[] }\n> {\n render() {\n return (\n <div>\n <h2>Cloud Monitoring alias patterns</h2>\n <div>\n <p>\n Format the legend keys any way you want by using alias patterns. Format the legend keys any way you want by\n using alias patterns.\n </p>\n Example:\n <code>{`${'{{metric.name}} - {{metric.label.instance_name}}'}`}</code>\n <br />\n Result: &nbsp;&nbsp;<code>cpu/usage_time - server1-europe-west-1</code>\n <br />\n <br />\n <label>Patterns</label>\n <br />\n <ul\n className={css`\n list-style: none;\n `}\n >\n <li>\n <code>{`${'{{metric.type}}'}`}</code> = metric type e.g. compute.googleapis.com/instance/cpu/usage_time\n </li>\n <li>\n <code>{`${'{{metric.name}}'}`}</code> = name part of metric e.g. instance/cpu/usage_time\n </li>\n <li>\n <code>{`${'{{metric.service}}'}`}</code> = service part of metric e.g. compute\n </li>\n <li>\n <code>{`${'{{metric.label.label_name}}'}`}</code> = Metric label metadata e.g. metric.label.instance_name\n </li>\n <li>\n <code>{`${'{{resource.label.label_name}}'}`}</code> = Resource label metadata e.g. resource.label.zone\n </li>\n <li>\n <code>{`${'{{metadata.system_labels.name}}'}`}</code> = Meta data system labels e.g.\n metadata.system_labels.name. For this to work, the needs to be included in the group by\n </li>\n <li>\n <code>{`${'{{metadata.user_labels.name}}'}`}</code> = Meta data user labels e.g.\n metadata.user_labels.name. For this to work, the needs to be included in the group by\n </li>\n <li>\n <code>{`${'{{bucket}}'}`}</code> = bucket boundary for distribution metrics when using a heatmap in\n Grafana\n </li>\n <li>\n <code>{`${'{{project}}'}`}</code> = The project name that was specified in the query editor\n </li>\n <li>\n <code>{`${'{{service}}'}`}</code> = The service id that was specified in the SLO query editor\n </li>\n <li>\n <code>{`${'{{slo}}'}`}</code> = The SLO id that was specified in the SLO query editor\n </li>\n <li>\n <code>{`${'{{selector}}'}`}</code> = The Selector function that was specified in the SLO query editor\n </li>\n </ul>\n </div>\n </div>\n );\n }\n}\n","import React, { PureComponent } from 'react';\n\nimport { DataSourcePluginOptionsEditorProps } from '@grafana/data';\nimport { ConnectionConfig } from '@grafana/google-sdk';\n\nimport { CloudMonitoringOptions, CloudMonitoringSecureJsonData } from '../../types';\n\nexport type Props = DataSourcePluginOptionsEditorProps<CloudMonitoringOptions, CloudMonitoringSecureJsonData>;\n\nexport class ConfigEditor extends PureComponent<Props> {\n render() {\n return (\n <>\n <ConnectionConfig {...this.props}></ConnectionConfig>\n </>\n );\n }\n}\n","import React, { PureComponent } from 'react';\n\nimport { QueryEditorProps } from '@grafana/data';\nimport { getTemplateSrv } from '@grafana/runtime';\n\nimport CloudMonitoringDatasource from '../datasource';\nimport { extractServicesFromMetricDescriptors, getLabelKeys, getMetricTypes } from '../functions';\nimport {\n CloudMonitoringOptions,\n CloudMonitoringQuery,\n CloudMonitoringVariableQuery,\n MetricDescriptor,\n MetricFindQueryTypes,\n VariableQueryData,\n} from '../types';\n\nimport { VariableQueryField } from './';\n\nexport type Props = QueryEditorProps<\n CloudMonitoringDatasource,\n CloudMonitoringQuery,\n CloudMonitoringOptions,\n CloudMonitoringVariableQuery\n>;\n\nexport class CloudMonitoringVariableQueryEditor extends PureComponent<Props, VariableQueryData> {\n queryTypes: Array<{ value: string; label: string }> = [\n { value: MetricFindQueryTypes.Projects, label: 'Projects' },\n { value: MetricFindQueryTypes.Services, label: 'Services' },\n { value: MetricFindQueryTypes.MetricTypes, label: 'Metric Types' },\n { value: MetricFindQueryTypes.LabelKeys, label: 'Label Keys' },\n { value: MetricFindQueryTypes.LabelValues, label: 'Label Values' },\n { value: MetricFindQueryTypes.ResourceTypes, label: 'Resource Types' },\n { value: MetricFindQueryTypes.Aggregations, label: 'Aggregations' },\n { value: MetricFindQueryTypes.Aligners, label: 'Aligners' },\n { value: MetricFindQueryTypes.AlignmentPeriods, label: 'Alignment Periods' },\n { value: MetricFindQueryTypes.Selectors, label: 'Selectors' },\n { value: MetricFindQueryTypes.SLOServices, label: 'SLO Services' },\n { value: MetricFindQueryTypes.SLO, label: 'Service Level Objectives (SLO)' },\n ];\n\n defaults: VariableQueryData = {\n selectedQueryType: this.queryTypes[0].value,\n metricDescriptors: [],\n selectedService: '',\n selectedMetricType: '',\n labels: [],\n labelKey: '',\n metricTypes: [],\n services: [],\n sloServices: [],\n selectedSLOService: '',\n projects: [],\n projectName: '',\n loading: true,\n };\n\n constructor(props: Props) {\n super(props);\n this.state = Object.assign(\n this.defaults,\n { projectName: this.props.datasource.getDefaultProject() },\n this.props.query\n );\n }\n\n async componentDidMount() {\n const projects = (await this.props.datasource.getProjects()) as MetricDescriptor[];\n const metricDescriptors = await this.props.datasource.getMetricTypes(\n this.props.query.projectName || this.props.datasource.getDefaultProject()\n );\n const services = extractServicesFromMetricDescriptors(metricDescriptors).map((m: any) => ({\n value: m.service,\n label: m.serviceShortName,\n }));\n\n let selectedService = '';\n if (services.some((s) => s.value === getTemplateSrv().replace(this.state.selectedService))) {\n selectedService = this.state.selectedService;\n } else if (services && services.length > 0) {\n selectedService = services[0].value;\n }\n\n const { metricTypes, selectedMetricType } = getMetricTypes(\n metricDescriptors,\n this.state.selectedMetricType,\n getTemplateSrv().replace(this.state.selectedMetricType),\n getTemplateSrv().replace(selectedService)\n );\n\n const sloServices = await this.props.datasource.getSLOServices(this.state.projectName);\n\n const state: any = {\n services,\n selectedService,\n metricTypes,\n selectedMetricType,\n metricDescriptors,\n projects,\n ...(await this.getLabels(selectedMetricType, this.state.projectName)),\n sloServices,\n loading: false,\n };\n this.setState(state, () => this.onPropsChange());\n }\n\n onPropsChange = () => {\n const { metricDescriptors, labels, metricTypes, services, ...queryModel } = this.state;\n this.props.onChange({ ...queryModel, refId: 'CloudMonitoringVariableQueryEditor-VariableQuery' });\n };\n\n async onQueryTypeChange(queryType: string) {\n const state: any = {\n selectedQueryType: queryType,\n ...(await this.getLabels(this.state.selectedMetricType, this.state.projectName, queryType)),\n };\n\n this.setState(state);\n }\n\n async onProjectChange(projectName: string) {\n const metricDescriptors = await this.props.datasource.getMetricTypes(projectName);\n const labels = await this.getLabels(this.state.selectedMetricType, projectName);\n const { metricTypes, selectedMetricType } = getMetricTypes(\n metricDescriptors,\n this.state.selectedMetricType,\n getTemplateSrv().replace(this.state.selectedMetricType),\n getTemplateSrv().replace(this.state.selectedService)\n );\n\n const sloServices = await this.props.datasource.getSLOServices(projectName);\n\n this.setState(\n {\n ...labels,\n metricTypes,\n selectedMetricType,\n metricDescriptors,\n projectName,\n sloServices,\n },\n () => this.onPropsChange()\n );\n }\n\n async onServiceChange(service: string) {\n const { metricTypes, selectedMetricType } = getMetricTypes(\n this.state.metricDescriptors,\n this.state.selectedMetricType,\n getTemplateSrv().replace(this.state.selectedMetricType),\n getTemplateSrv().replace(service)\n );\n const state: any = {\n selectedService: service,\n metricTypes,\n selectedMetricType,\n ...(await this.getLabels(selectedMetricType, this.state.projectName)),\n };\n this.setState(state, () => this.onPropsChange());\n }\n\n async onMetricTypeChange(metricType: string) {\n const state: any = {\n selectedMetricType: metricType,\n ...(await this.getLabels(metricType, this.state.projectName)),\n };\n this.setState(state, () => this.onPropsChange());\n }\n\n onLabelKeyChange(labelKey: string) {\n this.setState({ labelKey }, () => this.onPropsChange());\n }\n\n componentDidUpdate(prevProps: Readonly<Props>, prevState: Readonly<VariableQueryData>) {\n const selecQueryTypeChanged = prevState.selectedQueryType !== this.state.selectedQueryType;\n const selectSLOServiceChanged = this.state.selectedSLOService !== prevState.selectedSLOService;\n if (selecQueryTypeChanged || selectSLOServiceChanged) {\n this.onPropsChange();\n }\n }\n\n async getLabels(selectedMetricType: string, projectName: string, selectedQueryType = this.state.selectedQueryType) {\n let result = { labels: this.state.labels, labelKey: this.state.labelKey };\n if (selectedMetricType && selectedQueryType === MetricFindQueryTypes.LabelValues) {\n const labels = await getLabelKeys(this.props.datasource, selectedMetricType, projectName);\n const labelKey = labels.some((l) => l === getTemplateSrv().replace(this.state.labelKey))\n ? this.state.labelKey\n : labels[0];\n result = { labels, labelKey };\n }\n return result;\n }\n\n renderQueryTypeSwitch(queryType: string) {\n const variableOptionGroup = {\n label: 'Template Variables',\n expanded: false,\n options: getTemplateSrv()\n .getVariables()\n .map((v: any) => ({\n value: `$${v.name}`,\n label: `$${v.name}`,\n })),\n };\n\n switch (queryType) {\n case MetricFindQueryTypes.MetricTypes:\n return (\n <>\n <VariableQueryField\n allowCustomValue={true}\n value={this.state.projectName}\n options={[variableOptionGroup, ...this.state.projects]}\n onChange={(value) => this.onProjectChange(value)}\n label=\"Project\"\n />\n <VariableQueryField\n value={this.state.selectedService}\n options={[variableOptionGroup, ...this.state.services]}\n onChange={(value) => this.onServiceChange(value)}\n label=\"Service\"\n />\n </>\n );\n case MetricFindQueryTypes.LabelKeys:\n case MetricFindQueryTypes.LabelValues:\n case MetricFindQueryTypes.ResourceTypes:\n return (\n <>\n <VariableQueryField\n allowCustomValue={true}\n value={this.state.projectName}\n options={[variableOptionGroup, ...this.state.projects]}\n onChange={(value) => this.onProjectChange(value)}\n label=\"Project\"\n />\n <VariableQueryField\n value={this.state.selectedService}\n options={[variableOptionGroup, ...this.state.services]}\n onChange={(value) => this.onServiceChange(value)}\n label=\"Service\"\n />\n <VariableQueryField\n value={this.state.selectedMetricType}\n options={[\n variableOptionGroup,\n ...this.state.metricTypes.map(({ value, name }) => ({ value, label: name })),\n ]}\n onChange={(value) => this.onMetricTypeChange(value)}\n label=\"Metric Type\"\n />\n {queryType === MetricFindQueryTypes.LabelValues && (\n <VariableQueryField\n value={this.state.labelKey}\n options={[variableOptionGroup, ...this.state.labels.map((l) => ({ value: l, label: l }))]}\n onChange={(value) => this.onLabelKeyChange(value)}\n label=\"Label Key\"\n />\n )}\n </>\n );\n case MetricFindQueryTypes.Aligners:\n case MetricFindQueryTypes.Aggregations:\n return (\n <>\n <VariableQueryField\n value={this.state.selectedService}\n options={[variableOptionGroup, ...this.state.services]}\n onChange={(value) => this.onServiceChange(value)}\n label=\"Service\"\n />\n <VariableQueryField\n value={this.state.selectedMetricType}\n options={[\n variableOptionGroup,\n ...this.state.metricTypes.map(({ value, name }) => ({ value, label: name })),\n ]}\n onChange={(value) => this.onMetricTypeChange(value)}\n label=\"Metric Type\"\n />\n </>\n );\n case MetricFindQueryTypes.SLOServices:\n return (\n <>\n <VariableQueryField\n allowCustomValue={true}\n value={this.state.projectName}\n options={[variableOptionGroup, ...this.state.projects]}\n onChange={(value) => this.onProjectChange(value)}\n label=\"Project\"\n />\n </>\n );\n\n case MetricFindQueryTypes.SLO:\n return (\n <>\n <VariableQueryField\n allowCustomValue={true}\n value={this.state.projectName}\n options={[variableOptionGroup, ...this.state.projects]}\n onChange={(value) => this.onProjectChange(value)}\n label=\"Project\"\n />\n <VariableQueryField\n value={this.state.selectedSLOService}\n options={[variableOptionGroup, ...this.state.sloServices]}\n onChange={(value) => {\n this.setState({\n ...this.state,\n selectedSLOService: value,\n });\n }}\n label=\"SLO Service\"\n />\n </>\n );\n default:\n return '';\n }\n }\n\n render() {\n if (this.state.loading) {\n return (\n <div className=\"gf-form max-width-21\">\n <span className=\"gf-form-label width-10 query-keyword\">Query Type</span>\n <div className=\"gf-form-select-wrapper max-width-12\">\n <select className=\"gf-form-input\">\n <option>Loading...</option>\n </select>\n </div>\n </div>\n );\n }\n\n return (\n <>\n <VariableQueryField\n value={this.state.selectedQueryType}\n options={this.queryTypes}\n onChange={(value) => this.onQueryTypeChange(value)}\n label=\"Query Type\"\n />\n {this.renderQueryTypeSwitch(this.state.selectedQueryType)}\n </>\n );\n }\n}\n","import React, { useState } from 'react';\nimport { useDebounce } from 'react-use';\n\nimport { QueryEditorProps, toOption } from '@grafana/data';\nimport { Input } from '@grafana/ui';\n\nimport { INPUT_WIDTH } from '../constants';\nimport CloudMonitoringDatasource from '../datasource';\nimport {\n EditorMode,\n MetricKind,\n AnnotationMetricQuery,\n CloudMonitoringOptions,\n CloudMonitoringQuery,\n AlignmentTypes,\n} from '../types';\n\nimport { MetricQueryEditor } from './MetricQueryEditor';\n\nimport { AnnotationsHelp, QueryEditorRow } from './';\n\nexport type Props = QueryEditorProps<CloudMonitoringDatasource, CloudMonitoringQuery, CloudMonitoringOptions>;\n\nexport const defaultQuery: (datasource: CloudMonitoringDatasource) => AnnotationMetricQuery = (datasource) => ({\n editorMode: EditorMode.Visual,\n projectName: datasource.getDefaultProject(),\n projects: [],\n metricType: '',\n filters: [],\n metricKind: MetricKind.GAUGE,\n valueType: '',\n refId: 'annotationQuery',\n title: '',\n text: '',\n labels: {},\n variableOptionGroup: {},\n variableOptions: [],\n query: '',\n crossSeriesReducer: 'REDUCE_NONE',\n perSeriesAligner: AlignmentTypes.ALIGN_NONE,\n alignmentPeriod: 'grafana-auto',\n});\n\nexport const AnnotationQueryEditor = (props: Props) => {\n const { datasource, query, onRunQuery, data, onChange } = props;\n const meta = data?.series.length ? data?.series[0].meta : {};\n const customMetaData = meta?.custom ?? {};\n const metricQuery = { ...defaultQuery(datasource), ...query.metricQuery };\n const [title, setTitle] = useState(metricQuery.title || '');\n const [text, setText] = useState(metricQuery.text || '');\n const variableOptionGroup = {\n label: 'Template Variables',\n options: datasource.getVariables().map(toOption),\n };\n\n const handleQueryChange = (metricQuery: AnnotationMetricQuery) => onChange({ ...query, metricQuery });\n const handleTitleChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n setTitle(e.target.value);\n };\n const handleTextChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n setText(e.target.value);\n };\n\n useDebounce(\n () => {\n onChange({ ...query, metricQuery: { ...metricQuery, title } });\n },\n 1000,\n [title, onChange]\n );\n useDebounce(\n () => {\n onChange({ ...query, metricQuery: { ...metricQuery, text } });\n },\n 1000,\n [text, onChange]\n );\n\n return (\n <>\n <MetricQueryEditor\n refId={query.refId}\n variableOptionGroup={variableOptionGroup}\n customMetaData={customMetaData}\n onChange={handleQueryChange}\n onRunQuery={onRunQuery}\n datasource={datasource}\n query={metricQuery}\n />\n\n <QueryEditorRow label=\"Title\" htmlFor=\"annotation-query-title\">\n <Input id=\"annotation-query-title\" value={title} width={INPUT_WIDTH} onChange={handleTitleChange} />\n </QueryEditorRow>\n\n <QueryEditorRow label=\"Text\" htmlFor=\"annotation-query-text\">\n <Input id=\"annotation-query-text\" value={text} width={INPUT_WIDTH} onChange={handleTextChange} />\n </QueryEditorRow>\n\n <AnnotationsHelp />\n </>\n );\n};\n","import { isString } from 'lodash';\n\nimport { SelectableValue } from '@grafana/data';\n\nimport { ALIGNMENT_PERIODS, SELECTORS } from './constants';\nimport CloudMonitoringDatasource from './datasource';\nimport {\n extractServicesFromMetricDescriptors,\n getAggregationOptionsByMetric,\n getAlignmentOptionsByMetric,\n getLabelKeys,\n getMetricTypesByService,\n} from './functions';\nimport { CloudMonitoringVariableQuery, MetricDescriptor, MetricFindQueryTypes, MetricKind, ValueTypes } from './types';\n\nexport default class CloudMonitoringMetricFindQuery {\n constructor(private datasource: CloudMonitoringDatasource) {}\n\n async execute(query: CloudMonitoringVariableQuery) {\n try {\n if (!query.projectName) {\n query.projectName = this.datasource.getDefaultProject();\n }\n\n switch (query.selectedQueryType) {\n case MetricFindQueryTypes.Projects:\n return this.handleProjectsQuery();\n case MetricFindQueryTypes.Services:\n return this.handleServiceQuery(query);\n case MetricFindQueryTypes.MetricTypes:\n return this.handleMetricTypesQuery(query);\n case MetricFindQueryTypes.LabelKeys:\n return this.handleLabelKeysQuery(query);\n case MetricFindQueryTypes.LabelValues:\n return this.handleLabelValuesQuery(query);\n case MetricFindQueryTypes.ResourceTypes:\n return this.handleResourceTypeQuery(query);\n case MetricFindQueryTypes.Aligners:\n return this.handleAlignersQuery(query);\n case MetricFindQueryTypes.AlignmentPeriods:\n return this.handleAlignmentPeriodQuery();\n case MetricFindQueryTypes.Aggregations:\n return this.handleAggregationQuery(query);\n case MetricFindQueryTypes.SLOServices:\n return this.handleSLOServicesQuery(query);\n case MetricFindQueryTypes.SLO:\n return this.handleSLOQuery(query);\n case MetricFindQueryTypes.Selectors:\n return this.handleSelectorQuery();\n default:\n return [];\n }\n } catch (error) {\n console.error(`Could not run CloudMonitoringMetricFindQuery ${query}`, error);\n return [];\n }\n }\n\n async handleProjectsQuery() {\n const projects = await this.datasource.getProjects();\n return (projects as SelectableValue<string>).map((s: { label: string; value: string }) => ({\n text: s.label,\n value: s.value,\n expandable: true,\n }));\n }\n\n async handleServiceQuery({ projectName }: CloudMonitoringVariableQuery) {\n const metricDescriptors = await this.datasource.getMetricTypes(projectName);\n const services: MetricDescriptor[] = extractServicesFromMetricDescriptors(metricDescriptors);\n return services.map((s) => ({\n text: s.serviceShortName,\n value: s.service,\n expandable: true,\n }));\n }\n\n async handleMetricTypesQuery({ selectedService, projectName }: CloudMonitoringVariableQuery) {\n if (!selectedService) {\n return [];\n }\n const metricDescriptors = await this.datasource.getMetricTypes(projectName);\n return getMetricTypesByService(metricDescriptors, this.datasource.templateSrv.replace(selectedService)).map(\n (s) => ({\n text: s.displayName,\n value: s.type,\n expandable: true,\n })\n );\n }\n\n async handleLabelKeysQuery({ selectedMetricType, projectName }: CloudMonitoringVariableQuery) {\n if (!selectedMetricType) {\n return [];\n }\n const labelKeys = await getLabelKeys(this.datasource, selectedMetricType, projectName);\n return labelKeys.map(this.toFindQueryResult);\n }\n\n async handleLabelValuesQuery({ selectedMetricType, labelKey, projectName }: CloudMonitoringVariableQuery) {\n if (!selectedMetricType) {\n return [];\n }\n const refId = 'handleLabelValuesQuery';\n // REDUCE_MEAN is needed so the groupBy is not ignored\n const labels = await this.datasource.getLabels(selectedMetricType, refId, projectName, {\n groupBys: [labelKey],\n crossSeriesReducer: 'REDUCE_MEAN',\n });\n const interpolatedKey = this.datasource.templateSrv.replace(labelKey);\n const values = labels.hasOwnProperty(interpolatedKey) ? labels[interpolatedKey] : [];\n return values.map(this.toFindQueryResult);\n }\n\n async handleResourceTypeQuery({ selectedMetricType, projectName }: CloudMonitoringVariableQuery) {\n if (!selectedMetricType) {\n return [];\n }\n const refId = 'handleResourceTypeQueryQueryType';\n const labels = await this.datasource.getLabels(selectedMetricType, refId, projectName);\n return labels['resource.type']?.map(this.toFindQueryResult) ?? [];\n }\n\n async handleAlignersQuery({ selectedMetricType, projectName }: CloudMonitoringVariableQuery) {\n if (!selectedMetricType) {\n return [];\n }\n const metricDescriptors = await this.datasource.getMetricTypes(projectName);\n const descriptor = metricDescriptors.find(\n (m) => m.type === this.datasource.templateSrv.replace(selectedMetricType)\n );\n\n if (!descriptor) {\n return [];\n }\n\n return getAlignmentOptionsByMetric(descriptor.valueType, descriptor.metricKind).map(this.toFindQueryResult);\n }\n\n async handleAggregationQuery({ selectedMetricType, projectName }: CloudMonitoringVariableQuery) {\n if (!selectedMetricType) {\n return [];\n }\n\n const metricDescriptors = await this.datasource.getMetricTypes(projectName);\n const descriptor = metricDescriptors.find(\n (m) => m.type === this.datasource.templateSrv.replace(selectedMetricType)\n );\n\n if (!descriptor) {\n return [];\n }\n\n return getAggregationOptionsByMetric(descriptor.valueType as ValueTypes, descriptor.metricKind as MetricKind).map(\n this.toFindQueryResult\n );\n }\n\n async handleSLOServicesQuery({ projectName }: CloudMonitoringVariableQuery) {\n const services = await this.datasource.getSLOServices(projectName);\n return services.map(this.toFindQueryResult);\n }\n\n async handleSLOQuery({ selectedSLOService, projectName }: CloudMonitoringVariableQuery) {\n const slos = await this.datasource.getServiceLevelObjectives(projectName, selectedSLOService);\n return slos.map(this.toFindQueryResult);\n }\n\n async handleSelectorQuery() {\n return SELECTORS.map(this.toFindQueryResult);\n }\n\n handleAlignmentPeriodQuery() {\n return ALIGNMENT_PERIODS.map(this.toFindQueryResult);\n }\n\n toFindQueryResult(x: any) {\n return isString(x) ? { text: x, expandable: true } : { ...x, expandable: true };\n }\n}\n","import { from, Observable } from 'rxjs';\nimport { map, mergeMap } from 'rxjs/operators';\n\nimport { CustomVariableSupport, DataQueryRequest, DataQueryResponse } from '@grafana/data';\n\nimport CloudMonitoringMetricFindQuery from './CloudMonitoringMetricFindQuery';\nimport { CloudMonitoringVariableQueryEditor } from './components/VariableQueryEditor';\nimport CloudMonitoringDatasource from './datasource';\nimport { CloudMonitoringVariableQuery } from './types';\n\nexport class CloudMonitoringVariableSupport extends CustomVariableSupport<\n CloudMonitoringDatasource,\n CloudMonitoringVariableQuery\n> {\n private readonly metricFindQuery: CloudMonitoringMetricFindQuery;\n\n constructor(private readonly datasource: CloudMonitoringDatasource) {\n super();\n this.metricFindQuery = new CloudMonitoringMetricFindQuery(datasource);\n this.query = this.query.bind(this);\n }\n\n editor = CloudMonitoringVariableQueryEditor;\n\n query(request: DataQueryRequest<CloudMonitoringVariableQuery>): Observable<DataQueryResponse> {\n const executeObservable = from(this.metricFindQuery.execute(request.targets[0]));\n return from(this.datasource.ensureGCEDefaultProject()).pipe(\n mergeMap(() => executeObservable),\n map((data) => ({ data }))\n );\n }\n}\n","import { chunk, flatten, isString, isArray } from 'lodash';\nimport { from, lastValueFrom, Observable, of } from 'rxjs';\nimport { map, mergeMap } from 'rxjs/operators';\n\nimport {\n DataQueryRequest,\n DataQueryResponse,\n DataSourceInstanceSettings,\n ScopedVars,\n SelectableValue,\n} from '@grafana/data';\nimport { DataSourceWithBackend, getBackendSrv, toDataQueryResponse } from '@grafana/runtime';\nimport { getTimeSrv, TimeSrv } from 'app/features/dashboard/services/TimeSrv';\nimport { getTemplateSrv, TemplateSrv } from 'app/features/templating/template_srv';\n\nimport { CloudMonitoringAnnotationSupport } from './annotationSupport';\nimport {\n CloudMonitoringOptions,\n CloudMonitoringQuery,\n EditorMode,\n Filter,\n MetricDescriptor,\n QueryType,\n PostResponse,\n Aggregation,\n} from './types';\nimport { CloudMonitoringVariableSupport } from './variables';\n\nexport default class CloudMonitoringDatasource extends DataSourceWithBackend<\n CloudMonitoringQuery,\n CloudMonitoringOptions\n> {\n authenticationType: string;\n intervalMs: number;\n\n constructor(\n private instanceSettings: DataSourceInstanceSettings<CloudMonitoringOptions>,\n public templateSrv: TemplateSrv = getTemplateSrv(),\n private readonly timeSrv: TimeSrv = getTimeSrv()\n ) {\n super(instanceSettings);\n this.authenticationType = instanceSettings.jsonData.authenticationType || 'jwt';\n this.variables = new CloudMonitoringVariableSupport(this);\n this.intervalMs = 0;\n this.annotations = CloudMonitoringAnnotationSupport(this);\n }\n\n getVariables() {\n return this.templateSrv.getVariables().map((v) => `$${v.name}`);\n }\n\n query(request: DataQueryRequest<CloudMonitoringQuery>): Observable<DataQueryResponse> {\n request.targets = request.targets.map((t) => ({\n ...this.migrateQuery(t),\n intervalMs: request.intervalMs,\n }));\n return super.query(request);\n }\n\n applyTemplateVariables(\n { metricQuery, refId, queryType, sloQuery, type = 'timeSeriesQuery' }: CloudMonitoringQuery,\n scopedVars: ScopedVars\n ): Record<string, any> {\n return {\n datasource: this.getRef(),\n refId,\n intervalMs: this.intervalMs,\n type,\n queryType,\n metricQuery: {\n ...this.interpolateProps(metricQuery, scopedVars),\n projectName: this.templateSrv.replace(\n metricQuery.projectName ? metricQuery.projectName : this.getDefaultProject(),\n scopedVars\n ),\n filters: this.interpolateFilters(metricQuery.filters || [], scopedVars),\n groupBys: this.interpolateGroupBys(metricQuery.groupBys || [], scopedVars),\n view: metricQuery.view || 'FULL',\n editorMode: metricQuery.editorMode,\n },\n sloQuery: sloQuery && this.interpolateProps(sloQuery, scopedVars),\n };\n }\n\n async getLabels(metricType: string, refId: string, projectName: string, aggregation?: Aggregation) {\n const options = {\n targets: [\n {\n refId,\n datasource: this.getRef(),\n queryType: QueryType.METRICS,\n metricQuery: {\n projectName: this.templateSrv.replace(projectName),\n metricType: this.templateSrv.replace(metricType),\n groupBys: this.interpolateGroupBys(aggregation?.groupBys || [], {}),\n crossSeriesReducer: aggregation?.crossSeriesReducer ?? 'REDUCE_NONE',\n view: 'HEADERS',\n },\n },\n ],\n range: this.timeSrv.timeRange(),\n } as DataQueryRequest<CloudMonitoringQuery>;\n\n const queries = options.targets;\n\n if (!queries.length) {\n return lastValueFrom(of({ results: [] }));\n }\n\n return lastValueFrom(\n from(this.ensureGCEDefaultProject()).pipe(\n mergeMap(() => {\n return getBackendSrv().fetch<PostResponse>({\n url: '/api/ds/query',\n method: 'POST',\n data: {\n from: options.range.from.valueOf().toString(),\n to: options.range.to.valueOf().toString(),\n queries,\n },\n });\n }),\n map(({ data }) => {\n const dataQueryResponse = toDataQueryResponse({\n data: data,\n });\n const labels = dataQueryResponse?.data\n .map((f) => f.meta?.custom?.labels)\n .filter((p) => !!p)\n .reduce((acc, labels) => {\n for (let key in labels) {\n if (!acc[key]) {\n acc[key] = new Set<string>();\n }\n if (labels[key]) {\n acc[key].add(labels[key]);\n }\n }\n return acc;\n }, {});\n return Object.fromEntries(\n Object.entries(labels).map((l: any) => {\n l[1] = Array.from(l[1]);\n return l;\n })\n );\n })\n )\n );\n }\n\n async getGCEDefaultProject() {\n return this.getResource(`gceDefaultProject`);\n }\n\n getDefaultProject(): string {\n const { defaultProject, authenticationType, gceDefaultProject } = this.instanceSettings.jsonData;\n if (authenticationType === 'gce') {\n return gceDefaultProject || '';\n }\n\n return defaultProject || '';\n }\n\n async ensureGCEDefaultProject() {\n const { authenticationType, gceDefaultProject } = this.instanceSettings.jsonData;\n if (authenticationType === 'gce' && !gceDefaultProject) {\n this.instanceSettings.jsonData.gceDefaultProject = await this.getGCEDefaultProject();\n }\n }\n\n async getMetricTypes(projectName: string): Promise<MetricDescriptor[]> {\n if (!projectName) {\n return [];\n }\n\n return this.getResource(\n `metricDescriptors/v3/projects/${this.templateSrv.replace(projectName)}/metricDescriptors`\n ) as Promise<MetricDescriptor[]>;\n }\n\n async getSLOServices(projectName: string): Promise<Array<SelectableValue<string>>> {\n return this.getResource(`services/v3/projects/${this.templateSrv.replace(projectName)}/services?pageSize=1000`);\n }\n\n async getServiceLevelObjectives(projectName: string, serviceId: string): Promise<Array<SelectableValue<string>>> {\n if (!serviceId) {\n return Promise.resolve([]);\n }\n let { projectName: p, serviceId: s } = this.interpolateProps({ projectName, serviceId });\n return this.getResource(`slo-services/v3/projects/${p}/services/${s}/serviceLevelObjectives`);\n }\n\n getProjects(): Promise<Array<SelectableValue<string>>> {\n return this.getResource(`projects`);\n }\n\n migrateQuery(query: CloudMonitoringQuery): CloudMonitoringQuery {\n if (!query.hasOwnProperty('metricQuery')) {\n const { hide, refId, datasource, key, queryType, maxLines, metric, intervalMs, type, ...rest } = query as any;\n return {\n refId,\n intervalMs,\n type,\n hide,\n queryType: QueryType.METRICS,\n metricQuery: {\n ...rest,\n view: rest.view || 'FULL',\n },\n };\n }\n return query;\n }\n\n interpolateProps<T extends Record<string, any>>(object: T, scopedVars: ScopedVars = {}): T {\n return Object.entries(object).reduce((acc, [key, value]) => {\n return {\n ...acc,\n [key]: value && isString(value) ? this.templateSrv.replace(value, scopedVars) : value,\n };\n }, {} as T);\n }\n\n filterQuery(query: CloudMonitoringQuery): boolean {\n if (query.hide) {\n return false;\n }\n\n if (query.queryType && query.queryType === QueryType.SLO && query.sloQuery) {\n const { selectorName, serviceId, sloId, projectName } = query.sloQuery;\n return !!selectorName && !!serviceId && !!sloId && !!projectName;\n }\n\n if (query.queryType && query.queryType === QueryType.METRICS && query.metricQuery.editorMode === EditorMode.MQL) {\n return !!query.metricQuery.projectName && !!query.metricQuery.query;\n }\n\n const { metricType } = query.metricQuery;\n\n return !!metricType;\n }\n\n interpolateVariablesInQueries(queries: CloudMonitoringQuery[], scopedVars: ScopedVars): CloudMonitoringQuery[] {\n return queries.map(\n (query) => this.applyTemplateVariables(this.migrateQuery(query), scopedVars) as CloudMonitoringQuery\n );\n }\n\n interpolateFilters(filters: string[], scopedVars: ScopedVars) {\n const completeFilter: Filter[] = chunk(filters, 4)\n .map(([key, operator, value, condition]) => ({\n key,\n operator,\n value,\n ...(condition && { condition }),\n }))\n .filter((item) => item.value);\n\n const filterArray = flatten(\n completeFilter.map(({ key, operator, value, condition }: Filter) => [\n this.templateSrv.replace(key, scopedVars || {}),\n operator,\n this.templateSrv.replace(value, scopedVars || {}, (value: string | string[]) => {\n return isArray(value) && value.length ? `(${value.join('|')})` : value;\n }),\n ...(condition ? [condition] : []),\n ])\n );\n\n return filterArray || [];\n }\n\n interpolateGroupBys(groupBys: string[], scopedVars: {}): string[] {\n let interpolatedGroupBys: string[] = [];\n (groupBys || []).forEach((gb) => {\n const interpolated = this.templateSrv.replace(gb, scopedVars || {}, 'csv').split(',');\n if (Array.isArray(interpolated)) {\n interpolatedGroupBys = interpolatedGroupBys.concat(interpolated);\n } else {\n interpolatedGroupBys.push(interpolated);\n }\n });\n return interpolatedGroupBys;\n }\n}\n","import { AnnotationSupport, AnnotationQuery } from '@grafana/data';\n\nimport { AnnotationQueryEditor } from './components/AnnotationQueryEditor';\nimport CloudMonitoringDatasource from './datasource';\nimport {\n AlignmentTypes,\n CloudMonitoringQuery,\n EditorMode,\n LegacyCloudMonitoringAnnotationQuery,\n MetricKind,\n QueryType,\n} from './types';\n\n// The legacy query format sets the title and text values to empty strings by default.\n// If the title or text is not undefined at the top-level of the annotation target,\n// then it is a legacy query.\nconst isLegacyCloudMonitoringAnnotation = (\n query: unknown\n): query is AnnotationQuery<LegacyCloudMonitoringAnnotationQuery> =>\n (query as AnnotationQuery<LegacyCloudMonitoringAnnotationQuery>).target?.title !== undefined ||\n (query as AnnotationQuery<LegacyCloudMonitoringAnnotationQuery>).target?.text !== undefined;\n\nexport const CloudMonitoringAnnotationSupport: (\n ds: CloudMonitoringDatasource\n) => AnnotationSupport<CloudMonitoringQuery> = (ds: CloudMonitoringDatasource) => {\n return {\n prepareAnnotation: (\n query: AnnotationQuery<LegacyCloudMonitoringAnnotationQuery> | AnnotationQuery<CloudMonitoringQuery>\n ): AnnotationQuery<CloudMonitoringQuery> => {\n if (!isLegacyCloudMonitoringAnnotation(query)) {\n return query;\n }\n\n const { enable, name, iconColor } = query;\n const { target } = query;\n const result: AnnotationQuery<CloudMonitoringQuery> = {\n datasource: query.datasource,\n enable,\n name,\n iconColor,\n target: {\n intervalMs: ds.intervalMs,\n refId: target?.refId || 'annotationQuery',\n type: 'annotationQuery',\n queryType: QueryType.METRICS,\n metricQuery: {\n projectName: target?.projectName || ds.getDefaultProject(),\n editorMode: EditorMode.Visual,\n metricType: target?.metricType || '',\n filters: target?.filters || [],\n metricKind: target?.metricKind || MetricKind.GAUGE,\n query: '',\n crossSeriesReducer: 'REDUCE_NONE',\n perSeriesAligner: AlignmentTypes.ALIGN_NONE,\n title: target?.title || '',\n text: target?.text || '',\n },\n },\n };\n return result;\n },\n prepareQuery: (anno: AnnotationQuery<CloudMonitoringQuery>) => {\n if (!anno.target) {\n return undefined;\n }\n\n return {\n ...anno.target,\n queryType: QueryType.METRICS,\n type: 'annotationQuery',\n metricQuery: {\n ...anno.target.metricQuery,\n },\n };\n },\n QueryEditor: AnnotationQueryEditor,\n };\n};\n","import { DataSourcePlugin } from '@grafana/data';\n\nimport CloudMonitoringCheatSheet from './components/CloudMonitoringCheatSheet';\nimport { ConfigEditor } from './components/ConfigEditor/ConfigEditor';\nimport { QueryEditor } from './components/QueryEditor';\nimport { CloudMonitoringVariableQueryEditor } from './components/VariableQueryEditor';\nimport CloudMonitoringDatasource from './datasource';\nimport { CloudMonitoringQuery } from './types';\n\nexport const plugin = new DataSourcePlugin<CloudMonitoringDatasource, CloudMonitoringQuery>(CloudMonitoringDatasource)\n .setQueryEditorHelp(CloudMonitoringCheatSheet)\n .setQueryEditor(QueryEditor)\n .setConfigEditor(ConfigEditor)\n .setVariableQueryEditor(CloudMonitoringVariableQueryEditor);\n"],"names":["CloudMonitoringCheatSheet","PureComponent","render","className","css","ConfigEditor","ConnectionConfig","this","props","CloudMonitoringVariableQueryEditor","constructor","super","value","MetricFindQueryTypes","label","selectedQueryType","queryTypes","metricDescriptors","selectedService","selectedMetricType","labels","labelKey","metricTypes","services","sloServices","selectedSLOService","projects","projectName","loading","queryModel","state","onChange","refId","Object","assign","defaults","datasource","getDefaultProject","query","getProjects","getMetricTypes","extractServicesFromMetricDescriptors","map","m","service","serviceShortName","some","s","getTemplateSrv","replace","length","getSLOServices","getLabels","setState","onPropsChange","queryType","metricType","onLabelKeyChange","componentDidUpdate","prevProps","prevState","selecQueryTypeChanged","selectSLOServiceChanged","result","getLabelKeys","l","renderQueryTypeSwitch","variableOptionGroup","expanded","options","getVariables","v","name","allowCustomValue","onProjectChange","onServiceChange","onMetricTypeChange","onQueryTypeChange","AnnotationQueryEditor","onRunQuery","data","meta","series","customMetaData","custom","metricQuery","editorMode","EditorMode","filters","metricKind","MetricKind","valueType","title","text","variableOptions","crossSeriesReducer","perSeriesAligner","AlignmentTypes","alignmentPeriod","defaultQuery","setTitle","useState","setText","toOption","useDebounce","MetricQueryEditor","htmlFor","Input","id","width","INPUT_WIDTH","e","target","CloudMonitoringMetricFindQuery","handleProjectsQuery","handleServiceQuery","handleMetricTypesQuery","handleLabelKeysQuery","handleLabelValuesQuery","handleResourceTypeQuery","handleAlignersQuery","handleAlignmentPeriodQuery","handleAggregationQuery","handleSLOServicesQuery","handleSLOQuery","handleSelectorQuery","error","console","expandable","getMetricTypesByService","templateSrv","displayName","type","toFindQueryResult","groupBys","interpolatedKey","hasOwnProperty","descriptor","find","getAlignmentOptionsByMetric","getAggregationOptionsByMetric","getServiceLevelObjectives","SELECTORS","ALIGNMENT_PERIODS","x","isString","CloudMonitoringVariableSupport","CustomVariableSupport","metricFindQuery","bind","request","executeObservable","from","execute","targets","ensureGCEDefaultProject","pipe","mergeMap","CloudMonitoringDatasource","DataSourceWithBackend","instanceSettings","timeSrv","getTimeSrv","ds","authenticationType","jsonData","variables","intervalMs","annotations","prepareAnnotation","undefined","isLegacyCloudMonitoringAnnotation","enable","iconColor","QueryType","prepareQuery","anno","QueryEditor","t","migrateQuery","applyTemplateVariables","scopedVars","sloQuery","getRef","interpolateProps","interpolateFilters","interpolateGroupBys","view","aggregation","range","timeRange","queries","lastValueFrom","getBackendSrv","fetch","url","method","valueOf","toString","to","dataQueryResponse","toDataQueryResponse","f","filter","p","reduce","acc","key","Set","add","fromEntries","entries","Array","of","results","getResource","defaultProject","gceDefaultProject","getGCEDefaultProject","serviceId","Promise","resolve","hide","rest","object","filterQuery","selectorName","sloId","interpolateVariablesInQueries","completeFilter","chunk","operator","condition","item","flatten","isArray","join","interpolatedGroupBys","forEach","gb","interpolated","split","concat","push","plugin","DataSourcePlugin","setQueryEditorHelp","setQueryEditor","setConfigEditor","setVariableQueryEditor"],"sourceRoot":""}