mirror of
https://github.com/grafana/grafana.git
synced 2025-01-27 16:57:14 -06:00
Alerting: Filter insights panels (grafanacloud-usage ds) by instance_id (#78657)
* Filter grafana-managed panels by instance_id * Filter grafana alertmanager panels by instance_id * Filter mimir managed panels by instance_id * Filter mimir managed per group by instance id * Filter mimir alertmanager panels by instance id * Fix typos in queries
This commit is contained in:
parent
dff5022021
commit
588f87ef1e
@ -17,6 +17,7 @@ import {
|
||||
VariableValueSelectors,
|
||||
} from '@grafana/scenes';
|
||||
|
||||
import { config } from '../../../../core/config';
|
||||
import { SectionFooter } from '../insights/SectionFooter';
|
||||
import { SectionSubheader } from '../insights/SectionSubheader';
|
||||
import { getGrafanaInstancesByStateScene } from '../insights/grafana/AlertsByStateScene';
|
||||
@ -95,6 +96,10 @@ export const PANEL_STYLES = { minHeight: 300 };
|
||||
|
||||
const THIS_WEEK_TIME_RANGE = new SceneTimeRange({ from: 'now-1w', to: 'now' });
|
||||
|
||||
const namespace = config.bootData.settings.namespace;
|
||||
|
||||
export const INSTANCE_ID = namespace.includes('stack-') ? namespace.replace('stack-', '') : undefined;
|
||||
|
||||
export function getInsightsScenes() {
|
||||
const dataSourceSrv = getDataSourceSrv();
|
||||
|
||||
|
@ -3,16 +3,20 @@ import React from 'react';
|
||||
import { PanelBuilders, SceneDataTransformer, SceneFlexItem, SceneQueryRunner } from '@grafana/scenes';
|
||||
import { DataSourceRef, GraphDrawStyle, TooltipDisplayMode } from '@grafana/schema';
|
||||
|
||||
import { overrideToFixedColor, PANEL_STYLES } from '../../home/Insights';
|
||||
import { INSTANCE_ID, overrideToFixedColor, PANEL_STYLES } from '../../home/Insights';
|
||||
import { InsightsRatingModal } from '../RatingModal';
|
||||
|
||||
export function getGrafanaInstancesByStateScene(datasource: DataSourceRef, panelTitle: string) {
|
||||
const expr = INSTANCE_ID
|
||||
? `sum by(state) (grafanacloud_grafana_instance_alerting_alerts{id="${INSTANCE_ID}"})`
|
||||
: 'sum by (state) (grafanacloud_grafana_instance_alerting_alerts)';
|
||||
|
||||
const query = new SceneQueryRunner({
|
||||
datasource,
|
||||
queries: [
|
||||
{
|
||||
refId: 'A',
|
||||
expr: 'sum by (state) (grafanacloud_grafana_instance_alerting_alerts)',
|
||||
expr,
|
||||
range: true,
|
||||
legendFormat: '{{state}}',
|
||||
},
|
||||
|
@ -3,22 +3,30 @@ import React from 'react';
|
||||
import { PanelBuilders, SceneFlexItem, SceneQueryRunner } from '@grafana/scenes';
|
||||
import { DataSourceRef, GraphDrawStyle, TooltipDisplayMode } from '@grafana/schema';
|
||||
|
||||
import { overrideToFixedColor, PANEL_STYLES } from '../../home/Insights';
|
||||
import { INSTANCE_ID, overrideToFixedColor, PANEL_STYLES } from '../../home/Insights';
|
||||
import { InsightsRatingModal } from '../RatingModal';
|
||||
|
||||
export function getGrafanaEvalSuccessVsFailuresScene(datasource: DataSourceRef, panelTitle: string) {
|
||||
const exprA = INSTANCE_ID
|
||||
? `sum(grafanacloud_grafana_instance_alerting_rule_evaluations_total:rate5m{id="${INSTANCE_ID}"}) - sum(grafanacloud_grafana_instance_alerting_rule_evaluation_failures_total:rate5m{id="${INSTANCE_ID}"})`
|
||||
: `sum(grafanacloud_grafana_instance_alerting_rule_evaluations_total:rate5m) - sum(grafanacloud_grafana_instance_alerting_rule_evaluation_failures_total:rate5m)`;
|
||||
|
||||
const exprB = INSTANCE_ID
|
||||
? `sum(grafanacloud_grafana_instance_alerting_rule_evaluation_failures_total:rate5m{id="${INSTANCE_ID}"})`
|
||||
: `sum(grafanacloud_grafana_instance_alerting_rule_evaluation_failures_total:rate5m)`;
|
||||
|
||||
const query = new SceneQueryRunner({
|
||||
datasource,
|
||||
queries: [
|
||||
{
|
||||
refId: 'A',
|
||||
expr: 'sum(grafanacloud_grafana_instance_alerting_rule_evaluations_total:rate5m) - sum(grafanacloud_grafana_instance_alerting_rule_evaluation_failures_total:rate5m)',
|
||||
exprA,
|
||||
range: true,
|
||||
legendFormat: 'success',
|
||||
},
|
||||
{
|
||||
refId: 'B',
|
||||
expr: 'sum(grafanacloud_grafana_instance_alerting_rule_evaluation_failures_total:rate5m)',
|
||||
exprB,
|
||||
range: true,
|
||||
legendFormat: 'failed',
|
||||
},
|
||||
|
@ -4,17 +4,21 @@ import { ThresholdsMode } from '@grafana/data';
|
||||
import { PanelBuilders, SceneFlexItem, SceneQueryRunner } from '@grafana/scenes';
|
||||
import { DataSourceRef } from '@grafana/schema';
|
||||
|
||||
import { PANEL_STYLES } from '../../home/Insights';
|
||||
import { INSTANCE_ID, PANEL_STYLES } from '../../home/Insights';
|
||||
import { InsightsRatingModal } from '../RatingModal';
|
||||
|
||||
export function getFiringGrafanaAlertsScene(datasource: DataSourceRef, panelTitle: string) {
|
||||
const expr = INSTANCE_ID
|
||||
? `sum by (state) (grafanacloud_grafana_instance_alerting_rule_group_rules{state="active", id="${INSTANCE_ID}"})`
|
||||
: `sum by (state) (grafanacloud_grafana_instance_alerting_rule_group_rules{state="active"})`;
|
||||
|
||||
const query = new SceneQueryRunner({
|
||||
datasource,
|
||||
queries: [
|
||||
{
|
||||
refId: 'A',
|
||||
instant: true,
|
||||
expr: 'sum by (state) (grafanacloud_grafana_instance_alerting_rule_group_rules{state="active"})',
|
||||
expr,
|
||||
},
|
||||
],
|
||||
});
|
||||
|
@ -3,7 +3,7 @@ import React from 'react';
|
||||
import { PanelBuilders, SceneFlexItem, SceneQueryRunner } from '@grafana/scenes';
|
||||
import { DataSourceRef } from '@grafana/schema';
|
||||
|
||||
import { overrideToFixedColor } from '../../home/Insights';
|
||||
import { INSTANCE_ID, overrideToFixedColor } from '../../home/Insights';
|
||||
import { InsightsRatingModal } from '../RatingModal';
|
||||
export function getInstanceStatByStatusScene(
|
||||
datasource: DataSourceRef,
|
||||
@ -11,13 +11,17 @@ export function getInstanceStatByStatusScene(
|
||||
panelDescription: string,
|
||||
status: 'alerting' | 'pending' | 'nodata' | 'normal' | 'error'
|
||||
) {
|
||||
const expr = INSTANCE_ID
|
||||
? `sum by (state) (grafanacloud_grafana_instance_alerting_alerts{state="${status}", id="${INSTANCE_ID}"})`
|
||||
: `sum by (state) (grafanacloud_grafana_instance_alerting_alerts{state="${status}"})`;
|
||||
|
||||
const query = new SceneQueryRunner({
|
||||
datasource,
|
||||
queries: [
|
||||
{
|
||||
refId: 'A',
|
||||
instant: true,
|
||||
expr: `sum by (state) (grafanacloud_grafana_instance_alerting_alerts{state="${status}"})`,
|
||||
expr,
|
||||
legendFormat: '{{state}}',
|
||||
},
|
||||
],
|
||||
|
@ -11,16 +11,17 @@ import {
|
||||
} from '@grafana/scenes';
|
||||
import { DataSourceRef, GraphDrawStyle, TooltipDisplayMode } from '@grafana/schema';
|
||||
|
||||
import { PANEL_STYLES } from '../../home/Insights';
|
||||
import { INSTANCE_ID, PANEL_STYLES } from '../../home/Insights';
|
||||
import { InsightsRatingModal } from '../RatingModal';
|
||||
|
||||
export function getGrafanaMissedIterationsScene(datasource: DataSourceRef, panelTitle: string) {
|
||||
const expr = `sum by(rule_group) (grafanacloud_instance_rule_group_iterations_missed_total:rate5m{id="${INSTANCE_ID}"})`;
|
||||
const query = new SceneQueryRunner({
|
||||
datasource,
|
||||
queries: [
|
||||
{
|
||||
refId: 'A',
|
||||
expr: 'sum by (rule_group) (grafanacloud_instance_rule_group_iterations_missed_total:rate5m)',
|
||||
expr,
|
||||
range: true,
|
||||
legendFormat: '{{rule_group}}',
|
||||
},
|
||||
|
@ -4,17 +4,21 @@ import { ThresholdsMode } from '@grafana/data';
|
||||
import { PanelBuilders, SceneFlexItem, SceneQueryRunner } from '@grafana/scenes';
|
||||
import { DataSourceRef } from '@grafana/schema';
|
||||
|
||||
import { PANEL_STYLES } from '../../home/Insights';
|
||||
import { INSTANCE_ID, PANEL_STYLES } from '../../home/Insights';
|
||||
import { InsightsRatingModal } from '../RatingModal';
|
||||
|
||||
export function getPausedGrafanaAlertsScene(datasource: DataSourceRef, panelTitle: string) {
|
||||
const expr = INSTANCE_ID
|
||||
? `sum by (state) (grafanacloud_grafana_instance_alerting_rule_group_rules{state="paused", id="${INSTANCE_ID}"})`
|
||||
: `sum by (state) (grafanacloud_grafana_instance_alerting_rule_group_rules{state="paused"})`;
|
||||
|
||||
const query = new SceneQueryRunner({
|
||||
datasource,
|
||||
queries: [
|
||||
{
|
||||
refId: 'A',
|
||||
instant: true,
|
||||
expr: 'sum by (state) (grafanacloud_grafana_instance_alerting_rule_group_rules{state="paused"})',
|
||||
expr,
|
||||
},
|
||||
],
|
||||
});
|
||||
|
@ -3,16 +3,20 @@ import React from 'react';
|
||||
import { PanelBuilders, SceneFlexItem, SceneQueryRunner } from '@grafana/scenes';
|
||||
import { DataSourceRef, GraphDrawStyle, TooltipDisplayMode } from '@grafana/schema';
|
||||
|
||||
import { overrideToFixedColor, PANEL_STYLES } from '../../home/Insights';
|
||||
import { INSTANCE_ID, overrideToFixedColor, PANEL_STYLES } from '../../home/Insights';
|
||||
import { InsightsRatingModal } from '../RatingModal';
|
||||
|
||||
export function getGrafanaRulesByEvaluationScene(datasource: DataSourceRef, panelTitle: string) {
|
||||
const expr = INSTANCE_ID
|
||||
? `sum by (state) (grafanacloud_grafana_instance_alerting_rule_group_rules{id="${INSTANCE_ID}"})`
|
||||
: `sum by (state) (grafanacloud_grafana_instance_alerting_rule_group_rules)`;
|
||||
|
||||
const query = new SceneQueryRunner({
|
||||
datasource,
|
||||
queries: [
|
||||
{
|
||||
refId: 'A',
|
||||
expr: 'sum by (state) (grafanacloud_grafana_instance_alerting_rule_group_rules)',
|
||||
expr,
|
||||
range: true,
|
||||
legendFormat: '{{state}} evaluation',
|
||||
},
|
||||
|
@ -3,16 +3,20 @@ import React from 'react';
|
||||
import { PanelBuilders, SceneFlexItem, SceneQueryRunner } from '@grafana/scenes';
|
||||
import { DataSourceRef, GraphDrawStyle, TooltipDisplayMode } from '@grafana/schema';
|
||||
|
||||
import { overrideToFixedColor, PANEL_STYLES } from '../../home/Insights';
|
||||
import { INSTANCE_ID, overrideToFixedColor, PANEL_STYLES } from '../../home/Insights';
|
||||
import { InsightsRatingModal } from '../RatingModal';
|
||||
|
||||
export function getGrafanaRulesByEvaluationPercentageScene(datasource: DataSourceRef, panelTitle: string) {
|
||||
const expr = INSTANCE_ID
|
||||
? `sum by (state) (grafanacloud_grafana_instance_alerting_rule_group_rules{id="${INSTANCE_ID}"}) / ignoring(state) group_left sum(grafanacloud_grafana_instance_alerting_rule_group_rules{id="${INSTANCE_ID}"})`
|
||||
: `sum by (state) (grafanacloud_grafana_instance_alerting_rule_group_rules) / ignoring(state) group_left sum(grafanacloud_grafana_instance_alerting_rule_group_rules)`;
|
||||
|
||||
const query = new SceneQueryRunner({
|
||||
datasource,
|
||||
queries: [
|
||||
{
|
||||
refId: 'A',
|
||||
expr: 'sum by (state) (grafanacloud_grafana_instance_alerting_rule_group_rules) / ignoring(state) group_left sum(grafanacloud_grafana_instance_alerting_rule_group_rules)',
|
||||
expr,
|
||||
range: true,
|
||||
legendFormat: '{{state}} evaluation',
|
||||
},
|
||||
|
@ -3,16 +3,20 @@ import React from 'react';
|
||||
import { PanelBuilders, SceneFlexItem, SceneQueryRunner } from '@grafana/scenes';
|
||||
import { DataSourceRef, GraphDrawStyle, TooltipDisplayMode } from '@grafana/schema';
|
||||
|
||||
import { overrideToFixedColor, PANEL_STYLES } from '../../../home/Insights';
|
||||
import { INSTANCE_ID, overrideToFixedColor, PANEL_STYLES } from '../../../home/Insights';
|
||||
import { InsightsRatingModal } from '../../RatingModal';
|
||||
|
||||
export function getAlertsByStateScene(datasource: DataSourceRef, panelTitle: string) {
|
||||
const expr = INSTANCE_ID
|
||||
? `sum by (state) (grafanacloud_grafana_instance_alerting_alertmanager_alerts{id="${INSTANCE_ID}"})`
|
||||
: `sum by (state) (grafanacloud_grafana_instance_alerting_alertmanager_alerts)`;
|
||||
|
||||
const query = new SceneQueryRunner({
|
||||
datasource,
|
||||
queries: [
|
||||
{
|
||||
refId: 'A',
|
||||
expr: 'sum by (state) (grafanacloud_grafana_instance_alerting_alertmanager_alerts)',
|
||||
expr,
|
||||
range: true,
|
||||
legendFormat: '{{state}}',
|
||||
},
|
||||
|
@ -3,16 +3,20 @@ import React from 'react';
|
||||
import { PanelBuilders, SceneFlexItem, SceneQueryRunner } from '@grafana/scenes';
|
||||
import { DataSourceRef, GraphDrawStyle, TooltipDisplayMode } from '@grafana/schema';
|
||||
|
||||
import { PANEL_STYLES } from '../../../home/Insights';
|
||||
import { INSTANCE_ID, PANEL_STYLES } from '../../../home/Insights';
|
||||
import { InsightsRatingModal } from '../../RatingModal';
|
||||
|
||||
export function getGrafanaAlertmanagerSilencesScene(datasource: DataSourceRef, panelTitle: string) {
|
||||
const expr = INSTANCE_ID
|
||||
? `sum by (state) (grafanacloud_grafana_instance_alerting_silences{id="${INSTANCE_ID}"})`
|
||||
: `sum by (state) (grafanacloud_grafana_instance_alerting_silences)`;
|
||||
|
||||
const query = new SceneQueryRunner({
|
||||
datasource,
|
||||
queries: [
|
||||
{
|
||||
refId: 'A',
|
||||
expr: 'sum by (state) (grafanacloud_grafana_instance_alerting_silences)',
|
||||
expr,
|
||||
range: true,
|
||||
legendFormat: '{{state}}',
|
||||
},
|
||||
|
@ -3,16 +3,20 @@ import React from 'react';
|
||||
import { PanelBuilders, SceneFlexItem, SceneQueryRunner } from '@grafana/scenes';
|
||||
import { DataSourceRef, GraphDrawStyle, TooltipDisplayMode } from '@grafana/schema';
|
||||
|
||||
import { overrideToFixedColor, PANEL_STYLES } from '../../home/Insights';
|
||||
import { INSTANCE_ID, overrideToFixedColor, PANEL_STYLES } from '../../home/Insights';
|
||||
import { InsightsRatingModal } from '../RatingModal';
|
||||
|
||||
export function getAlertsByStateScene(datasource: DataSourceRef, panelTitle: string) {
|
||||
const expr = INSTANCE_ID
|
||||
? `sum by (state) (grafanacloud_instance_alertmanager_alerts{id="${INSTANCE_ID}"})`
|
||||
: `sum by (state) (grafanacloud_instance_alertmanager_alerts)`;
|
||||
|
||||
const query = new SceneQueryRunner({
|
||||
datasource,
|
||||
queries: [
|
||||
{
|
||||
refId: 'A',
|
||||
expr: 'sum by (state) (grafanacloud_instance_alertmanager_alerts)',
|
||||
expr,
|
||||
range: true,
|
||||
legendFormat: '{{state}}',
|
||||
},
|
||||
|
@ -3,16 +3,20 @@ import React from 'react';
|
||||
import { PanelBuilders, SceneFlexItem, SceneQueryRunner } from '@grafana/scenes';
|
||||
import { BigValueGraphMode, DataSourceRef } from '@grafana/schema';
|
||||
|
||||
import { PANEL_STYLES } from '../../home/Insights';
|
||||
import { INSTANCE_ID, PANEL_STYLES } from '../../home/Insights';
|
||||
import { InsightsRatingModal } from '../RatingModal';
|
||||
|
||||
export function getInvalidConfigScene(datasource: DataSourceRef, panelTitle: string) {
|
||||
const expr = INSTANCE_ID
|
||||
? `sum by (cluster)(grafanacloud_instance_alertmanager_invalid_config{id="${INSTANCE_ID}"})`
|
||||
: `sum by (cluster)(grafanacloud_instance_alertmanager_invalid_config)`;
|
||||
|
||||
const query = new SceneQueryRunner({
|
||||
datasource,
|
||||
queries: [
|
||||
{
|
||||
refId: 'A',
|
||||
expr: 'sum by (cluster)(grafanacloud_instance_alertmanager_invalid_config)',
|
||||
expr,
|
||||
range: true,
|
||||
legendFormat: '{{cluster}}',
|
||||
},
|
||||
|
@ -3,22 +3,30 @@ import React from 'react';
|
||||
import { PanelBuilders, SceneFlexItem, SceneQueryRunner } from '@grafana/scenes';
|
||||
import { DataSourceRef, GraphDrawStyle, TooltipDisplayMode } from '@grafana/schema';
|
||||
|
||||
import { overrideToFixedColor, PANEL_STYLES } from '../../home/Insights';
|
||||
import { INSTANCE_ID, overrideToFixedColor, PANEL_STYLES } from '../../home/Insights';
|
||||
import { InsightsRatingModal } from '../RatingModal';
|
||||
|
||||
export function getNotificationsScene(datasource: DataSourceRef, panelTitle: string) {
|
||||
const exprA = INSTANCE_ID
|
||||
? `sum by(cluster)(grafanacloud_instance_alertmanager_notifications_per_second{id="${INSTANCE_ID}"}) - sum by (cluster)(grafanacloud_instance_alertmanager_notifications_failed_per_second{id="${INSTANCE_ID}"})`
|
||||
: `sum by(cluster)(grafanacloud_instance_alertmanager_notifications_per_second) - sum by (cluster)(grafanacloud_instance_alertmanager_notifications_failed_per_second)`;
|
||||
|
||||
const exprB = INSTANCE_ID
|
||||
? `sum by(cluster)(grafanacloud_instance_alertmanager_notifications_failed_per_second{id="${INSTANCE_ID}"})`
|
||||
: `sum by(cluster)(grafanacloud_instance_alertmanager_notifications_failed_per_second)`;
|
||||
|
||||
const query = new SceneQueryRunner({
|
||||
datasource,
|
||||
queries: [
|
||||
{
|
||||
refId: 'A',
|
||||
expr: 'sum by(cluster)(grafanacloud_instance_alertmanager_notifications_per_second) - sum by (cluster)(grafanacloud_instance_alertmanager_notifications_failed_per_second)',
|
||||
exprA,
|
||||
range: true,
|
||||
legendFormat: 'success',
|
||||
},
|
||||
{
|
||||
refId: 'B',
|
||||
expr: 'sum by(cluster)(grafanacloud_instance_alertmanager_notifications_failed_per_second)',
|
||||
exprB,
|
||||
range: true,
|
||||
legendFormat: 'failed',
|
||||
},
|
||||
|
@ -3,16 +3,20 @@ import React from 'react';
|
||||
import { PanelBuilders, SceneFlexItem, SceneQueryRunner } from '@grafana/scenes';
|
||||
import { DataSourceRef, GraphDrawStyle, TooltipDisplayMode } from '@grafana/schema';
|
||||
|
||||
import { PANEL_STYLES } from '../../home/Insights';
|
||||
import { INSTANCE_ID, PANEL_STYLES } from '../../home/Insights';
|
||||
import { InsightsRatingModal } from '../RatingModal';
|
||||
|
||||
export function getSilencesScene(datasource: DataSourceRef, panelTitle: string) {
|
||||
const expr = INSTANCE_ID
|
||||
? `sum by (state) (grafanacloud_instance_alertmanager_silences{id="${INSTANCE_ID}"})`
|
||||
: `sum by (state) (grafanacloud_instance_alertmanager_silences)`;
|
||||
|
||||
const query = new SceneQueryRunner({
|
||||
datasource,
|
||||
queries: [
|
||||
{
|
||||
refId: 'A',
|
||||
expr: 'sum by (state) (grafanacloud_instance_alertmanager_silences)',
|
||||
expr,
|
||||
range: true,
|
||||
legendFormat: '{{state}}',
|
||||
},
|
||||
|
@ -3,16 +3,20 @@ import React from 'react';
|
||||
import { PanelBuilders, SceneFlexItem, SceneQueryRunner } from '@grafana/scenes';
|
||||
import { DataSourceRef, GraphDrawStyle, ThresholdsMode, TooltipDisplayMode } from '@grafana/schema';
|
||||
|
||||
import { PANEL_STYLES } from '../../../home/Insights';
|
||||
import { INSTANCE_ID, PANEL_STYLES } from '../../../home/Insights';
|
||||
import { InsightsRatingModal } from '../../RatingModal';
|
||||
|
||||
export function getRuleGroupEvaluationDurationIntervalRatioScene(datasource: DataSourceRef, panelTitle: string) {
|
||||
const expr = INSTANCE_ID
|
||||
? `grafanacloud_instance_rule_group_last_duration_seconds{rule_group="$rule_group", id="${INSTANCE_ID}"} / grafanacloud_instance_rule_group_interval_seconds{rule_group="$rule_group", id="${INSTANCE_ID}"}`
|
||||
: `grafanacloud_instance_rule_group_last_duration_seconds{rule_group="$rule_group"} / grafanacloud_instance_rule_group_interval_seconds{rule_group="$rule_group"}`;
|
||||
|
||||
const query = new SceneQueryRunner({
|
||||
datasource,
|
||||
queries: [
|
||||
{
|
||||
refId: 'A',
|
||||
expr: `grafanacloud_instance_rule_group_last_duration_seconds{rule_group="$rule_group"} / grafanacloud_instance_rule_group_interval_seconds{rule_group="$rule_group"}`,
|
||||
expr,
|
||||
range: true,
|
||||
legendFormat: 'duration / interval',
|
||||
},
|
||||
|
@ -3,16 +3,20 @@ import React from 'react';
|
||||
import { PanelBuilders, SceneFlexItem, SceneQueryRunner } from '@grafana/scenes';
|
||||
import { DataSourceRef, GraphDrawStyle, TooltipDisplayMode } from '@grafana/schema';
|
||||
|
||||
import { PANEL_STYLES } from '../../../home/Insights';
|
||||
import { INSTANCE_ID, PANEL_STYLES } from '../../../home/Insights';
|
||||
import { InsightsRatingModal } from '../../RatingModal';
|
||||
|
||||
export function getRuleGroupEvaluationDurationScene(datasource: DataSourceRef, panelTitle: string) {
|
||||
const expr = INSTANCE_ID
|
||||
? `grafanacloud_instance_rule_group_last_duration_seconds{rule_group="$rule_group", id="${INSTANCE_ID}"}`
|
||||
: `grafanacloud_instance_rule_group_last_duration_seconds{rule_group="$rule_group"}`;
|
||||
|
||||
const query = new SceneQueryRunner({
|
||||
datasource,
|
||||
queries: [
|
||||
{
|
||||
refId: 'A',
|
||||
expr: `grafanacloud_instance_rule_group_last_duration_seconds{rule_group="$rule_group"}`,
|
||||
expr,
|
||||
range: true,
|
||||
legendFormat: '{{rule_group}}',
|
||||
},
|
||||
|
@ -3,22 +3,30 @@ import React from 'react';
|
||||
import { PanelBuilders, SceneFlexItem, SceneQueryRunner } from '@grafana/scenes';
|
||||
import { DataSourceRef, GraphDrawStyle, TooltipDisplayMode } from '@grafana/schema';
|
||||
|
||||
import { overrideToFixedColor, PANEL_STYLES } from '../../../home/Insights';
|
||||
import { INSTANCE_ID, overrideToFixedColor, PANEL_STYLES } from '../../../home/Insights';
|
||||
import { InsightsRatingModal } from '../../RatingModal';
|
||||
|
||||
export function getRuleGroupEvaluationsScene(datasource: DataSourceRef, panelTitle: string) {
|
||||
const exprA = INSTANCE_ID
|
||||
? `grafanacloud_instance_rule_evaluations_total:rate5m{rule_group="$rule_group", id="${INSTANCE_ID}} - grafanacloud_instance_rule_evaluation_failures_total:rate5m{rule_group=~"$rule_group", id="${INSTANCE_ID}}`
|
||||
: `grafanacloud_instance_rule_evaluations_total:rate5m{rule_group="$rule_group"} - grafanacloud_instance_rule_evaluation_failures_total:rate5m{rule_group=~"$rule_group"}`;
|
||||
|
||||
const exprB = INSTANCE_ID
|
||||
? `grafanacloud_instance_rule_evaluation_failures_total:rate5m{rule_group=~"$rule_group", id="${INSTANCE_ID}}`
|
||||
: `grafanacloud_instance_rule_evaluation_failures_total:rate5m{rule_group=~"$rule_group"}`;
|
||||
|
||||
const query = new SceneQueryRunner({
|
||||
datasource,
|
||||
queries: [
|
||||
{
|
||||
refId: 'A',
|
||||
expr: `grafanacloud_instance_rule_evaluations_total:rate5m{rule_group="$rule_group"} - grafanacloud_instance_rule_evaluation_failures_total:rate5m{rule_group=~"$rule_group"}`,
|
||||
exprA,
|
||||
range: true,
|
||||
legendFormat: 'success',
|
||||
},
|
||||
{
|
||||
refId: 'B',
|
||||
expr: `grafanacloud_instance_rule_evaluation_failures_total:rate5m{rule_group=~"$rule_group"}`,
|
||||
exprB,
|
||||
range: true,
|
||||
legendFormat: 'failed',
|
||||
},
|
||||
|
@ -3,16 +3,20 @@ import React from 'react';
|
||||
import { PanelBuilders, SceneFlexItem, SceneQueryRunner } from '@grafana/scenes';
|
||||
import { BigValueGraphMode, DataSourceRef } from '@grafana/schema';
|
||||
|
||||
import { PANEL_STYLES } from '../../../home/Insights';
|
||||
import { INSTANCE_ID, PANEL_STYLES } from '../../../home/Insights';
|
||||
import { InsightsRatingModal } from '../../RatingModal';
|
||||
|
||||
export function getRuleGroupIntervalScene(datasource: DataSourceRef, panelTitle: string) {
|
||||
const expr = INSTANCE_ID
|
||||
? `grafanacloud_instance_rule_group_interval_seconds{rule_group="$rule_group", id="${INSTANCE_ID}"}`
|
||||
: `grafanacloud_instance_rule_group_interval_seconds{rule_group="$rule_group"}`;
|
||||
|
||||
const query = new SceneQueryRunner({
|
||||
datasource,
|
||||
queries: [
|
||||
{
|
||||
refId: 'A',
|
||||
expr: `grafanacloud_instance_rule_group_interval_seconds{rule_group="$rule_group"}`,
|
||||
expr,
|
||||
range: true,
|
||||
legendFormat: 'interval',
|
||||
},
|
||||
|
@ -3,16 +3,20 @@ import React from 'react';
|
||||
import { PanelBuilders, SceneFlexItem, SceneQueryRunner } from '@grafana/scenes';
|
||||
import { BigValueGraphMode, DataSourceRef } from '@grafana/schema';
|
||||
|
||||
import { PANEL_STYLES } from '../../../home/Insights';
|
||||
import { INSTANCE_ID, PANEL_STYLES } from '../../../home/Insights';
|
||||
import { InsightsRatingModal } from '../../RatingModal';
|
||||
|
||||
export function getRulesPerGroupScene(datasource: DataSourceRef, panelTitle: string) {
|
||||
const expr = INSTANCE_ID
|
||||
? `sum(grafanacloud_instance_rule_group_rules{rule_group="$rule_group", id="${INSTANCE_ID}"})`
|
||||
: `sum(grafanacloud_instance_rule_group_rules{rule_group="$rule_group"})`;
|
||||
|
||||
const query = new SceneQueryRunner({
|
||||
datasource,
|
||||
queries: [
|
||||
{
|
||||
refId: 'A',
|
||||
expr: `sum(grafanacloud_instance_rule_group_rules{rule_group="$rule_group"})`,
|
||||
expr,
|
||||
range: true,
|
||||
legendFormat: 'number of rules',
|
||||
},
|
||||
|
@ -3,22 +3,30 @@ import React from 'react';
|
||||
import { PanelBuilders, SceneFlexItem, SceneQueryRunner } from '@grafana/scenes';
|
||||
import { DataSourceRef, GraphDrawStyle, TooltipDisplayMode } from '@grafana/schema';
|
||||
|
||||
import { overrideToFixedColor, PANEL_STYLES } from '../../../home/Insights';
|
||||
import { INSTANCE_ID, overrideToFixedColor, PANEL_STYLES } from '../../../home/Insights';
|
||||
import { InsightsRatingModal } from '../../RatingModal';
|
||||
|
||||
export function getEvalSuccessVsFailuresScene(datasource: DataSourceRef, panelTitle: string) {
|
||||
const exprA = INSTANCE_ID
|
||||
? `sum(grafanacloud_instance_rule_evaluations_total:rate5m{id="${INSTANCE_ID}) - sum(grafanacloud_instance_rule_evaluation_failures_total:rate5m{id="${INSTANCE_ID})`
|
||||
: `sum(grafanacloud_instance_rule_evaluations_total:rate5m) - sum(grafanacloud_instance_rule_evaluation_failures_total:rate5m)`;
|
||||
|
||||
const exprB = INSTANCE_ID
|
||||
? `sum(grafanacloud_instance_rule_evaluation_failures_total:rate5m{id="${INSTANCE_ID})`
|
||||
: `sum(grafanacloud_instance_rule_evaluation_failures_total:rate5m)`;
|
||||
|
||||
const query = new SceneQueryRunner({
|
||||
datasource,
|
||||
queries: [
|
||||
{
|
||||
refId: 'A',
|
||||
expr: 'sum(grafanacloud_instance_rule_evaluations_total:rate5m) - sum(grafanacloud_instance_rule_evaluation_failures_total:rate5m)',
|
||||
exprA,
|
||||
range: true,
|
||||
legendFormat: 'success',
|
||||
},
|
||||
{
|
||||
refId: 'B',
|
||||
expr: 'sum(grafanacloud_instance_rule_evaluation_failures_total:rate5m)',
|
||||
exprB,
|
||||
range: true,
|
||||
legendFormat: 'failed',
|
||||
},
|
||||
|
@ -3,16 +3,20 @@ import React from 'react';
|
||||
import { PanelBuilders, SceneFlexItem, SceneQueryRunner } from '@grafana/scenes';
|
||||
import { DataSourceRef, GraphDrawStyle, TooltipDisplayMode } from '@grafana/schema';
|
||||
|
||||
import { overrideToFixedColor, PANEL_STYLES } from '../../../home/Insights';
|
||||
import { INSTANCE_ID, overrideToFixedColor, PANEL_STYLES } from '../../../home/Insights';
|
||||
import { InsightsRatingModal } from '../../RatingModal';
|
||||
|
||||
export function getMissedIterationsScene(datasource: DataSourceRef, panelTitle: string) {
|
||||
const expr = INSTANCE_ID
|
||||
? `sum(grafanacloud_instance_rule_group_iterations_missed_total:rate5m{id="${INSTANCE_ID}"})`
|
||||
: `sum(grafanacloud_instance_rule_group_iterations_missed_total:rate5m)`;
|
||||
|
||||
const query = new SceneQueryRunner({
|
||||
datasource,
|
||||
queries: [
|
||||
{
|
||||
refId: 'A',
|
||||
expr: 'sum(grafanacloud_instance_rule_group_iterations_missed_total:rate5m)',
|
||||
expr,
|
||||
range: true,
|
||||
legendFormat: 'missed',
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user