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X,EAAyBhC,GAAgC,UACzF,MAAM0G,GAAc/J,EAAAA,EAAAA,IAA4BC,GAAUA,EAAM8J,cAC1DwK,EAAYlR,IAAQc,EAAAA,EAAAA,IAAmBd,GAAQA,EAAKa,cAAcsQ,mBAAgB7N,EAElF8N,GAAiBC,EAAAA,EAAAA,IAAoBrP,IAErC,OAAEiP,EAAF,QAAU5U,IAAYsU,EAAAA,EAAAA,GAAUO,GAEtC,IAAKlR,EACH,MAAO,CAAEyC,YAAY,EAAOC,aAAa,EAAOrG,SAAS,GAM3D,IAAIyE,EAAAA,EAAAA,IAAmBd,GAAO,SAC5B,IAAKkR,EACH,MAAM,IAAIhD,MACP,QAAOlO,EAAKa,cAAczD,yEAO/B,MAAO,CACLqF,WAJ0BN,EAAAA,GAAAA,UAAqBiP,EAAeE,OAApC,UAA4CL,MAAAA,OAA5C,EAA4CA,EAAQM,eAApD,UAK1B7O,YAJ4BP,EAAAA,GAAAA,UAAqBiP,EAAeI,OAApC,UAA4CP,MAAAA,OAA5C,EAA4CA,EAAQM,eAApD,UAK5BlV,QAAAA,GAKJ,MAAMoV,EAAmBC,QAAO,UAAChL,EAAY1E,UAAb,iBAAC,EAA8BzF,cAA/B,aAAC,EAAsCoV,aAIvE,MAAO,CACLlP,WAJwBN,EAAAA,GAAAA,UAAqBiP,EAAeE,OAAQnP,EAAAA,GAAAA,WAInCsP,EACjC/O,YAJ0BP,EAAAA,GAAAA,UAAqBiP,EAAeI,OAAQrP,EAAAA,GAAAA,WAIlCsP,EACpCpV,QAAO,UAAEqK,EAAY1E,UAAd,aAAE,EAA8B3F","sources":["webpack://grafana/./public/app/features/alerting/unified/components/alert-groups/MatcherFilter.tsx","webpack://grafana/./public/app/features/alerting/unified/components/rules/StateHistory.tsx","webpack://grafana/./public/app/features/alerting/unified/hooks/useManagedAlertStateHistory.ts","webpack://grafana/./public/app/features/alerting/unified/components/rules/RuleDetailsActionButtons.tsx","webpack://grafana/./public/app/features/alerting/unified/hooks/useStateHistoryModal.tsx","webpack://grafana/./public/app/features/alerting/unified/components/rules/RuleDetailsAnnotations.tsx","webpack://grafana/./public/app/features/alerting/unified/components/rules/RuleDetailsDataSources.tsx","webpack://grafana/./public/app/features/alerting/unified/components/Expression.tsx","webpack://grafana/./public/app/features/alerting/unified/components/rules/RuleDetailsExpression.tsx","webpack://grafana/./public/app/features/alerting/unified/components/rules/AlertInstanceStateFilter.tsx","webpack://grafana/./public/app/features/alerting/unified/components/rules/RuleDetailsMatchingInstances.tsx","webpack://grafana/./public/app/features/alerting/unified/components/rules/RuleHealth.tsx","webpack://grafana/./public/app/features/alerting/unified/components/rules/RuleState.tsx","webpack://grafana/./public/app/features/alerting/unified/hooks/useCombinedRuleNamespaces.ts","webpack://grafana/./public/app/features/alerting/unified/hooks/useFolder.ts","webpack://grafana/./public/app/features/alerting/unified/hooks/useIsRuleEditable.ts"],"sourcesContent":["import { css } from '@emotion/css';\nimport React, { FormEvent } from 'react';\n\nimport { GrafanaTheme2 } from '@grafana/data';\nimport { Stack } from '@grafana/experimental';\nimport { Label, Tooltip, Input, Icon, useStyles2 } from '@grafana/ui';\n\ninterface Props {\n className?: string;\n queryString?: string;\n defaultQueryString?: string;\n onFilterChange: (filterString: string) => void;\n}\n\nexport const MatcherFilter = ({ className, onFilterChange, defaultQueryString, queryString }: Props) => {\n const styles = useStyles2(getStyles);\n const handleSearchChange = (e: FormEvent) => {\n const target = e.target as HTMLInputElement;\n onFilterChange(target.value);\n };\n const searchIcon = ;\n return (\n
\n
\n }\n >\n \n \n \n \n \n \n );\n};\n\nconst getStyles = (theme: GrafanaTheme2) => ({\n icon: css`\n margin-right: ${theme.spacing(0.5)};\n `,\n inputWidth: css`\n width: 340px;\n flex-grow: 0;\n `,\n});\n","import { css } from '@emotion/css';\nimport { uniqueId } from 'lodash';\nimport React, { FC } from 'react';\n\nimport { AlertState, dateTimeFormat, GrafanaTheme } from '@grafana/data';\nimport { Alert, LoadingPlaceholder, useStyles } from '@grafana/ui';\nimport { StateHistoryItem, StateHistoryItemData } from 'app/types/unified-alerting';\nimport { GrafanaAlertStateWithReason, PromAlertingRuleState } from 'app/types/unified-alerting-dto';\n\nimport { useManagedAlertStateHistory } from '../../hooks/useManagedAlertStateHistory';\nimport { AlertLabel } from '../AlertLabel';\nimport { DynamicTable, DynamicTableColumnProps, DynamicTableItemProps } from '../DynamicTable';\n\nimport { AlertStateTag } from './AlertStateTag';\n\ntype StateHistoryRowItem = {\n id: string;\n state: PromAlertingRuleState | GrafanaAlertStateWithReason | AlertState;\n text?: string;\n data?: StateHistoryItemData;\n timestamp?: number;\n};\n\ntype StateHistoryRow = DynamicTableItemProps;\n\ninterface RuleStateHistoryProps {\n alertId: string;\n}\n\nconst StateHistory: FC = ({ alertId }) => {\n const { loading, error, result = [] } = useManagedAlertStateHistory(alertId);\n\n if (loading && !error) {\n return ;\n }\n\n if (error && !loading) {\n return {error.message};\n }\n\n const columns: Array> = [\n { id: 'state', label: 'State', size: 'max-content', renderCell: renderStateCell },\n { id: 'value', label: '', size: 'auto', renderCell: renderValueCell },\n { id: 'timestamp', label: 'Time', size: 'max-content', renderCell: renderTimestampCell },\n ];\n\n const items: StateHistoryRow[] = result\n .reduce((acc: StateHistoryRowItem[], item, index) => {\n acc.push({\n id: String(item.id),\n state: item.newState,\n text: item.text,\n data: item.data,\n timestamp: item.updated,\n });\n\n // if the preceding state is not the same, create a separate state entry – this likely means the state was reset\n if (!hasMatchingPrecedingState(index, result)) {\n acc.push({ id: uniqueId(), state: item.prevState });\n }\n\n return acc;\n }, [])\n .map((historyItem) => ({\n id: historyItem.id,\n data: historyItem,\n }));\n\n return ;\n};\n\nfunction renderValueCell(item: StateHistoryRow) {\n const matches = item.data.data?.evalMatches ?? [];\n\n return (\n <>\n {item.data.text}\n \n {matches.map((match) => (\n \n ))}\n \n \n );\n}\n\nfunction renderStateCell(item: StateHistoryRow) {\n return ;\n}\n\nfunction renderTimestampCell(item: StateHistoryRow) {\n return (\n
{item.data.timestamp && {dateTimeFormat(item.data.timestamp)}}
\n );\n}\n\nconst LabelsWrapper: FC<{}> = ({ children }) => {\n const { wrapper } = useStyles(getStyles);\n return
{children}
;\n};\n\nconst TimestampStyle = css`\n display: flex;\n align-items: flex-end;\n flex-direction: column;\n`;\n\nconst getStyles = (theme: GrafanaTheme) => ({\n wrapper: css`\n & > * {\n margin-right: ${theme.spacing.xs};\n }\n `,\n});\n\n// this function will figure out if a given historyItem has a preceding historyItem where the states match - in other words\n// the newState of the previous historyItem is the same as the prevState of the current historyItem\nfunction hasMatchingPrecedingState(index: number, items: StateHistoryItem[]): boolean {\n const currentHistoryItem = items[index];\n const previousHistoryItem = items[index + 1];\n\n if (!previousHistoryItem) {\n return false;\n }\n\n return previousHistoryItem.newState === currentHistoryItem.prevState;\n}\n\nexport { StateHistory };\n","import { useEffect } from 'react';\nimport { useDispatch } from 'react-redux';\n\nimport { StateHistoryItem } from 'app/types/unified-alerting';\n\nimport { fetchGrafanaAnnotationsAction } from '../state/actions';\nimport { AsyncRequestState } from '../utils/redux';\n\nimport { useUnifiedAlertingSelector } from './useUnifiedAlertingSelector';\n\nexport function useManagedAlertStateHistory(alertId: string) {\n const dispatch = useDispatch();\n const history = useUnifiedAlertingSelector>(\n (state) => state.managedAlertStateHistory\n );\n\n useEffect(() => {\n dispatch(fetchGrafanaAnnotationsAction(alertId));\n }, [dispatch, alertId]);\n\n return history;\n}\n","import { css } from '@emotion/css';\nimport React, { FC, Fragment, useState } from 'react';\nimport { useDispatch } from 'react-redux';\nimport { useLocation } from 'react-router-dom';\n\nimport { GrafanaTheme2, textUtil, urlUtil } from '@grafana/data';\nimport { config } from '@grafana/runtime';\nimport { Button, ClipboardButton, ConfirmModal, HorizontalGroup, LinkButton, useStyles2 } from '@grafana/ui';\nimport { useAppNotification } from 'app/core/copy/appNotification';\nimport { contextSrv } from 'app/core/services/context_srv';\nimport { AccessControlAction } from 'app/types';\nimport { CombinedRule, RulesSource } from 'app/types/unified-alerting';\nimport { RulerGrafanaRuleDTO, RulerRuleDTO } from 'app/types/unified-alerting-dto';\n\nimport { useIsRuleEditable } from '../../hooks/useIsRuleEditable';\nimport { useStateHistoryModal } from '../../hooks/useStateHistoryModal';\nimport { deleteRuleAction } from '../../state/actions';\nimport { getAlertmanagerByUid } from '../../utils/alertmanager';\nimport { Annotation } from '../../utils/constants';\nimport { getRulesSourceName, isCloudRulesSource, isGrafanaRulesSource } from '../../utils/datasource';\nimport { createExploreLink, createViewLink, makeRuleBasedSilenceLink } from '../../utils/misc';\nimport * as ruleId from '../../utils/rule-id';\nimport { isFederatedRuleGroup } from '../../utils/rules';\n\ninterface Props {\n rule: CombinedRule;\n rulesSource: RulesSource;\n}\n\nexport const RuleDetailsActionButtons: FC = ({ rule, rulesSource }) => {\n const dispatch = useDispatch();\n const location = useLocation();\n const notifyApp = useAppNotification();\n const style = useStyles2(getStyles);\n const { namespace, group, rulerRule } = rule;\n const [ruleToDelete, setRuleToDelete] = useState();\n const alertId = isGrafanaRulerRule(rule.rulerRule) ? rule.rulerRule.grafana_alert.id ?? '' : '';\n const { StateHistoryModal, showStateHistoryModal } = useStateHistoryModal(alertId);\n\n const alertmanagerSourceName = isGrafanaRulesSource(rulesSource)\n ? rulesSource\n : getAlertmanagerByUid(rulesSource.jsonData.alertmanagerUid)?.name;\n const rulesSourceName = getRulesSourceName(rulesSource);\n\n const hasExplorePermission = contextSrv.hasPermission(AccessControlAction.DataSourcesExplore);\n\n const leftButtons: JSX.Element[] = [];\n const rightButtons: JSX.Element[] = [];\n\n const isFederated = isFederatedRuleGroup(group);\n const { isEditable, isRemovable } = useIsRuleEditable(rulesSourceName, rulerRule);\n const returnTo = location.pathname + location.search;\n const isViewMode = inViewMode(location.pathname);\n\n const deleteRule = () => {\n if (ruleToDelete && ruleToDelete.rulerRule) {\n const identifier = ruleId.fromRulerRule(\n getRulesSourceName(ruleToDelete.namespace.rulesSource),\n ruleToDelete.namespace.name,\n ruleToDelete.group.name,\n ruleToDelete.rulerRule\n );\n\n dispatch(deleteRuleAction(identifier, { navigateTo: isViewMode ? '/alerting/list' : undefined }));\n setRuleToDelete(undefined);\n }\n };\n\n const buildShareUrl = () => {\n if (isCloudRulesSource(rulesSource)) {\n const { appUrl, appSubUrl } = config;\n const baseUrl = appSubUrl !== '' ? `${appUrl}${appSubUrl}/` : config.appUrl;\n const ruleUrl = `${encodeURIComponent(rulesSource.name)}/${encodeURIComponent(rule.name)}`;\n return `${baseUrl}alerting/${ruleUrl}/find`;\n }\n\n return window.location.href.split('?')[0];\n };\n\n // explore does not support grafana rule queries atm\n // neither do \"federated rules\"\n if (isCloudRulesSource(rulesSource) && hasExplorePermission && !isFederated) {\n leftButtons.push(\n \n See graph\n \n );\n }\n if (rule.annotations[Annotation.runbookURL]) {\n leftButtons.push(\n \n View runbook\n \n );\n }\n if (rule.annotations[Annotation.dashboardUID]) {\n const dashboardUID = rule.annotations[Annotation.dashboardUID];\n if (dashboardUID) {\n leftButtons.push(\n \n Go to dashboard\n \n );\n const panelId = rule.annotations[Annotation.panelID];\n if (panelId) {\n leftButtons.push(\n \n Go to panel\n \n );\n }\n }\n }\n\n if (alertmanagerSourceName && contextSrv.hasAccess(AccessControlAction.AlertingInstanceCreate, contextSrv.isEditor)) {\n leftButtons.push(\n \n Silence\n \n );\n }\n\n if (alertId) {\n leftButtons.push(\n \n \n {StateHistoryModal}\n \n );\n }\n\n if (!isViewMode) {\n rightButtons.push(\n \n View\n \n );\n }\n\n if (isEditable && rulerRule && !isFederated) {\n const sourceName = getRulesSourceName(rulesSource);\n const identifier = ruleId.fromRulerRule(sourceName, namespace.name, group.name, rulerRule);\n\n const editURL = urlUtil.renderUrl(\n `${config.appSubUrl}/alerting/${encodeURIComponent(ruleId.stringifyIdentifier(identifier))}/edit`,\n {\n returnTo,\n }\n );\n\n if (isViewMode) {\n rightButtons.push(\n {\n notifyApp.success('URL copied!');\n }}\n onClipboardError={(copiedText) => {\n notifyApp.error('Error while copying URL', copiedText);\n }}\n className={style.button}\n size=\"sm\"\n getText={buildShareUrl}\n >\n Copy link to rule\n \n );\n }\n\n rightButtons.push(\n \n Edit\n \n );\n }\n\n if (isRemovable && rulerRule && !isFederated) {\n rightButtons.push(\n setRuleToDelete(rule)}\n >\n Delete\n \n );\n }\n\n if (leftButtons.length || rightButtons.length) {\n return (\n <>\n
\n {leftButtons.length ? leftButtons :
}\n {rightButtons.length ? rightButtons :
}\n
\n {!!ruleToDelete && (\n setRuleToDelete(undefined)}\n />\n )}\n \n );\n }\n\n return null;\n};\n\nfunction inViewMode(pathname: string): boolean {\n return pathname.endsWith('/view');\n}\n\nexport const getStyles = (theme: GrafanaTheme2) => ({\n wrapper: css`\n padding: ${theme.spacing(2)} 0;\n display: flex;\n flex-direction: row;\n justify-content: space-between;\n flex-wrap: wrap;\n border-bottom: solid 1px ${theme.colors.border.medium};\n `,\n button: css`\n height: 24px;\n margin-top: ${theme.spacing(1)};\n font-size: ${theme.typography.size.sm};\n `,\n});\n\nfunction isGrafanaRulerRule(rule?: RulerRuleDTO): rule is RulerGrafanaRuleDTO {\n if (!rule) {\n return false;\n }\n return (rule as RulerGrafanaRuleDTO).grafana_alert != null;\n}\n","import React, { useMemo, useState } from 'react';\n\nimport { Modal } from '@grafana/ui';\n\nimport { StateHistory } from '../components/rules/StateHistory';\n\nfunction useStateHistoryModal(alertId: string) {\n const [showModal, setShowModal] = useState(false);\n\n const StateHistoryModal = useMemo(\n () => (\n setShowModal(false)}\n closeOnBackdropClick={true}\n closeOnEscape={true}\n title=\"State history\"\n >\n \n \n ),\n [alertId, showModal]\n );\n\n return {\n StateHistoryModal,\n showStateHistoryModal: () => setShowModal(true),\n hideStateHistoryModal: () => setShowModal(false),\n };\n}\n\nexport { useStateHistoryModal };\n","import { css } from '@emotion/css';\nimport React from 'react';\n\nimport { useStyles2 } from '@grafana/ui';\n\nimport { AnnotationDetailsField } from '../AnnotationDetailsField';\n\ntype Props = {\n annotations: Array<[string, string]>;\n};\n\nexport function RuleDetailsAnnotations(props: Props): JSX.Element | null {\n const { annotations } = props;\n const styles = useStyles2(getStyles);\n\n if (annotations.length === 0) {\n return null;\n }\n\n return (\n
\n {annotations.map(([key, value]) => (\n \n ))}\n
\n );\n}\n\nconst getStyles = () => ({\n annotations: css`\n margin-top: 46px;\n `,\n});\n","import { css } from '@emotion/css';\nimport React, { useMemo } from 'react';\n\nimport { GrafanaTheme2 } from '@grafana/data';\nimport { getDataSourceSrv } from '@grafana/runtime';\nimport { useStyles2 } from '@grafana/ui';\nimport { ExpressionDatasourceUID } from 'app/features/expressions/ExpressionDatasource';\nimport { CombinedRule, RulesSource } from 'app/types/unified-alerting';\n\nimport { isCloudRulesSource } from '../../utils/datasource';\nimport { isGrafanaRulerRule } from '../../utils/rules';\nimport { DetailsField } from '../DetailsField';\n\ntype Props = {\n rule: CombinedRule;\n rulesSource: RulesSource;\n};\n\nexport function RuleDetailsDataSources(props: Props): JSX.Element | null {\n const { rulesSource, rule } = props;\n const styles = useStyles2(getStyles);\n\n const dataSources: Array<{ name: string; icon?: string }> = useMemo(() => {\n if (isCloudRulesSource(rulesSource)) {\n return [{ name: rulesSource.name, icon: rulesSource.meta.info.logos.small }];\n }\n\n if (isGrafanaRulerRule(rule.rulerRule)) {\n const { data } = rule.rulerRule.grafana_alert;\n const unique = data.reduce((dataSources, query) => {\n const ds = getDataSourceSrv().getInstanceSettings(query.datasourceUid);\n\n if (!ds || ds.uid === ExpressionDatasourceUID) {\n return dataSources;\n }\n\n dataSources[ds.name] = { name: ds.name, icon: ds.meta.info.logos.small };\n return dataSources;\n }, {} as Record);\n\n return Object.values(unique);\n }\n\n return [];\n }, [rule, rulesSource]);\n\n if (dataSources.length === 0) {\n return null;\n }\n\n return (\n \n {dataSources.map(({ name, icon }, index) => (\n
\n {icon && (\n <>\n {`${name}{' '}\n \n )}\n {name}\n
\n ))}\n
\n );\n}\n\nfunction getStyles(theme: GrafanaTheme2) {\n const size = theme.spacing(2);\n\n return {\n dataSourceIcon: css`\n width: ${size};\n height: ${size};\n `,\n };\n}\n","import { css, cx } from '@emotion/css';\nimport { LanguageMap, languages as prismLanguages } from 'prismjs';\nimport React, { FC, useMemo } from 'react';\n\nimport { GrafanaTheme } from '@grafana/data';\nimport { Editor } from '@grafana/slate-react';\nimport { makeValue, SlatePrism, useStyles } from '@grafana/ui';\nimport LogqlSyntax from 'app/plugins/datasource/loki/syntax';\nimport PromqlSyntax from 'app/plugins/datasource/prometheus/promql';\nimport { RulesSource } from 'app/types/unified-alerting';\n\nimport { DataSourceType, isCloudRulesSource } from '../utils/datasource';\n\nimport { Well } from './Well';\n\ninterface Props {\n expression: string;\n rulesSource: RulesSource;\n}\n\nexport const HighlightedQuery: FC<{ language: 'promql' | 'logql'; expr: string }> = ({ language, expr }) => {\n const plugins = useMemo(\n () => [\n SlatePrism(\n {\n onlyIn: (node: any) => node.type === 'code_block',\n getSyntax: () => language,\n },\n { ...(prismLanguages as LanguageMap), [language]: language === 'logql' ? LogqlSyntax : PromqlSyntax }\n ),\n ],\n [language]\n );\n\n const slateValue = useMemo(() => makeValue(expr), [expr]);\n\n return ;\n};\n\nexport const Expression: FC = ({ expression: query, rulesSource }) => {\n const styles = useStyles(getStyles);\n\n return (\n \n {isCloudRulesSource(rulesSource) ? (\n \n ) : (\n query\n )}\n \n );\n};\n\nexport const getStyles = (theme: GrafanaTheme) => ({\n well: css`\n font-family: ${theme.typography.fontFamily.monospace};\n `,\n});\n","import { css, cx } from '@emotion/css';\nimport React from 'react';\n\nimport { CombinedRule, RulesSource } from 'app/types/unified-alerting';\n\nimport { isCloudRulesSource } from '../../utils/datasource';\nimport { DetailsField } from '../DetailsField';\nimport { Expression } from '../Expression';\n\ntype Props = {\n rule: CombinedRule;\n rulesSource: RulesSource;\n annotations: Array<[string, string]>;\n};\n\nexport function RuleDetailsExpression(props: Props): JSX.Element | null {\n const { annotations, rulesSource, rule } = props;\n const styles = getStyles();\n\n if (!isCloudRulesSource(rulesSource)) {\n return null;\n }\n\n return (\n \n \n \n );\n}\n\nconst getStyles = () => ({\n exprRow: css`\n margin-bottom: 46px;\n `,\n});\n","import { capitalize } from 'lodash';\nimport React, { useMemo } from 'react';\n\nimport { Label, RadioButtonGroup } from '@grafana/ui';\nimport { GrafanaAlertState, PromAlertingRuleState } from 'app/types/unified-alerting-dto';\n\nexport type InstanceStateFilter = GrafanaAlertState | PromAlertingRuleState.Pending | PromAlertingRuleState.Firing;\n\ninterface Props {\n className?: string;\n filterType: 'grafana' | 'prometheus';\n stateFilter?: InstanceStateFilter;\n onStateFilterChange: (value?: InstanceStateFilter) => void;\n}\n\nconst grafanaOptions = Object.values(GrafanaAlertState).map((value) => ({\n label: value,\n value,\n}));\n\nconst promOptionValues = [PromAlertingRuleState.Firing, PromAlertingRuleState.Pending] as const;\nconst promOptions = promOptionValues.map((state) => ({\n label: capitalize(state),\n value: state,\n}));\n\nexport const AlertInstanceStateFilter = ({ className, onStateFilterChange, stateFilter, filterType }: Props) => {\n const stateOptions = useMemo(() => (filterType === 'grafana' ? grafanaOptions : promOptions), [filterType]);\n\n return (\n
\n \n {\n if (v === stateFilter) {\n onStateFilterChange(undefined);\n }\n }}\n />\n
\n );\n};\n","import { css, cx } from '@emotion/css';\nimport React, { useMemo, useState } from 'react';\n\nimport { GrafanaTheme } from '@grafana/data';\nimport { useStyles } from '@grafana/ui';\nimport { MatcherFilter } from 'app/features/alerting/unified/components/alert-groups/MatcherFilter';\nimport {\n AlertInstanceStateFilter,\n InstanceStateFilter,\n} from 'app/features/alerting/unified/components/rules/AlertInstanceStateFilter';\nimport { labelsMatchMatchers, parseMatchers } from 'app/features/alerting/unified/utils/alertmanager';\nimport { sortAlerts } from 'app/features/alerting/unified/utils/misc';\nimport { SortOrder } from 'app/plugins/panel/alertlist/types';\nimport { Alert, CombinedRule } from 'app/types/unified-alerting';\nimport { mapStateWithReasonToBaseState } from 'app/types/unified-alerting-dto';\n\nimport { GRAFANA_RULES_SOURCE_NAME, isGrafanaRulesSource } from '../../utils/datasource';\nimport { isAlertingRule } from '../../utils/rules';\nimport { DetailsField } from '../DetailsField';\n\nimport { AlertInstancesTable } from './AlertInstancesTable';\n\ntype Props = {\n rule: CombinedRule;\n};\n\nexport function RuleDetailsMatchingInstances(props: Props): JSX.Element | null {\n const {\n rule: { promRule, namespace },\n } = props;\n\n const [queryString, setQueryString] = useState();\n const [alertState, setAlertState] = useState();\n\n // This key is used to force a rerender on the inputs when the filters are cleared\n const [filterKey] = useState(Math.floor(Math.random() * 100));\n const queryStringKey = `queryString-${filterKey}`;\n\n const styles = useStyles(getStyles);\n\n const stateFilterType = isGrafanaRulesSource(namespace.rulesSource) ? GRAFANA_RULES_SOURCE_NAME : 'prometheus';\n\n const alerts = useMemo(\n (): Alert[] =>\n isAlertingRule(promRule) && promRule.alerts?.length\n ? filterAlerts(queryString, alertState, sortAlerts(SortOrder.Importance, promRule.alerts))\n : [],\n [promRule, alertState, queryString]\n );\n\n if (!isAlertingRule(promRule)) {\n return null;\n }\n\n return (\n \n
\n
\n setQueryString(value)}\n />\n \n
\n
\n\n \n
\n );\n}\n\nfunction filterAlerts(\n alertInstanceLabel: string | undefined,\n alertInstanceState: InstanceStateFilter | undefined,\n alerts: Alert[]\n): Alert[] {\n let filteredAlerts = [...alerts];\n if (alertInstanceLabel) {\n const matchers = parseMatchers(alertInstanceLabel || '');\n filteredAlerts = filteredAlerts.filter(({ labels }) => labelsMatchMatchers(labels, matchers));\n }\n if (alertInstanceState) {\n filteredAlerts = filteredAlerts.filter((alert) => {\n return mapStateWithReasonToBaseState(alert.state) === alertInstanceState;\n });\n }\n\n return filteredAlerts;\n}\n\nconst getStyles = (theme: GrafanaTheme) => {\n return {\n flexRow: css`\n display: flex;\n flex-direction: row;\n align-items: flex-end;\n width: 100%;\n flex-wrap: wrap;\n margin-bottom: ${theme.spacing.sm};\n `,\n spaceBetween: css`\n justify-content: space-between;\n `,\n rowChild: css`\n margin-right: ${theme.spacing.sm};\n `,\n };\n};\n","import { css } from '@emotion/css';\nimport React, { FC } from 'react';\n\nimport { GrafanaTheme2 } from '@grafana/data';\nimport { Icon, Tooltip, useStyles2 } from '@grafana/ui';\nimport { Rule } from 'app/types/unified-alerting';\n\ninterface Prom {\n rule: Rule;\n}\n\nexport const RuleHealth: FC = ({ rule }) => {\n const style = useStyles2(getStyle);\n if (rule.health === 'err' || rule.health === 'error') {\n return (\n \n
\n \n error\n
\n
\n );\n }\n return <>{rule.health};\n};\n\nconst getStyle = (theme: GrafanaTheme2) => ({\n warn: css`\n display: inline-flex;\n flex-direction: row;\n color: ${theme.colors.warning.text};\n & > * + * {\n margin-left: ${theme.spacing(1)};\n }\n `,\n});\n","import { css } from '@emotion/css';\nimport React, { FC, useMemo } from 'react';\n\nimport { GrafanaTheme2, intervalToAbbreviatedDurationString } from '@grafana/data';\nimport { HorizontalGroup, Spinner, useStyles2 } from '@grafana/ui';\nimport { CombinedRule } from 'app/types/unified-alerting';\nimport { PromAlertingRuleState } from 'app/types/unified-alerting-dto';\n\nimport { isAlertingRule, isRecordingRule, getFirstActiveAt } from '../../utils/rules';\n\nimport { AlertStateTag } from './AlertStateTag';\n\ninterface Props {\n rule: CombinedRule;\n isDeleting: boolean;\n isCreating: boolean;\n}\n\nexport const RuleState: FC = ({ rule, isDeleting, isCreating }) => {\n const style = useStyles2(getStyle);\n const { promRule } = rule;\n\n // return how long the rule has been in it's firing state, if any\n const forTime = useMemo(() => {\n if (\n promRule &&\n isAlertingRule(promRule) &&\n promRule.alerts?.length &&\n promRule.state !== PromAlertingRuleState.Inactive\n ) {\n // find earliest alert\n const firstActiveAt = getFirstActiveAt(promRule);\n\n // calculate time elapsed from earliest alert\n if (firstActiveAt) {\n return (\n \n for{' '}\n {intervalToAbbreviatedDurationString(\n {\n start: firstActiveAt,\n end: new Date(),\n },\n false\n )}\n \n );\n }\n }\n return null;\n }, [promRule, style]);\n\n if (isDeleting) {\n return (\n \n \n deleting\n \n );\n } else if (isCreating) {\n return (\n \n {' '}\n \n creating\n \n );\n } else if (promRule && isAlertingRule(promRule)) {\n return (\n \n \n {forTime}\n \n );\n } else if (promRule && isRecordingRule(promRule)) {\n return <>Recording rule;\n }\n return <>n/a;\n};\n\nconst getStyle = (theme: GrafanaTheme2) => ({\n for: css`\n font-size: ${theme.typography.bodySmall.fontSize};\n color: ${theme.colors.text.secondary};\n white-space: nowrap;\n padding-top: 2px;\n `,\n});\n","import { useMemo, useRef } from 'react';\n\nimport {\n CombinedRule,\n CombinedRuleGroup,\n CombinedRuleNamespace,\n Rule,\n RuleGroup,\n RuleNamespace,\n RulesSource,\n} from 'app/types/unified-alerting';\nimport { RulerRuleDTO, RulerRuleGroupDTO, RulerRulesConfigDTO } from 'app/types/unified-alerting-dto';\n\nimport {\n getAllRulesSources,\n getRulesSourceByName,\n isCloudRulesSource,\n isGrafanaRulesSource,\n} from '../utils/datasource';\nimport { isAlertingRule, isAlertingRulerRule, isRecordingRulerRule } from '../utils/rules';\n\nimport { useUnifiedAlertingSelector } from './useUnifiedAlertingSelector';\n\ninterface CacheValue {\n promRules?: RuleNamespace[];\n rulerRules?: RulerRulesConfigDTO | null;\n result: CombinedRuleNamespace[];\n}\n\n// this little monster combines prometheus rules and ruler rules to produce a unified data structure\n// can limit to a single rules source\nexport function useCombinedRuleNamespaces(rulesSourceName?: string): CombinedRuleNamespace[] {\n const promRulesResponses = useUnifiedAlertingSelector((state) => state.promRules);\n const rulerRulesResponses = useUnifiedAlertingSelector((state) => state.rulerRules);\n\n // cache results per rules source, so we only recalculate those for which results have actually changed\n const cache = useRef>({});\n\n const rulesSources = useMemo((): RulesSource[] => {\n if (rulesSourceName) {\n const rulesSource = getRulesSourceByName(rulesSourceName);\n if (!rulesSource) {\n throw new Error(`Unknown rules source: ${rulesSourceName}`);\n }\n return [rulesSource];\n }\n return getAllRulesSources();\n }, [rulesSourceName]);\n\n return useMemo(\n () =>\n rulesSources\n .map((rulesSource): CombinedRuleNamespace[] => {\n const rulesSourceName = isCloudRulesSource(rulesSource) ? rulesSource.name : rulesSource;\n const promRules = promRulesResponses[rulesSourceName]?.result;\n const rulerRules = rulerRulesResponses[rulesSourceName]?.result;\n\n const cached = cache.current[rulesSourceName];\n if (cached && cached.promRules === promRules && cached.rulerRules === rulerRules) {\n return cached.result;\n }\n const namespaces: Record = {};\n\n // first get all the ruler rules in\n Object.entries(rulerRules || {}).forEach(([namespaceName, groups]) => {\n const namespace: CombinedRuleNamespace = {\n rulesSource,\n name: namespaceName,\n groups: [],\n };\n namespaces[namespaceName] = namespace;\n addRulerGroupsToCombinedNamespace(namespace, groups);\n });\n\n // then correlate with prometheus rules\n promRules?.forEach(({ name: namespaceName, groups }) => {\n const ns = (namespaces[namespaceName] = namespaces[namespaceName] || {\n rulesSource,\n name: namespaceName,\n groups: [],\n });\n\n addPromGroupsToCombinedNamespace(ns, groups);\n });\n\n const result = Object.values(namespaces);\n\n cache.current[rulesSourceName] = { promRules, rulerRules, result };\n return result;\n })\n .flat(),\n [promRulesResponses, rulerRulesResponses, rulesSources]\n );\n}\n\n// merge all groups in case of grafana managed, essentially treating namespaces (folders) as groups\nexport function flattenGrafanaManagedRules(namespaces: CombinedRuleNamespace[]) {\n return namespaces.map((namespace) => {\n const newNamespace: CombinedRuleNamespace = {\n ...namespace,\n groups: [],\n };\n\n // add default group with ungrouped rules\n newNamespace.groups.push({\n name: 'default',\n rules: sortRulesByName(namespace.groups.flatMap((group) => group.rules)),\n });\n\n return newNamespace;\n });\n}\n\nexport function sortRulesByName(rules: CombinedRule[]) {\n return rules.sort((a, b) => a.name.localeCompare(b.name));\n}\n\nfunction addRulerGroupsToCombinedNamespace(namespace: CombinedRuleNamespace, groups: RulerRuleGroupDTO[]): void {\n namespace.groups = groups.map((group) => {\n const combinedGroup: CombinedRuleGroup = {\n name: group.name,\n interval: group.interval,\n source_tenants: group.source_tenants,\n rules: [],\n };\n combinedGroup.rules = group.rules.map((rule) => rulerRuleToCombinedRule(rule, namespace, combinedGroup));\n return combinedGroup;\n });\n}\n\nfunction addPromGroupsToCombinedNamespace(namespace: CombinedRuleNamespace, groups: RuleGroup[]): void {\n groups.forEach((group) => {\n let combinedGroup = namespace.groups.find((g) => g.name === group.name);\n if (!combinedGroup) {\n combinedGroup = {\n name: group.name,\n rules: [],\n };\n namespace.groups.push(combinedGroup);\n }\n\n (group.rules ?? []).forEach((rule) => {\n const existingRule = getExistingRuleInGroup(rule, combinedGroup!, namespace.rulesSource);\n if (existingRule) {\n existingRule.promRule = rule;\n } else {\n combinedGroup!.rules.push(promRuleToCombinedRule(rule, namespace, combinedGroup!));\n }\n });\n });\n}\n\nfunction promRuleToCombinedRule(rule: Rule, namespace: CombinedRuleNamespace, group: CombinedRuleGroup): CombinedRule {\n return {\n name: rule.name,\n query: rule.query,\n labels: rule.labels || {},\n annotations: isAlertingRule(rule) ? rule.annotations || {} : {},\n promRule: rule,\n namespace: namespace,\n group,\n };\n}\n\nfunction rulerRuleToCombinedRule(\n rule: RulerRuleDTO,\n namespace: CombinedRuleNamespace,\n group: CombinedRuleGroup\n): CombinedRule {\n return isAlertingRulerRule(rule)\n ? {\n name: rule.alert,\n query: rule.expr,\n labels: rule.labels || {},\n annotations: rule.annotations || {},\n rulerRule: rule,\n namespace,\n group,\n }\n : isRecordingRulerRule(rule)\n ? {\n name: rule.record,\n query: rule.expr,\n labels: rule.labels || {},\n annotations: {},\n rulerRule: rule,\n namespace,\n group,\n }\n : {\n name: rule.grafana_alert.title,\n query: '',\n labels: rule.labels || {},\n annotations: rule.annotations || {},\n rulerRule: rule,\n namespace,\n group,\n };\n}\n\n// find existing rule in group that matches the given prom rule\nfunction getExistingRuleInGroup(\n rule: Rule,\n group: CombinedRuleGroup,\n rulesSource: RulesSource\n): CombinedRule | undefined {\n if (isGrafanaRulesSource(rulesSource)) {\n // assume grafana groups have only the one rule. check name anyway because paranoid\n return group!.rules.find((existingRule) => existingRule.name === rule.name);\n }\n return (\n // try finding a rule that matches name, labels, annotations and query\n group!.rules.find(\n (existingRule) => !existingRule.promRule && isCombinedRuleEqualToPromRule(existingRule, rule, true)\n ) ??\n // if that fails, try finding a rule that only matches name, labels and annotations.\n // loki & prom can sometimes modify the query so it doesnt match, eg `2 > 1` becomes `1`\n group!.rules.find(\n (existingRule) => !existingRule.promRule && isCombinedRuleEqualToPromRule(existingRule, rule, false)\n )\n );\n}\n\nfunction isCombinedRuleEqualToPromRule(combinedRule: CombinedRule, rule: Rule, checkQuery = true): boolean {\n if (combinedRule.name === rule.name) {\n return (\n JSON.stringify([\n checkQuery ? hashQuery(combinedRule.query) : '',\n combinedRule.labels,\n combinedRule.annotations,\n ]) ===\n JSON.stringify([\n checkQuery ? hashQuery(rule.query) : '',\n rule.labels || {},\n isAlertingRule(rule) ? rule.annotations || {} : {},\n ])\n );\n }\n return false;\n}\n\n// there can be slight differences in how prom & ruler render a query, this will hash them accounting for the differences\nfunction hashQuery(query: string) {\n // one of them might be wrapped in parens\n if (query.length > 1 && query[0] === '(' && query[query.length - 1] === ')') {\n query = query.slice(1, -1);\n }\n // whitespace could be added or removed\n query = query.replace(/\\s|\\n/g, '');\n // labels matchers can be reordered, so sort the enitre string, esentially comparing just the character counts\n return query.split('').sort().join('');\n}\n","import { useEffect } from 'react';\nimport { useDispatch } from 'react-redux';\n\nimport { FolderDTO } from 'app/types';\n\nimport { fetchFolderIfNotFetchedAction } from '../state/actions';\nimport { initialAsyncRequestState } from '../utils/redux';\n\nimport { useUnifiedAlertingSelector } from './useUnifiedAlertingSelector';\n\ninterface ReturnBag {\n folder?: FolderDTO;\n loading: boolean;\n}\n\nexport function useFolder(uid?: string): ReturnBag {\n const dispatch = useDispatch();\n const folderRequests = useUnifiedAlertingSelector((state) => state.folders);\n useEffect(() => {\n if (uid) {\n dispatch(fetchFolderIfNotFetchedAction(uid));\n }\n }, [dispatch, uid]);\n\n if (uid) {\n const request = folderRequests[uid] || initialAsyncRequestState;\n return {\n folder: request.result,\n loading: request.loading,\n };\n }\n return {\n loading: false,\n };\n}\n","import { contextSrv } from 'app/core/services/context_srv';\nimport { RulerRuleDTO } from 'app/types/unified-alerting-dto';\n\nimport { getRulesPermissions } from '../utils/access-control';\nimport { isGrafanaRulerRule } from '../utils/rules';\n\nimport { useFolder } from './useFolder';\nimport { useUnifiedAlertingSelector } from './useUnifiedAlertingSelector';\n\ninterface ResultBag {\n isEditable?: boolean;\n isRemovable?: boolean;\n loading: boolean;\n}\n\nexport function useIsRuleEditable(rulesSourceName: string, rule?: RulerRuleDTO): ResultBag {\n const dataSources = useUnifiedAlertingSelector((state) => state.dataSources);\n const folderUID = rule && isGrafanaRulerRule(rule) ? rule.grafana_alert.namespace_uid : undefined;\n\n const rulePermission = getRulesPermissions(rulesSourceName);\n\n const { folder, loading } = useFolder(folderUID);\n\n if (!rule) {\n return { isEditable: false, isRemovable: false, loading: false };\n }\n\n // Grafana rules can be edited if user can edit the folder they're in\n // When RBAC is disabled access to a folder is the only requirement for managing rules\n // When RBAC is enabled the appropriate alerting permissions need to be met\n if (isGrafanaRulerRule(rule)) {\n if (!folderUID) {\n throw new Error(\n `Rule ${rule.grafana_alert.title} does not have a folder uid, cannot determine if it is editable.`\n );\n }\n\n const canEditGrafanaRules = contextSrv.hasAccess(rulePermission.update, folder?.canSave ?? false);\n const canRemoveGrafanaRules = contextSrv.hasAccess(rulePermission.delete, folder?.canSave ?? false);\n\n return {\n isEditable: canEditGrafanaRules,\n isRemovable: canRemoveGrafanaRules,\n loading,\n };\n }\n\n // prom rules are only editable by users with Editor role and only if rules source supports editing\n const isRulerAvailable = Boolean(dataSources[rulesSourceName]?.result?.rulerConfig);\n const canEditCloudRules = contextSrv.hasAccess(rulePermission.update, contextSrv.isEditor);\n const canRemoveCloudRules = contextSrv.hasAccess(rulePermission.delete, contextSrv.isEditor);\n\n return {\n isEditable: canEditCloudRules && isRulerAvailable,\n isRemovable: canRemoveCloudRules && isRulerAvailable,\n loading: dataSources[rulesSourceName]?.loading,\n };\n}\n"],"names":["MatcherFilter","className","onFilterChange","defaultQueryString","queryString","styles","useStyles2","getStyles","searchIcon","Icon","name","Label","Stack","gap","Tooltip","content","icon","size","Input","placeholder","defaultValue","value","onChange","e","target","prefix","inputWidth","theme","css","spacing","StateHistory","alertId","loading","error","result","dispatch","useDispatch","history","useUnifiedAlertingSelector","state","managedAlertStateHistory","useEffect","fetchGrafanaAnnotationsAction","useManagedAlertStateHistory","LoadingPlaceholder","text","Alert","title","message","columns","id","label","renderCell","renderStateCell","renderValueCell","renderTimestampCell","items","reduce","acc","item","index","push","String","newState","data","timestamp","updated","currentHistoryItem","previousHistoryItem","prevState","hasMatchingPrecedingState","uniqueId","map","historyItem","DynamicTable","cols","matches","evalMatches","LabelsWrapper","match","AlertLabel","labelKey","metric","AlertStateTag","TimestampStyle","dateTimeFormat","children","wrapper","useStyles","xs","RuleDetailsActionButtons","rule","rulesSource","location","useLocation","notifyApp","useAppNotification","style","namespace","group","rulerRule","ruleToDelete","setRuleToDelete","useState","grafana_alert","isGrafanaRulerRule","StateHistoryModal","showStateHistoryModal","showModal","setShowModal","useMemo","Modal","isOpen","onDismiss","closeOnBackdropClick","closeOnEscape","hideStateHistoryModal","useStateHistoryModal","alertmanagerSourceName","isGrafanaRulesSource","getAlertmanagerByUid","jsonData","alertmanagerUid","rulesSourceName","getRulesSourceName","hasExplorePermission","contextSrv","AccessControlAction","leftButtons","rightButtons","isFederated","isFederatedRuleGroup","isEditable","isRemovable","useIsRuleEditable","returnTo","pathname","search","isViewMode","endsWith","deleteRule","identifier","ruleId","deleteRuleAction","navigateTo","undefined","buildShareUrl","isCloudRulesSource","appUrl","appSubUrl","config","encodeURIComponent","window","href","split","LinkButton","button","variant","createExploreLink","query","annotations","Annotation","textUtil","dashboardUID","panelId","makeRuleBasedSilenceLink","Fragment","Button","onClick","createViewLink","sourceName","editURL","urlUtil","ClipboardButton","onClipboardCopy","success","onClipboardError","copiedText","getText","type","length","HorizontalGroup","width","ConfirmModal","body","confirmText","onConfirm","colors","border","medium","typography","sm","RuleDetailsAnnotations","props","key","annotationKey","RuleDetailsDataSources","dataSources","meta","info","logos","small","unique","ds","getDataSourceSrv","getInstanceSettings","datasourceUid","uid","ExpressionDatasourceUID","Object","values","alt","dataSourceIcon","src","HighlightedQuery","language","expr","plugins","SlatePrism","onlyIn","node","getSyntax","prismLanguages","LogqlSyntax","PromqlSyntax","slateValue","makeValue","readOnly","Expression","expression","Well","cx","well","DataSourceType","fontFamily","monospace","RuleDetailsExpression","DetailsField","horizontal","exprRow","grafanaOptions","GrafanaAlertState","promOptions","PromAlertingRuleState","capitalize","AlertInstanceStateFilter","onStateFilterChange","stateFilter","filterType","stateOptions","RadioButtonGroup","options","v","RuleDetailsMatchingInstances","promRule","setQueryString","alertState","setAlertState","filterKey","Math","floor","random","queryStringKey","stateFilterType","GRAFANA_RULES_SOURCE_NAME","alerts","isAlertingRule","alertInstanceLabel","alertInstanceState","filteredAlerts","matchers","parseMatchers","filter","labels","labelsMatchMatchers","alert","mapStateWithReasonToBaseState","filterAlerts","sortAlerts","SortOrder","flexRow","spaceBetween","rowChild","AlertInstancesTable","instances","RuleHealth","getStyle","health","lastError","warn","warning","RuleState","isDeleting","isCreating","forTime","firstActiveAt","getFirstActiveAt","for","intervalToAbbreviatedDurationString","start","end","Date","align","Spinner","isRecordingRule","bodySmall","fontSize","secondary","useCombinedRuleNamespaces","promRulesResponses","promRules","rulerRulesResponses","rulerRules","cache","useRef","rulesSources","getRulesSourceByName","Error","getAllRulesSources","cached","current","namespaces","entries","forEach","namespaceName","groups","combinedGroup","interval","source_tenants","rules","isAlertingRulerRule","isRecordingRulerRule","record","rulerRuleToCombinedRule","addRulerGroupsToCombinedNamespace","find","g","existingRule","isCombinedRuleEqualToPromRule","getExistingRuleInGroup","promRuleToCombinedRule","addPromGroupsToCombinedNamespace","flat","flattenGrafanaManagedRules","newNamespace","flatMap","sort","a","b","localeCompare","combinedRule","checkQuery","JSON","stringify","hashQuery","slice","replace","join","useFolder","folderRequests","folders","fetchFolderIfNotFetchedAction","request","initialAsyncRequestState","folder","folderUID","namespace_uid","rulePermission","getRulesPermissions","update","canSave","delete","isRulerAvailable","Boolean","rulerConfig"],"sourceRoot":""}