mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
* Add new scenes for grafana managed alerts * Remove unused import * Fix lint * Remove width property from SceneFlexItem * Add missing scenes for GMA section * Improve scenes layout * Add Grafana Alertmanager panels * Fix lint * Fix lint * Refactor expression variables * Apply shared styles to scenes
41 lines
1014 B
TypeScript
41 lines
1014 B
TypeScript
import { ThresholdsMode } from '@grafana/data';
|
|
import { PanelBuilders, SceneFlexItem, SceneQueryRunner, SceneTimeRange } from '@grafana/scenes';
|
|
import { DataSourceRef } from '@grafana/schema';
|
|
|
|
import { PANEL_STYLES } from '../../../home/Insights';
|
|
|
|
export function getPendingCloudAlertsScene(timeRange: SceneTimeRange, datasource: DataSourceRef, panelTitle: string) {
|
|
const query = new SceneQueryRunner({
|
|
datasource,
|
|
queries: [
|
|
{
|
|
refId: 'A',
|
|
instant: true,
|
|
expr: 'sum by (alertstate) (ALERTS{alertstate="pending"})',
|
|
},
|
|
],
|
|
$timeRange: timeRange,
|
|
});
|
|
|
|
return new SceneFlexItem({
|
|
...PANEL_STYLES,
|
|
body: PanelBuilders.stat()
|
|
.setTitle(panelTitle)
|
|
.setData(query)
|
|
.setThresholds({
|
|
mode: ThresholdsMode.Absolute,
|
|
steps: [
|
|
{
|
|
color: 'yellow',
|
|
value: 0,
|
|
},
|
|
{
|
|
color: 'red',
|
|
value: 80,
|
|
},
|
|
],
|
|
})
|
|
.build(),
|
|
});
|
|
}
|