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AAYlD,UAAUqD,GAC9B,OAAO,WAAc,OAAOC,EAAE7C,iBAC/B,CAACyC,IACG7R","sources":["webpack://grafana/./public/app/features/alerting/unified/components/rule-viewer/RuleViewerVisualization.tsx","webpack://grafana/./public/app/features/alerting/unified/components/rules/RuleDetailsFederatedSources.tsx","webpack://grafana/./public/app/features/alerting/unified/utils/query.ts","webpack://grafana/./public/app/features/alerting/unified/RuleViewer.tsx","webpack://grafana/./public/app/features/alerting/unified/components/Authorize.tsx","webpack://grafana/./public/app/features/alerting/unified/components/PanelPluginsButtonGroup.tsx","webpack://grafana/./public/app/features/alerting/unified/components/rule-viewer/RuleViewerLayout.tsx","webpack://grafana/./public/app/features/alerting/unified/hooks/useAlertQueriesStatus.ts","webpack://grafana/./public/app/features/alerting/unified/hooks/useCombinedRule.ts","webpack://grafana/./public/app/features/alerting/unified/utils/timeRange.ts","webpack://grafana/./public/app/features/alerting/unified/state/AlertingQueryRunner.ts","webpack://grafana/./public/app/features/expressions/guards.ts","webpack://grafana/./.yarn/__virtual__/react-use-virtual-00326e70ba/3/opt/drone/yarncache/react-use-npm-17.3.2-a032cbeb01-7379460f51.zip/node_modules/react-use/esm/useObservable.js"],"sourcesContent":["import { css } from '@emotion/css';\nimport React, { useCallback, useState } from 'react';\nimport AutoSizer from 'react-virtualized-auto-sizer';\n\nimport { DataSourceInstanceSettings, DateTime, dateTime, GrafanaTheme2, PanelData, urlUtil } from '@grafana/data';\nimport { config, getDataSourceSrv, PanelRenderer } from '@grafana/runtime';\nimport { Alert, CodeEditor, DateTimePicker, LinkButton, useStyles2, useTheme2 } from '@grafana/ui';\nimport { isExpressionQuery } from 'app/features/expressions/guards';\nimport { PanelOptions } from 'app/plugins/panel/table/models.gen';\nimport { AccessControlAction } from 'app/types';\nimport { AlertQuery } from 'app/types/unified-alerting-dto';\n\nimport { TABLE, TIMESERIES } from '../../utils/constants';\nimport { Authorize } from '../Authorize';\nimport { PanelPluginsButtonGroup, SupportedPanelPlugins } from '../PanelPluginsButtonGroup';\n\ntype RuleViewerVisualizationProps = {\n data?: PanelData;\n query: AlertQuery;\n onChangeQuery: (query: AlertQuery) => void;\n};\n\nconst headerHeight = 4;\n\nexport function RuleViewerVisualization(props: RuleViewerVisualizationProps): JSX.Element | null {\n const theme = useTheme2();\n const styles = useStyles2(getStyles);\n const { data, query, onChangeQuery } = props;\n const defaultPanel = isExpressionQuery(query.model) ? TABLE : TIMESERIES;\n const [panel, setPanel] = useState(defaultPanel);\n const dsSettings = getDataSourceSrv().getInstanceSettings(query.datasourceUid);\n const relativeTimeRange = query.relativeTimeRange;\n const [options, setOptions] = useState({\n frameIndex: 0,\n showHeader: true,\n });\n\n const onTimeChange = useCallback(\n (newDateTime: DateTime) => {\n const now = dateTime().unix() - newDateTime.unix();\n\n if (relativeTimeRange) {\n const interval = relativeTimeRange.from - relativeTimeRange.to;\n onChangeQuery({\n ...query,\n relativeTimeRange: { from: now + interval, to: now },\n });\n }\n },\n [onChangeQuery, query, relativeTimeRange]\n );\n\n const setDateTime = useCallback((relativeTimeRangeTo: number) => {\n return relativeTimeRangeTo === 0 ? dateTime() : dateTime().subtract(relativeTimeRangeTo, 'seconds');\n }, []);\n\n if (!data) {\n return null;\n }\n\n if (!dsSettings) {\n return (\n
\n \n \n
\n );\n }\n\n return (\n
\n \n {({ width, height }) => {\n return (\n
\n
\n
\n {`Query ${query.refId}`}\n ({dsSettings.name})\n
\n
\n {!isExpressionQuery(query.model) && relativeTimeRange ? (\n \n ) : null}\n \n \n {!isExpressionQuery(query.model) && (\n <>\n
\n \n View in Explore\n \n \n )}\n \n
\n
\n \n
\n );\n }}\n \n
\n );\n}\n\nfunction createExploreLink(settings: DataSourceInstanceSettings, query: AlertQuery): string {\n const { name } = settings;\n const { refId, ...rest } = query.model;\n const queryParams = { ...rest, datasource: name };\n\n return urlUtil.renderUrl(`${config.appSubUrl}/explore`, {\n left: JSON.stringify(['now-1h', 'now', name, queryParams]),\n });\n}\n\nconst getStyles = (theme: GrafanaTheme2) => {\n return {\n content: css`\n width: 100%;\n height: 250px;\n `,\n header: css`\n height: ${theme.spacing(headerHeight)};\n display: flex;\n align-items: center;\n justify-content: space-between;\n white-space: nowrap;\n `,\n refId: css`\n font-weight: ${theme.typography.fontWeightMedium};\n color: ${theme.colors.text.link};\n overflow: hidden;\n `,\n dataSource: css`\n margin-left: ${theme.spacing(1)};\n font-style: italic;\n color: ${theme.colors.text.secondary};\n `,\n actions: css`\n display: flex;\n align-items: center;\n `,\n spacing: css`\n padding: ${theme.spacing(0, 1, 0, 0)};\n `,\n errorMessage: css`\n white-space: pre-wrap;\n `,\n };\n};\n","import React, { FC } from 'react';\n\nimport { CombinedRuleGroup } from 'app/types/unified-alerting';\n\nimport { DetailsField } from '../DetailsField';\n\ninterface Props {\n group: CombinedRuleGroup;\n}\n\nconst RuleDetailsFederatedSources: FC = ({ group }) => {\n const sourceTenants = group.source_tenants ?? [];\n\n return (\n \n <>\n {sourceTenants.map((tenant) => (\n
{tenant}
\n ))}\n \n
\n );\n};\n\nexport { RuleDetailsFederatedSources };\n","import { DataQuery, DataSourceInstanceSettings } from '@grafana/data';\nimport { LokiQuery } from 'app/plugins/datasource/loki/types';\nimport { PromQuery } from 'app/plugins/datasource/prometheus/types';\nimport { CombinedRule } from 'app/types/unified-alerting';\nimport { AlertQuery } from 'app/types/unified-alerting-dto';\n\nimport { isCloudRulesSource, isGrafanaRulesSource } from './datasource';\nimport { isGrafanaRulerRule } from './rules';\n\nexport function alertRuleToQueries(combinedRule: CombinedRule | undefined | null): AlertQuery[] {\n if (!combinedRule) {\n return [];\n }\n const { namespace, rulerRule } = combinedRule;\n const { rulesSource } = namespace;\n\n if (isGrafanaRulesSource(rulesSource)) {\n if (isGrafanaRulerRule(rulerRule)) {\n return rulerRule.grafana_alert.data;\n }\n }\n\n if (isCloudRulesSource(rulesSource)) {\n const model = cloudAlertRuleToModel(rulesSource, combinedRule);\n\n return [\n {\n refId: model.refId,\n datasourceUid: rulesSource.uid,\n queryType: '',\n model,\n relativeTimeRange: {\n from: 360,\n to: 0,\n },\n },\n ];\n }\n\n return [];\n}\n\nfunction cloudAlertRuleToModel(dsSettings: DataSourceInstanceSettings, rule: CombinedRule): DataQuery {\n const refId = 'A';\n\n switch (dsSettings.type) {\n case 'prometheus': {\n const query: PromQuery = {\n refId,\n expr: rule.query,\n };\n\n return query;\n }\n\n case 'loki': {\n const query: LokiQuery = {\n refId,\n expr: rule.query,\n };\n\n return query;\n }\n\n default:\n throw new Error(`Query for datasource type ${dsSettings.type} is currently not supported by cloud alert rules.`);\n }\n}\n","import { css } from '@emotion/css';\nimport React, { useCallback, useEffect, useMemo, useState } from 'react';\nimport { useObservable } from 'react-use';\n\nimport { GrafanaTheme2, LoadingState, PanelData } from '@grafana/data';\nimport {\n Alert,\n Button,\n Icon,\n LoadingPlaceholder,\n PanelChromeLoadingIndicator,\n useStyles2,\n VerticalGroup,\n withErrorBoundary,\n} from '@grafana/ui';\nimport { GrafanaRouteComponentProps } from 'app/core/navigation/types';\n\nimport { AlertQuery } from '../../../types/unified-alerting-dto';\n\nimport { AlertLabels } from './components/AlertLabels';\nimport { DetailsField } from './components/DetailsField';\nimport { RuleViewerLayout, RuleViewerLayoutContent } from './components/rule-viewer/RuleViewerLayout';\nimport { RuleViewerVisualization } from './components/rule-viewer/RuleViewerVisualization';\nimport { RuleDetailsActionButtons } from './components/rules/RuleDetailsActionButtons';\nimport { RuleDetailsAnnotations } from './components/rules/RuleDetailsAnnotations';\nimport { RuleDetailsDataSources } from './components/rules/RuleDetailsDataSources';\nimport { RuleDetailsExpression } from './components/rules/RuleDetailsExpression';\nimport { RuleDetailsFederatedSources } from './components/rules/RuleDetailsFederatedSources';\nimport { RuleDetailsMatchingInstances } from './components/rules/RuleDetailsMatchingInstances';\nimport { RuleHealth } from './components/rules/RuleHealth';\nimport { RuleState } from './components/rules/RuleState';\nimport { useAlertQueriesStatus } from './hooks/useAlertQueriesStatus';\nimport { useCombinedRule } from './hooks/useCombinedRule';\nimport { AlertingQueryRunner } from './state/AlertingQueryRunner';\nimport { getRulesSourceByName } from './utils/datasource';\nimport { alertRuleToQueries } from './utils/query';\nimport * as ruleId from './utils/rule-id';\nimport { isFederatedRuleGroup } from './utils/rules';\n\ntype RuleViewerProps = GrafanaRouteComponentProps<{ id?: string; sourceName?: string }>;\n\nconst errorMessage = 'Could not find data source for rule';\nconst errorTitle = 'Could not view rule';\nconst pageTitle = 'Alerting / View rule';\n\nexport function RuleViewer({ match }: RuleViewerProps) {\n const styles = useStyles2(getStyles);\n const { id } = match.params;\n const identifier = ruleId.tryParse(id, true);\n\n const { loading, error, result: rule } = useCombinedRule(identifier, identifier?.ruleSourceName);\n const runner = useMemo(() => new AlertingQueryRunner(), []);\n const data = useObservable(runner.get());\n const queries2 = useMemo(() => alertRuleToQueries(rule), [rule]);\n const [queries, setQueries] = useState([]);\n\n const { allDataSourcesAvailable } = useAlertQueriesStatus(queries2);\n\n const onRunQueries = useCallback(() => {\n if (queries.length > 0 && allDataSourcesAvailable) {\n runner.run(queries);\n }\n }, [queries, runner, allDataSourcesAvailable]);\n\n useEffect(() => {\n setQueries(queries2);\n }, [queries2]);\n\n useEffect(() => {\n if (allDataSourcesAvailable) {\n onRunQueries();\n }\n }, [onRunQueries, allDataSourcesAvailable]);\n\n useEffect(() => {\n return () => runner.destroy();\n }, [runner]);\n\n const onChangeQuery = useCallback((query: AlertQuery) => {\n setQueries((queries) =>\n queries.map((q) => {\n if (q.refId === query.refId) {\n return query;\n }\n return q;\n })\n );\n }, []);\n\n if (!identifier?.ruleSourceName) {\n return (\n \n \n
{errorMessage}
\n
\n
\n );\n }\n\n const rulesSource = getRulesSourceByName(identifier.ruleSourceName);\n\n if (loading) {\n return (\n \n \n \n );\n }\n\n if (error || !rulesSource) {\n return (\n \n \n
\n {error?.message ?? errorMessage}\n
\n {!!error?.stack && error.stack}\n
\n
\n
\n );\n }\n\n if (!rule) {\n return (\n \n Rule could not be found.\n \n );\n }\n\n const annotations = Object.entries(rule.annotations).filter(([_, value]) => !!value.trim());\n const isFederatedRule = isFederatedRuleGroup(rule.group);\n\n return (\n \n {isFederatedRule && (\n \n \n Federated rule groups are currently an experimental feature.\n \n \n \n )}\n \n
\n

\n {rule.name}\n

\n \n \n
\n
\n
\n {rule.promRule && (\n \n \n \n )}\n {!!rule.labels && !!Object.keys(rule.labels).length && (\n \n \n \n )}\n \n \n
\n
\n \n {isFederatedRule && }\n {`${rule.namespace.name} / ${rule.group.name}`}\n
\n
\n
\n \n
\n
\n {!isFederatedRule && data && Object.keys(data).length > 0 && (\n <>\n
\n Query results runner.cancel()} />\n
\n \n
\n {queries.map((query) => {\n return (\n
\n \n
\n );\n })}\n
\n
\n \n )}\n {!isFederatedRule && !allDataSourcesAvailable && (\n \n Cannot display the query preview. Some of the data sources used in the queries are not available.\n \n )}\n
\n );\n}\n\nfunction isLoading(data: Record): boolean {\n return !!Object.values(data).find((d) => d.state === LoadingState.Loading);\n}\n\nconst getStyles = (theme: GrafanaTheme2) => {\n return {\n errorMessage: css`\n white-space: pre-wrap;\n `,\n queries: css`\n height: 100%;\n width: 100%;\n `,\n queriesTitle: css`\n padding: ${theme.spacing(2, 0.5)};\n font-size: ${theme.typography.h5.fontSize};\n font-weight: ${theme.typography.fontWeightBold};\n font-family: ${theme.typography.h5.fontFamily};\n `,\n query: css`\n border-bottom: 1px solid ${theme.colors.border.medium};\n padding: ${theme.spacing(2)};\n `,\n queryWarning: css`\n margin: ${theme.spacing(4, 0)};\n `,\n details: css`\n display: flex;\n flex-direction: row;\n `,\n leftSide: css`\n flex: 1;\n `,\n rightSide: css`\n padding-left: 90px;\n width: 300px;\n `,\n };\n};\n\nexport default withErrorBoundary(RuleViewer, { style: 'page' });\n","import React, { FC } from 'react';\n\nimport { contextSrv } from 'app/core/services/context_srv';\nimport { AccessControlAction } from 'app/types';\n\ntype Props = {\n actions: AccessControlAction[];\n fallback?: boolean;\n};\n\nexport const Authorize: FC = ({ actions, children, fallback = true }) => {\n if (actions.some((action) => contextSrv.hasAccess(action, fallback))) {\n return <>{children};\n } else {\n return null;\n }\n};\n","import React, { useMemo } from 'react';\n\nimport { SelectableValue } from '@grafana/data';\nimport { config } from '@grafana/runtime';\nimport { RadioButtonGroup } from '@grafana/ui';\n\nimport { STAT, TABLE, TIMESERIES } from '../utils/constants';\n\nexport type SupportedPanelPlugins = 'timeseries' | 'table' | 'stat';\n\ntype Props = {\n value: SupportedPanelPlugins;\n onChange: (value: SupportedPanelPlugins) => void;\n size?: 'sm' | 'md';\n};\n\nexport function PanelPluginsButtonGroup(props: Props): JSX.Element | null {\n const { value, onChange, size = 'md' } = props;\n const panels = useMemo(() => getSupportedPanels(), []);\n\n return ;\n}\n\nfunction getSupportedPanels(): Array> {\n return Object.values(config.panels).reduce((panels: Array>, panel) => {\n if (isSupportedPanelPlugin(panel.id)) {\n panels.push({\n value: panel.id,\n label: panel.name,\n imgUrl: panel.info.logos.small,\n });\n }\n return panels;\n }, []);\n}\n\nfunction isSupportedPanelPlugin(id: string): id is SupportedPanelPlugins {\n switch (id) {\n case TIMESERIES:\n case TABLE:\n case STAT:\n return true;\n default:\n return false;\n }\n}\n","import { css } from '@emotion/css';\nimport React from 'react';\n\nimport { GrafanaTheme2 } from '@grafana/data';\nimport { locationService } from '@grafana/runtime';\nimport { PageToolbar, useStyles2 } from '@grafana/ui';\nimport { Page } from 'app/core/components/Page/Page';\n\ntype Props = {\n children: React.ReactNode | React.ReactNode[];\n title: string;\n wrapInContent?: boolean;\n};\n\nexport function RuleViewerLayout(props: Props): JSX.Element | null {\n const { wrapInContent = true, children, title } = props;\n const styles = useStyles2(getPageStyles);\n\n return (\n \n locationService.push('/alerting/list')} />\n
{wrapInContent ? : children}
\n
\n );\n}\n\ntype ContentProps = {\n children: React.ReactNode | React.ReactNode[];\n padding?: number;\n};\n\nexport function RuleViewerLayoutContent({ children, padding = 2 }: ContentProps): JSX.Element | null {\n const styles = useStyles2(getContentStyles(padding));\n return
{children}
;\n}\n\nconst getPageStyles = (theme: GrafanaTheme2) => {\n return {\n content: css`\n margin: ${theme.spacing(0, 2, 2)};\n max-width: ${theme.breakpoints.values.xxl}px;\n `,\n };\n};\n\nconst getContentStyles = (padding: number) => (theme: GrafanaTheme2) => {\n return {\n wrapper: css`\n background: ${theme.colors.background.primary};\n border: 1px solid ${theme.colors.border.weak};\n border-radius: ${theme.shape.borderRadius()};\n padding: ${theme.spacing(padding)};\n `,\n };\n};\n","import { useMemo } from 'react';\n\nimport { getDataSourceSrv } from '@grafana/runtime';\nimport { AlertQuery } from 'app/types/unified-alerting-dto';\n\nexport function useAlertQueriesStatus(queries: AlertQuery[]) {\n const allDataSourcesAvailable = useMemo(\n () => queries.every((query) => Boolean(getDataSourceSrv().getInstanceSettings(query.datasourceUid))),\n [queries]\n );\n\n return { allDataSourcesAvailable };\n}\n","import { useMemo } from 'react';\nimport { useDispatch } from 'react-redux';\nimport { useAsync } from 'react-use';\n\nimport { CombinedRule, RuleIdentifier, RuleNamespace } from 'app/types/unified-alerting';\nimport { RulerRulesConfigDTO } from 'app/types/unified-alerting-dto';\n\nimport { fetchPromAndRulerRulesAction } from '../state/actions';\nimport { AsyncRequestMapSlice, AsyncRequestState, initialAsyncRequestState } from '../utils/redux';\nimport * as ruleId from '../utils/rule-id';\nimport { isRulerNotSupportedResponse } from '../utils/rules';\n\nimport { useCombinedRuleNamespaces } from './useCombinedRuleNamespaces';\nimport { useUnifiedAlertingSelector } from './useUnifiedAlertingSelector';\n\nexport function useCombinedRule(\n identifier: RuleIdentifier | undefined,\n ruleSourceName: string | undefined\n): AsyncRequestState {\n const requestState = useCombinedRulesLoader(ruleSourceName);\n const combinedRules = useCombinedRuleNamespaces(ruleSourceName);\n\n const rule = useMemo(() => {\n if (!identifier || !ruleSourceName || combinedRules.length === 0) {\n return;\n }\n\n for (const namespace of combinedRules) {\n for (const group of namespace.groups) {\n for (const rule of group.rules) {\n const id = ruleId.fromCombinedRule(ruleSourceName, rule);\n\n if (ruleId.equal(id, identifier)) {\n return rule;\n }\n }\n }\n }\n\n return;\n }, [identifier, ruleSourceName, combinedRules]);\n\n return {\n ...requestState,\n result: rule,\n };\n}\n\nexport function useCombinedRulesMatching(\n ruleName: string | undefined,\n ruleSourceName: string | undefined\n): AsyncRequestState {\n const requestState = useCombinedRulesLoader(ruleSourceName);\n const combinedRules = useCombinedRuleNamespaces(ruleSourceName);\n\n const rules = useMemo(() => {\n if (!ruleName || !ruleSourceName || combinedRules.length === 0) {\n return [];\n }\n\n const rules: CombinedRule[] = [];\n\n for (const namespace of combinedRules) {\n for (const group of namespace.groups) {\n for (const rule of group.rules) {\n if (rule.name === ruleName) {\n rules.push(rule);\n }\n }\n }\n }\n\n return rules;\n }, [ruleName, ruleSourceName, combinedRules]);\n\n return {\n ...requestState,\n result: rules,\n };\n}\n\nfunction useCombinedRulesLoader(rulesSourceName: string | undefined): AsyncRequestState {\n const dispatch = useDispatch();\n const promRuleRequests = useUnifiedAlertingSelector((state) => state.promRules);\n const promRuleRequest = getRequestState(rulesSourceName, promRuleRequests);\n const rulerRuleRequests = useUnifiedAlertingSelector((state) => state.rulerRules);\n const rulerRuleRequest = getRequestState(rulesSourceName, rulerRuleRequests);\n\n const { loading } = useAsync(async () => {\n if (!rulesSourceName) {\n return;\n }\n\n await dispatch(fetchPromAndRulerRulesAction({ rulesSourceName }));\n }, [dispatch, rulesSourceName]);\n\n return {\n loading,\n error: promRuleRequest.error ?? isRulerNotSupportedResponse(rulerRuleRequest) ? undefined : rulerRuleRequest.error,\n dispatched: promRuleRequest.dispatched && rulerRuleRequest.dispatched,\n };\n}\n\nfunction getRequestState(\n ruleSourceName: string | undefined,\n slice: AsyncRequestMapSlice\n): AsyncRequestState {\n if (!ruleSourceName) {\n return initialAsyncRequestState;\n }\n\n const state = slice[ruleSourceName];\n\n if (!state) {\n return initialAsyncRequestState;\n }\n\n return state;\n}\n","import { RelativeTimeRange } from '@grafana/data';\nimport { AlertQuery } from 'app/types/unified-alerting-dto';\n\nimport { ExpressionQuery, ExpressionQueryType } from '../../../expressions/types';\n\nconst FALL_BACK_TIME_RANGE = { from: 21600, to: 0 };\n\nexport const getTimeRangeForExpression = (query: ExpressionQuery, queries: AlertQuery[]): RelativeTimeRange => {\n const referencedRefIds: string[] | undefined = getReferencedIds(query, queries);\n\n if (!referencedRefIds) {\n return FALL_BACK_TIME_RANGE;\n }\n\n const { from, to } = getTimeRanges(referencedRefIds, queries);\n\n if (!from.length && !to.length) {\n return FALL_BACK_TIME_RANGE;\n }\n\n return {\n from: Math.max(...from),\n to: Math.min(...to),\n };\n};\n\nconst getReferencedIds = (model: ExpressionQuery, queries: AlertQuery[]): string[] | undefined => {\n switch (model.type) {\n case ExpressionQueryType.classic:\n return getReferencedIdsForClassicCondition(model);\n case ExpressionQueryType.math:\n return getReferencedIdsForMath(model, queries);\n case ExpressionQueryType.resample:\n case ExpressionQueryType.reduce:\n return getReferencedIdsForReduce(model);\n }\n};\n\nconst getReferencedIdsForClassicCondition = (model: ExpressionQuery) => {\n return model.conditions?.map((condition) => {\n return condition.query.params[0];\n });\n};\n\nconst getTimeRanges = (referencedRefIds: string[], queries: AlertQuery[]) => {\n let from: number[] = [];\n let to = [FALL_BACK_TIME_RANGE.to];\n for (const referencedRefIdsKey of referencedRefIds) {\n const query = queries.find((query) => query.refId === referencedRefIdsKey);\n\n if (!query || !query.relativeTimeRange) {\n continue;\n }\n from.push(query.relativeTimeRange.from);\n to.push(query.relativeTimeRange.to);\n }\n\n return {\n from,\n to,\n };\n};\n\nconst getReferencedIdsForMath = (model: ExpressionQuery, queries: AlertQuery[]) => {\n return (\n queries\n // filter queries of type query and filter expression on if it includes any refIds\n .filter((q) => q.queryType === 'query' && model.expression?.includes(q.refId))\n .map((q) => {\n return q.refId;\n })\n );\n};\n\nconst getReferencedIdsForReduce = (model: ExpressionQuery) => {\n return model.expression ? [model.expression] : undefined;\n};\n","import { Observable, of, OperatorFunction, ReplaySubject, Unsubscribable } from 'rxjs';\nimport { catchError, map, share } from 'rxjs/operators';\nimport { v4 as uuidv4 } from 'uuid';\n\nimport {\n dataFrameFromJSON,\n DataFrameJSON,\n getDefaultTimeRange,\n LoadingState,\n PanelData,\n rangeUtil,\n TimeRange,\n withLoadingIndicator,\n} from '@grafana/data';\nimport { FetchResponse, getDataSourceSrv, toDataQueryError } from '@grafana/runtime';\nimport { BackendSrv, getBackendSrv } from 'app/core/services/backend_srv';\nimport { isExpressionQuery } from 'app/features/expressions/guards';\nimport { cancelNetworkRequestsOnUnsubscribe } from 'app/features/query/state/processing/canceler';\nimport { setStructureRevision } from 'app/features/query/state/processing/revision';\nimport { preProcessPanelData } from 'app/features/query/state/runRequest';\nimport { AlertQuery } from 'app/types/unified-alerting-dto';\n\nimport { getTimeRangeForExpression } from '../utils/timeRange';\n\nexport interface AlertingQueryResult {\n frames: DataFrameJSON[];\n}\n\nexport interface AlertingQueryResponse {\n results: Record;\n}\nexport class AlertingQueryRunner {\n private subject: ReplaySubject>;\n private subscription?: Unsubscribable;\n private lastResult: Record;\n\n constructor(private backendSrv = getBackendSrv(), private dataSourceSrv = getDataSourceSrv()) {\n this.subject = new ReplaySubject(1);\n this.lastResult = {};\n }\n\n get(): Observable> {\n return this.subject.asObservable();\n }\n\n async run(queries: AlertQuery[]) {\n if (queries.length === 0) {\n const empty = initialState(queries, LoadingState.Done);\n return this.subject.next(empty);\n }\n\n // do not execute if one more of the queries are not runnable,\n // for example not completely configured\n for (const query of queries) {\n if (!isExpressionQuery(query.model)) {\n const ds = await this.dataSourceSrv.get(query.datasourceUid);\n if (ds.filterQuery && !ds.filterQuery(query.model)) {\n const empty = initialState(queries, LoadingState.Done);\n return this.subject.next(empty);\n }\n }\n }\n\n this.subscription = runRequest(this.backendSrv, queries).subscribe({\n next: (dataPerQuery) => {\n const nextResult = applyChange(dataPerQuery, (refId, data) => {\n const previous = this.lastResult[refId];\n const preProcessed = preProcessPanelData(data, previous);\n return setStructureRevision(preProcessed, previous);\n });\n\n this.lastResult = nextResult;\n this.subject.next(this.lastResult);\n },\n\n error: (error: Error) => {\n this.lastResult = mapErrorToPanelData(this.lastResult, error);\n this.subject.next(this.lastResult);\n },\n });\n }\n\n cancel() {\n if (!this.subscription) {\n return;\n }\n this.subscription.unsubscribe();\n\n let requestIsRunning = false;\n\n const nextResult = applyChange(this.lastResult, (refId, data) => {\n if (data.state === LoadingState.Loading) {\n requestIsRunning = true;\n }\n\n return {\n ...data,\n state: LoadingState.Done,\n };\n });\n\n if (requestIsRunning) {\n this.subject.next(nextResult);\n }\n }\n\n destroy() {\n if (this.subject) {\n this.subject.complete();\n }\n\n this.cancel();\n }\n}\n\nconst runRequest = (backendSrv: BackendSrv, queries: AlertQuery[]): Observable> => {\n const initial = initialState(queries, LoadingState.Loading);\n const request = {\n data: { data: queries },\n url: '/api/v1/eval',\n method: 'POST',\n requestId: uuidv4(),\n };\n\n return withLoadingIndicator({\n whileLoading: initial,\n source: backendSrv.fetch(request).pipe(\n mapToPanelData(initial),\n catchError((error) => of(mapErrorToPanelData(initial, error))),\n cancelNetworkRequestsOnUnsubscribe(backendSrv, request.requestId),\n share()\n ),\n });\n};\n\nconst initialState = (queries: AlertQuery[], state: LoadingState): Record => {\n return queries.reduce((dataByQuery: Record, query) => {\n dataByQuery[query.refId] = {\n state,\n series: [],\n timeRange: getTimeRange(query, queries),\n };\n\n return dataByQuery;\n }, {});\n};\n\nconst getTimeRange = (query: AlertQuery, queries: AlertQuery[]): TimeRange => {\n if (isExpressionQuery(query.model)) {\n const relative = getTimeRangeForExpression(query.model, queries);\n return rangeUtil.relativeToTimeRange(relative);\n }\n\n if (!query.relativeTimeRange) {\n console.warn(`Query with refId: ${query.refId} did not have any relative time range, using default.`);\n return getDefaultTimeRange();\n }\n\n return rangeUtil.relativeToTimeRange(query.relativeTimeRange);\n};\n\nconst mapToPanelData = (\n dataByQuery: Record\n): OperatorFunction, Record> => {\n return map((response) => {\n const { data } = response;\n const results: Record = {};\n\n for (const [refId, result] of Object.entries(data.results)) {\n results[refId] = {\n timeRange: dataByQuery[refId].timeRange,\n state: LoadingState.Done,\n series: result.frames.map(dataFrameFromJSON),\n };\n }\n\n return results;\n });\n};\n\nconst mapErrorToPanelData = (lastResult: Record, error: Error): Record => {\n const queryError = toDataQueryError(error);\n\n return applyChange(lastResult, (refId, data) => {\n return {\n ...data,\n state: LoadingState.Error,\n error: queryError,\n };\n });\n};\n\nconst applyChange = (\n initial: Record,\n change: (refId: string, data: PanelData) => PanelData\n): Record => {\n const nextResult: Record = {};\n\n for (const [refId, data] of Object.entries(initial)) {\n nextResult[refId] = change(refId, data);\n }\n\n return nextResult;\n};\n","import { DataQuery } from '@grafana/data';\nimport { isExpressionReference } from '@grafana/runtime/src/utils/DataSourceWithBackend';\n\nimport { ExpressionQuery, ExpressionQueryType } from './types';\n\nexport const isExpressionQuery = (dataQuery?: DataQuery): dataQuery is ExpressionQuery => {\n if (!dataQuery) {\n return false;\n }\n\n if (isExpressionReference(dataQuery.datasource)) {\n return true;\n }\n\n const expression = dataQuery as ExpressionQuery;\n\n if (typeof expression.type !== 'string') {\n return false;\n }\n return Object.values(ExpressionQueryType).includes(expression.type);\n};\n","import { useState } from 'react';\nimport useIsomorphicLayoutEffect from './useIsomorphicLayoutEffect';\nfunction useObservable(observable$, initialValue) {\n var _a = useState(initialValue), value = _a[0], update = _a[1];\n useIsomorphicLayoutEffect(function () {\n var s = observable$.subscribe(update);\n return function () { return s.unsubscribe(); };\n }, [observable$]);\n return value;\n}\nexport default useObservable;\n"],"names":["RuleViewerVisualization","props","theme","useTheme2","styles","useStyles2","getStyles","data","query","onChangeQuery","defaultPanel","isExpressionQuery","model","TABLE","TIMESERIES","panel","setPanel","useState","dsSettings","getDataSourceSrv","getInstanceSettings","datasourceUid","relativeTimeRange","options","setOptions","frameIndex","showHeader","onTimeChange","useCallback","newDateTime","now","dateTime","unix","interval","from","to","setDateTime","relativeTimeRangeTo","subtract","className","content","width","height","style","header","refId","dataSource","name","actions","DateTimePicker","date","onChange","maxDate","Date","PanelPluginsButtonGroup","value","size","Authorize","AccessControlAction","spacing","LinkButton","variant","icon","target","href","createExploreLink","PanelRenderer","gridSize","pluginId","title","onOptionsChange","Alert","CodeEditor","language","showLineNumbers","showMiniMap","JSON","stringify","readOnly","settings","rest","queryParams","datasource","urlUtil","config","left","css","typography","fontWeightMedium","colors","text","link","secondary","errorMessage","RuleDetailsFederatedSources","group","sourceTenants","source_tenants","DetailsField","label","map","tenant","alertRuleToQueries","combinedRule","namespace","rulerRule","rulesSource","isGrafanaRulesSource","isGrafanaRulerRule","grafana_alert","isCloudRulesSource","rule","type","expr","Error","cloudAlertRuleToModel","uid","queryType","errorTitle","pageTitle","RuleViewer","match","id","params","identifier","ruleId","loading","error","result","useCombinedRule","ruleSourceName","runner","useMemo","AlertingQueryRunner","useObservable","get","queries2","queries","setQueries","allDataSourcesAvailable","useAlertQueriesStatus","onRunQueries","length","run","useEffect","destroy","q","RuleViewerLayout","getRulesSourceByName","LoadingPlaceholder","message","stack","annotations","Object","entries","filter","_","trim","isFederatedRule","isFederatedRuleGroup","wrapInContent","severity","VerticalGroup","Button","fill","Icon","RuleState","isCreating","isDeleting","RuleDetailsActionButtons","details","leftSide","promRule","horizontal","RuleHealth","labels","keys","AlertLabels","RuleDetailsExpression","RuleDetailsAnnotations","rightSide","RuleDetailsDataSources","RuleDetailsMatchingInstances","queriesTitle","PanelChromeLoadingIndicator","isLoading","onCancel","cancel","padding","queryWarning","values","find","d","state","LoadingState","h5","fontSize","fontWeightBold","fontFamily","border","medium","withErrorBoundary","children","fallback","some","action","contextSrv","panels","reduce","STAT","isSupportedPanelPlugin","push","imgUrl","info","logos","small","RadioButtonGroup","getPageStyles","PageToolbar","pageIcon","onGoBack","locationService","RuleViewerLayoutContent","getContentStyles","wrapper","breakpoints","xxl","background","primary","weak","shape","borderRadius","every","Boolean","requestState","useCombinedRulesLoader","combinedRules","useCombinedRuleNamespaces","groups","rules","useCombinedRulesMatching","ruleName","rulesSourceName","dispatch","useDispatch","promRuleRequests","useUnifiedAlertingSelector","promRules","promRuleRequest","getRequestState","rulerRuleRequests","rulerRules","rulerRuleRequest","useAsync","async","fetchPromAndRulerRulesAction","isRulerNotSupportedResponse","undefined","dispatched","slice","initialAsyncRequestState","FALL_BACK_TIME_RANGE","getReferencedIds","ExpressionQueryType","getReferencedIdsForClassicCondition","getReferencedIdsForMath","getReferencedIdsForReduce","conditions","condition","getTimeRanges","referencedRefIds","referencedRefIdsKey","expression","includes","constructor","backendSrv","getBackendSrv","dataSourceSrv","this","subject","ReplaySubject","lastResult","asObservable","empty","initialState","next","ds","filterQuery","subscription","runRequest","subscribe","dataPerQuery","nextResult","applyChange","previous","preProcessed","preProcessPanelData","setStructureRevision","mapErrorToPanelData","unsubscribe","requestIsRunning","complete","initial","request","url","method","requestId","uuidv4","withLoadingIndicator","whileLoading","source","fetch","pipe","mapToPanelData","catchError","of","cancelNetworkRequestsOnUnsubscribe","share","dataByQuery","series","timeRange","getTimeRange","relative","Math","max","min","getTimeRangeForExpression","rangeUtil","console","warn","getDefaultTimeRange","response","results","frames","dataFrameFromJSON","queryError","toDataQueryError","change","dataQuery","isExpressionReference","observable$","initialValue","_a","update","s"],"sourceRoot":""}