[v10.0.x] Alerting: Add support for Alert State History Loki primary (#69077)

Alerting: Add support for Alert State History Loki primary (#69065)

add support for multiple ash targets with loki as primary

(cherry picked from commit 73681a251e)

Co-authored-by: Gilles De Mey <gilles.de.mey@gmail.com>
This commit is contained in:
Grot (@grafanabot)
2023-05-25 14:00:33 +00:00
committed by GitHub
co-authored by Gilles De Mey
parent dc6fb6d7a4
commit 95726f1530
5 changed files with 21 additions and 5 deletions
@@ -76,6 +76,8 @@ export interface UnifiedAlertingConfig {
minInterval: string;
// will be undefined if alerStateHistory is not enabled
alertStateHistoryBackend?: string;
// will be undefined if implementation is not "multiple"
alertStateHistoryPrimary?: string;
}
/** Supported OAuth services
+5 -1
View File
@@ -135,7 +135,11 @@ export class GrafanaBootConfig implements GrafanaConfig {
geomapDefaultBaseLayerConfig?: MapLayerOptions;
geomapDisableCustomBaseLayer?: boolean;
unifiedAlertingEnabled = false;
unifiedAlerting = { minInterval: '', alertStateHistoryBackend: undefined };
unifiedAlerting = {
minInterval: '',
alertStateHistoryBackend: undefined,
alertStateHistoryPrimary: undefined,
};
applicationInsightsConnectionString?: string;
applicationInsightsEndpointUrl?: string;
recordedQueries = {
+1
View File
@@ -63,6 +63,7 @@ type FrontendSettingsReportingDTO struct {
type FrontendSettingsUnifiedAlertingDTO struct {
MinInterval string `json:"minInterval"`
AlertStateHistoryBackend string `json:"alertStateHistoryBackend,omitempty"`
AlertStateHistoryPrimary string `json:"alertStateHistoryPrimary,omitempty"`
}
// Enterprise-only
+1
View File
@@ -235,6 +235,7 @@ func (hs *HTTPServer) getFrontendSettings(c *contextmodel.ReqContext) (*dtos.Fro
if hs.Cfg.UnifiedAlerting.StateHistory.Enabled {
frontendSettings.UnifiedAlerting.AlertStateHistoryBackend = hs.Cfg.UnifiedAlerting.StateHistory.Backend
frontendSettings.UnifiedAlerting.AlertStateHistoryPrimary = hs.Cfg.UnifiedAlerting.StateHistory.MultiPrimary
}
if hs.Cfg.UnifiedAlerting.Enabled != nil {
@@ -20,10 +20,18 @@ function useStateHistoryModal() {
const styles = useStyles2(getStyles);
const implementation =
config.unifiedAlerting.alertStateHistoryBackend === StateHistoryImplementation.Loki
? StateHistoryImplementation.Loki
: StateHistoryImplementation.Annotations;
// can be "loki", "multiple" or "annotations"
const stateHistoryBackend = config.unifiedAlerting.alertStateHistoryBackend;
// can be "loki" or "annotations"
const stateHistoryPrimary = config.unifiedAlerting.alertStateHistoryPrimary;
// if "loki" is either the backend or the primary, show the new state history implementation
const usingNewAlertStateHistory = [stateHistoryBackend, stateHistoryPrimary].some(
(implementation) => implementation === StateHistoryImplementation.Loki
);
const implementation = usingNewAlertStateHistory
? StateHistoryImplementation.Loki
: StateHistoryImplementation.Annotations;
const dismissModal = useCallback(() => {
setRule(undefined);