2022-05-17 13:42:48 -05:00
|
|
|
package provisioning
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"fmt"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/grafana/grafana/pkg/infra/log"
|
2022-05-26 14:24:34 -05:00
|
|
|
"github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"
|
2022-05-17 13:42:48 -05:00
|
|
|
"github.com/grafana/grafana/pkg/services/ngalert/models"
|
2022-05-26 14:24:34 -05:00
|
|
|
"github.com/prometheus/alertmanager/config"
|
2022-05-17 13:42:48 -05:00
|
|
|
mock "github.com/stretchr/testify/mock"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestMuteTimingService(t *testing.T) {
|
|
|
|
t.Run("service returns timings from config file", func(t *testing.T) {
|
|
|
|
sut := createMuteTimingSvcSut()
|
|
|
|
sut.config.(*MockAMConfigStore).EXPECT().
|
2022-06-09 03:38:46 -05:00
|
|
|
GetsConfig(models.AlertConfiguration{
|
2022-05-17 13:42:48 -05:00
|
|
|
AlertmanagerConfiguration: configWithMuteTimings,
|
|
|
|
})
|
|
|
|
|
|
|
|
result, err := sut.GetMuteTimings(context.Background(), 1)
|
|
|
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
require.Len(t, result, 1)
|
|
|
|
require.Equal(t, "asdf", result[0].Name)
|
|
|
|
})
|
|
|
|
|
2022-05-23 18:16:03 -05:00
|
|
|
t.Run("service returns empty list when config file contains no mute timings", func(t *testing.T) {
|
2022-05-17 13:42:48 -05:00
|
|
|
sut := createMuteTimingSvcSut()
|
|
|
|
sut.config.(*MockAMConfigStore).EXPECT().
|
2022-06-09 03:38:46 -05:00
|
|
|
GetsConfig(models.AlertConfiguration{
|
2022-05-17 13:42:48 -05:00
|
|
|
AlertmanagerConfiguration: defaultConfig,
|
|
|
|
})
|
|
|
|
|
|
|
|
result, err := sut.GetMuteTimings(context.Background(), 1)
|
|
|
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
require.Empty(t, result)
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("service propagates errors", func(t *testing.T) {
|
|
|
|
t.Run("when unable to read config", func(t *testing.T) {
|
|
|
|
sut := createMuteTimingSvcSut()
|
|
|
|
sut.config.(*MockAMConfigStore).EXPECT().
|
|
|
|
GetLatestAlertmanagerConfiguration(mock.Anything, mock.Anything).
|
|
|
|
Return(fmt.Errorf("failed"))
|
|
|
|
|
|
|
|
_, err := sut.GetMuteTimings(context.Background(), 1)
|
|
|
|
|
|
|
|
require.Error(t, err)
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("when config is invalid", func(t *testing.T) {
|
|
|
|
sut := createMuteTimingSvcSut()
|
|
|
|
sut.config.(*MockAMConfigStore).EXPECT().
|
2022-06-09 03:38:46 -05:00
|
|
|
GetsConfig(models.AlertConfiguration{
|
2022-05-17 13:42:48 -05:00
|
|
|
AlertmanagerConfiguration: brokenConfig,
|
|
|
|
})
|
|
|
|
|
|
|
|
_, err := sut.GetMuteTimings(context.Background(), 1)
|
|
|
|
|
|
|
|
require.ErrorContains(t, err, "failed to deserialize")
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("when no AM config in current org", func(t *testing.T) {
|
|
|
|
sut := createMuteTimingSvcSut()
|
|
|
|
sut.config.(*MockAMConfigStore).EXPECT().
|
|
|
|
GetLatestAlertmanagerConfiguration(mock.Anything, mock.Anything).
|
|
|
|
Return(nil)
|
|
|
|
|
|
|
|
_, err := sut.GetMuteTimings(context.Background(), 1)
|
|
|
|
|
|
|
|
require.ErrorContains(t, err, "no alertmanager configuration")
|
|
|
|
})
|
|
|
|
})
|
2022-05-26 14:24:34 -05:00
|
|
|
|
|
|
|
t.Run("creating mute timings", func(t *testing.T) {
|
|
|
|
t.Run("rejects mute timings that fail validation", func(t *testing.T) {
|
|
|
|
sut := createMuteTimingSvcSut()
|
|
|
|
timing := definitions.MuteTimeInterval{
|
|
|
|
MuteTimeInterval: config.MuteTimeInterval{
|
|
|
|
Name: "",
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
_, err := sut.CreateMuteTiming(context.Background(), timing, 1)
|
|
|
|
|
|
|
|
require.ErrorIs(t, err, ErrValidation)
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("propagates errors", func(t *testing.T) {
|
|
|
|
t.Run("when unable to read config", func(t *testing.T) {
|
|
|
|
sut := createMuteTimingSvcSut()
|
|
|
|
timing := createMuteTiming()
|
|
|
|
sut.config.(*MockAMConfigStore).EXPECT().
|
|
|
|
GetLatestAlertmanagerConfiguration(mock.Anything, mock.Anything).
|
|
|
|
Return(fmt.Errorf("failed"))
|
|
|
|
|
|
|
|
_, err := sut.CreateMuteTiming(context.Background(), timing, 1)
|
|
|
|
|
|
|
|
require.Error(t, err)
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("when config is invalid", func(t *testing.T) {
|
|
|
|
sut := createMuteTimingSvcSut()
|
|
|
|
timing := createMuteTiming()
|
|
|
|
sut.config.(*MockAMConfigStore).EXPECT().
|
2022-06-09 03:38:46 -05:00
|
|
|
GetsConfig(models.AlertConfiguration{
|
2022-05-26 14:24:34 -05:00
|
|
|
AlertmanagerConfiguration: brokenConfig,
|
|
|
|
})
|
|
|
|
|
|
|
|
_, err := sut.CreateMuteTiming(context.Background(), timing, 1)
|
|
|
|
|
|
|
|
require.ErrorContains(t, err, "failed to deserialize")
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("when no AM config in current org", func(t *testing.T) {
|
|
|
|
sut := createMuteTimingSvcSut()
|
|
|
|
timing := createMuteTiming()
|
|
|
|
sut.config.(*MockAMConfigStore).EXPECT().
|
|
|
|
GetLatestAlertmanagerConfiguration(mock.Anything, mock.Anything).
|
|
|
|
Return(nil)
|
|
|
|
|
|
|
|
_, err := sut.CreateMuteTiming(context.Background(), timing, 1)
|
|
|
|
|
|
|
|
require.ErrorContains(t, err, "no alertmanager configuration")
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("when provenance fails to save", func(t *testing.T) {
|
|
|
|
sut := createMuteTimingSvcSut()
|
|
|
|
timing := createMuteTiming()
|
|
|
|
sut.config.(*MockAMConfigStore).EXPECT().
|
2022-06-09 03:38:46 -05:00
|
|
|
GetsConfig(models.AlertConfiguration{
|
2022-05-26 14:24:34 -05:00
|
|
|
AlertmanagerConfiguration: configWithMuteTimings,
|
|
|
|
})
|
2022-06-09 03:38:46 -05:00
|
|
|
sut.config.(*MockAMConfigStore).EXPECT().SaveSucceeds()
|
2022-05-26 14:24:34 -05:00
|
|
|
sut.prov.(*MockProvisioningStore).EXPECT().
|
|
|
|
SetProvenance(mock.Anything, mock.Anything, mock.Anything, mock.Anything).
|
|
|
|
Return(fmt.Errorf("failed to save provenance"))
|
|
|
|
|
|
|
|
_, err := sut.CreateMuteTiming(context.Background(), timing, 1)
|
|
|
|
|
|
|
|
require.ErrorContains(t, err, "failed to save provenance")
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("when AM config fails to save", func(t *testing.T) {
|
|
|
|
sut := createMuteTimingSvcSut()
|
|
|
|
timing := createMuteTiming()
|
|
|
|
sut.config.(*MockAMConfigStore).EXPECT().
|
2022-06-09 03:38:46 -05:00
|
|
|
GetsConfig(models.AlertConfiguration{
|
2022-05-26 14:24:34 -05:00
|
|
|
AlertmanagerConfiguration: configWithMuteTimings,
|
|
|
|
})
|
|
|
|
sut.config.(*MockAMConfigStore).EXPECT().
|
|
|
|
UpdateAlertmanagerConfiguration(mock.Anything, mock.Anything).
|
|
|
|
Return(fmt.Errorf("failed to save config"))
|
2022-06-09 03:38:46 -05:00
|
|
|
sut.prov.(*MockProvisioningStore).EXPECT().SaveSucceeds()
|
2022-05-26 14:24:34 -05:00
|
|
|
|
|
|
|
_, err := sut.CreateMuteTiming(context.Background(), timing, 1)
|
|
|
|
|
|
|
|
require.ErrorContains(t, err, "failed to save config")
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("updating mute timings", func(t *testing.T) {
|
|
|
|
t.Run("rejects mute timings that fail validation", func(t *testing.T) {
|
|
|
|
sut := createMuteTimingSvcSut()
|
|
|
|
timing := definitions.MuteTimeInterval{
|
|
|
|
MuteTimeInterval: config.MuteTimeInterval{
|
|
|
|
Name: "",
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
_, err := sut.UpdateMuteTiming(context.Background(), timing, 1)
|
|
|
|
|
|
|
|
require.ErrorIs(t, err, ErrValidation)
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("returns nil if timing does not exist", func(t *testing.T) {
|
|
|
|
sut := createMuteTimingSvcSut()
|
|
|
|
timing := createMuteTiming()
|
|
|
|
timing.Name = "does not exist"
|
|
|
|
sut.config.(*MockAMConfigStore).EXPECT().
|
2022-06-09 03:38:46 -05:00
|
|
|
GetsConfig(models.AlertConfiguration{
|
2022-05-26 14:24:34 -05:00
|
|
|
AlertmanagerConfiguration: configWithMuteTimings,
|
|
|
|
})
|
2022-06-09 03:38:46 -05:00
|
|
|
sut.config.(*MockAMConfigStore).EXPECT().SaveSucceeds()
|
|
|
|
sut.prov.(*MockProvisioningStore).EXPECT().SaveSucceeds()
|
2022-05-26 14:24:34 -05:00
|
|
|
|
|
|
|
updated, err := sut.UpdateMuteTiming(context.Background(), timing, 1)
|
|
|
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
require.Nil(t, updated)
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("propagates errors", func(t *testing.T) {
|
|
|
|
t.Run("when unable to read config", func(t *testing.T) {
|
|
|
|
sut := createMuteTimingSvcSut()
|
|
|
|
timing := createMuteTiming()
|
|
|
|
timing.Name = "asdf"
|
|
|
|
sut.config.(*MockAMConfigStore).EXPECT().
|
|
|
|
GetLatestAlertmanagerConfiguration(mock.Anything, mock.Anything).
|
|
|
|
Return(fmt.Errorf("failed"))
|
|
|
|
|
|
|
|
_, err := sut.UpdateMuteTiming(context.Background(), timing, 1)
|
|
|
|
|
|
|
|
require.Error(t, err)
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("when config is invalid", func(t *testing.T) {
|
|
|
|
sut := createMuteTimingSvcSut()
|
|
|
|
timing := createMuteTiming()
|
|
|
|
timing.Name = "asdf"
|
|
|
|
sut.config.(*MockAMConfigStore).EXPECT().
|
2022-06-09 03:38:46 -05:00
|
|
|
GetsConfig(models.AlertConfiguration{
|
2022-05-26 14:24:34 -05:00
|
|
|
AlertmanagerConfiguration: brokenConfig,
|
|
|
|
})
|
|
|
|
|
|
|
|
_, err := sut.UpdateMuteTiming(context.Background(), timing, 1)
|
|
|
|
|
|
|
|
require.ErrorContains(t, err, "failed to deserialize")
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("when no AM config in current org", func(t *testing.T) {
|
|
|
|
sut := createMuteTimingSvcSut()
|
|
|
|
timing := createMuteTiming()
|
|
|
|
timing.Name = "asdf"
|
|
|
|
sut.config.(*MockAMConfigStore).EXPECT().
|
|
|
|
GetLatestAlertmanagerConfiguration(mock.Anything, mock.Anything).
|
|
|
|
Return(nil)
|
|
|
|
|
|
|
|
_, err := sut.UpdateMuteTiming(context.Background(), timing, 1)
|
|
|
|
|
|
|
|
require.ErrorContains(t, err, "no alertmanager configuration")
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("when provenance fails to save", func(t *testing.T) {
|
|
|
|
sut := createMuteTimingSvcSut()
|
|
|
|
timing := createMuteTiming()
|
|
|
|
timing.Name = "asdf"
|
|
|
|
sut.config.(*MockAMConfigStore).EXPECT().
|
2022-06-09 03:38:46 -05:00
|
|
|
GetsConfig(models.AlertConfiguration{
|
2022-05-26 14:24:34 -05:00
|
|
|
AlertmanagerConfiguration: configWithMuteTimings,
|
|
|
|
})
|
2022-06-09 03:38:46 -05:00
|
|
|
sut.config.(*MockAMConfigStore).EXPECT().SaveSucceeds()
|
2022-05-26 14:24:34 -05:00
|
|
|
sut.prov.(*MockProvisioningStore).EXPECT().
|
|
|
|
SetProvenance(mock.Anything, mock.Anything, mock.Anything, mock.Anything).
|
|
|
|
Return(fmt.Errorf("failed to save provenance"))
|
|
|
|
|
|
|
|
_, err := sut.UpdateMuteTiming(context.Background(), timing, 1)
|
|
|
|
|
|
|
|
require.ErrorContains(t, err, "failed to save provenance")
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("when AM config fails to save", func(t *testing.T) {
|
|
|
|
sut := createMuteTimingSvcSut()
|
|
|
|
timing := createMuteTiming()
|
|
|
|
timing.Name = "asdf"
|
|
|
|
sut.config.(*MockAMConfigStore).EXPECT().
|
2022-06-09 03:38:46 -05:00
|
|
|
GetsConfig(models.AlertConfiguration{
|
2022-05-26 14:24:34 -05:00
|
|
|
AlertmanagerConfiguration: configWithMuteTimings,
|
|
|
|
})
|
|
|
|
sut.config.(*MockAMConfigStore).EXPECT().
|
|
|
|
UpdateAlertmanagerConfiguration(mock.Anything, mock.Anything).
|
|
|
|
Return(fmt.Errorf("failed to save config"))
|
2022-06-09 03:38:46 -05:00
|
|
|
sut.prov.(*MockProvisioningStore).EXPECT().SaveSucceeds()
|
2022-05-26 14:24:34 -05:00
|
|
|
|
|
|
|
_, err := sut.UpdateMuteTiming(context.Background(), timing, 1)
|
|
|
|
|
|
|
|
require.ErrorContains(t, err, "failed to save config")
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("deleting mute timings", func(t *testing.T) {
|
|
|
|
t.Run("returns nil if timing does not exist", func(t *testing.T) {
|
|
|
|
sut := createMuteTimingSvcSut()
|
|
|
|
sut.config.(*MockAMConfigStore).EXPECT().
|
2022-06-09 03:38:46 -05:00
|
|
|
GetsConfig(models.AlertConfiguration{
|
2022-05-26 14:24:34 -05:00
|
|
|
AlertmanagerConfiguration: configWithMuteTimings,
|
|
|
|
})
|
2022-06-09 03:38:46 -05:00
|
|
|
sut.config.(*MockAMConfigStore).EXPECT().SaveSucceeds()
|
|
|
|
sut.prov.(*MockProvisioningStore).EXPECT().SaveSucceeds()
|
2022-05-26 14:24:34 -05:00
|
|
|
|
|
|
|
err := sut.DeleteMuteTiming(context.Background(), "does not exist", 1)
|
|
|
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("propagates errors", func(t *testing.T) {
|
|
|
|
t.Run("when unable to read config", func(t *testing.T) {
|
|
|
|
sut := createMuteTimingSvcSut()
|
|
|
|
sut.config.(*MockAMConfigStore).EXPECT().
|
|
|
|
GetLatestAlertmanagerConfiguration(mock.Anything, mock.Anything).
|
|
|
|
Return(fmt.Errorf("failed"))
|
|
|
|
|
|
|
|
err := sut.DeleteMuteTiming(context.Background(), "asdf", 1)
|
|
|
|
|
|
|
|
require.Error(t, err)
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("when config is invalid", func(t *testing.T) {
|
|
|
|
sut := createMuteTimingSvcSut()
|
|
|
|
sut.config.(*MockAMConfigStore).EXPECT().
|
2022-06-09 03:38:46 -05:00
|
|
|
GetsConfig(models.AlertConfiguration{
|
2022-05-26 14:24:34 -05:00
|
|
|
AlertmanagerConfiguration: brokenConfig,
|
|
|
|
})
|
|
|
|
|
|
|
|
err := sut.DeleteMuteTiming(context.Background(), "asdf", 1)
|
|
|
|
|
|
|
|
require.ErrorContains(t, err, "failed to deserialize")
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("when no AM config in current org", func(t *testing.T) {
|
|
|
|
sut := createMuteTimingSvcSut()
|
|
|
|
sut.config.(*MockAMConfigStore).EXPECT().
|
|
|
|
GetLatestAlertmanagerConfiguration(mock.Anything, mock.Anything).
|
|
|
|
Return(nil)
|
|
|
|
|
|
|
|
err := sut.DeleteMuteTiming(context.Background(), "asdf", 1)
|
|
|
|
|
|
|
|
require.ErrorContains(t, err, "no alertmanager configuration")
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("when provenance fails to save", func(t *testing.T) {
|
|
|
|
sut := createMuteTimingSvcSut()
|
|
|
|
sut.config.(*MockAMConfigStore).EXPECT().
|
2022-06-09 03:38:46 -05:00
|
|
|
GetsConfig(models.AlertConfiguration{
|
2022-05-26 14:24:34 -05:00
|
|
|
AlertmanagerConfiguration: configWithMuteTimings,
|
|
|
|
})
|
2022-06-09 03:38:46 -05:00
|
|
|
sut.config.(*MockAMConfigStore).EXPECT().SaveSucceeds()
|
2022-05-26 14:24:34 -05:00
|
|
|
sut.prov.(*MockProvisioningStore).EXPECT().
|
|
|
|
DeleteProvenance(mock.Anything, mock.Anything, mock.Anything).
|
|
|
|
Return(fmt.Errorf("failed to save provenance"))
|
|
|
|
|
|
|
|
err := sut.DeleteMuteTiming(context.Background(), "asdf", 1)
|
|
|
|
|
|
|
|
require.ErrorContains(t, err, "failed to save provenance")
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("when AM config fails to save", func(t *testing.T) {
|
|
|
|
sut := createMuteTimingSvcSut()
|
|
|
|
sut.config.(*MockAMConfigStore).EXPECT().
|
2022-06-09 03:38:46 -05:00
|
|
|
GetsConfig(models.AlertConfiguration{
|
2022-05-26 14:24:34 -05:00
|
|
|
AlertmanagerConfiguration: configWithMuteTimings,
|
|
|
|
})
|
|
|
|
sut.config.(*MockAMConfigStore).EXPECT().
|
|
|
|
UpdateAlertmanagerConfiguration(mock.Anything, mock.Anything).
|
|
|
|
Return(fmt.Errorf("failed to save config"))
|
2022-06-09 03:38:46 -05:00
|
|
|
sut.prov.(*MockProvisioningStore).EXPECT().SaveSucceeds()
|
2022-05-26 14:24:34 -05:00
|
|
|
|
|
|
|
err := sut.DeleteMuteTiming(context.Background(), "asdf", 1)
|
|
|
|
|
|
|
|
require.ErrorContains(t, err, "failed to save config")
|
|
|
|
})
|
2022-06-04 00:48:24 -05:00
|
|
|
|
|
|
|
t.Run("when mute timing is used in route", func(t *testing.T) {
|
|
|
|
sut := createMuteTimingSvcSut()
|
|
|
|
sut.config.(*MockAMConfigStore).EXPECT().
|
2022-06-09 03:38:46 -05:00
|
|
|
GetsConfig(models.AlertConfiguration{
|
2022-06-04 00:48:24 -05:00
|
|
|
AlertmanagerConfiguration: configWithMuteTimingsInRoute,
|
|
|
|
})
|
|
|
|
|
|
|
|
err := sut.DeleteMuteTiming(context.Background(), "asdf", 1)
|
|
|
|
|
|
|
|
require.Error(t, err)
|
|
|
|
})
|
2022-05-26 14:24:34 -05:00
|
|
|
})
|
|
|
|
})
|
2022-05-17 13:42:48 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
func createMuteTimingSvcSut() *MuteTimingService {
|
|
|
|
return &MuteTimingService{
|
|
|
|
config: &MockAMConfigStore{},
|
|
|
|
prov: &MockProvisioningStore{},
|
|
|
|
xact: newNopTransactionManager(),
|
|
|
|
log: log.NewNopLogger(),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-05-26 14:24:34 -05:00
|
|
|
func createMuteTiming() definitions.MuteTimeInterval {
|
|
|
|
return definitions.MuteTimeInterval{
|
|
|
|
MuteTimeInterval: config.MuteTimeInterval{
|
|
|
|
Name: "interval",
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-05-17 13:42:48 -05:00
|
|
|
var configWithMuteTimings = `
|
|
|
|
{
|
|
|
|
"template_files": {
|
|
|
|
"a": "template"
|
|
|
|
},
|
|
|
|
"alertmanager_config": {
|
|
|
|
"route": {
|
|
|
|
"receiver": "grafana-default-email"
|
|
|
|
},
|
|
|
|
"mute_time_intervals": [{
|
|
|
|
"name": "asdf",
|
|
|
|
"time_intervals": [{
|
|
|
|
"times": [],
|
|
|
|
"weekdays": ["monday"]
|
|
|
|
}]
|
|
|
|
}],
|
|
|
|
"receivers": [{
|
|
|
|
"name": "grafana-default-email",
|
|
|
|
"grafana_managed_receiver_configs": [{
|
|
|
|
"uid": "",
|
|
|
|
"name": "email receiver",
|
|
|
|
"type": "email",
|
|
|
|
"isDefault": true,
|
|
|
|
"settings": {
|
|
|
|
"addresses": "<example@email.com>"
|
|
|
|
}
|
|
|
|
}]
|
|
|
|
}]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`
|
2022-06-04 00:48:24 -05:00
|
|
|
|
|
|
|
var configWithMuteTimingsInRoute = `
|
|
|
|
{
|
|
|
|
"template_files": {
|
|
|
|
"a": "template"
|
|
|
|
},
|
|
|
|
"alertmanager_config": {
|
|
|
|
"route": {
|
|
|
|
"receiver": "grafana-default-email",
|
|
|
|
"routes": [
|
|
|
|
{
|
|
|
|
"receiver": "grafana-default-email",
|
|
|
|
"mute_time_intervals": ["asdf"]
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
"mute_time_intervals": [{
|
|
|
|
"name": "asdf",
|
|
|
|
"time_intervals": [{
|
|
|
|
"times": [],
|
|
|
|
"weekdays": ["monday"]
|
|
|
|
}]
|
|
|
|
}],
|
|
|
|
"receivers": [{
|
|
|
|
"name": "grafana-default-email",
|
|
|
|
"grafana_managed_receiver_configs": [{
|
|
|
|
"uid": "",
|
|
|
|
"name": "email receiver",
|
|
|
|
"type": "email",
|
|
|
|
"isDefault": true,
|
|
|
|
"settings": {
|
|
|
|
"addresses": "<example@email.com>"
|
|
|
|
}
|
|
|
|
}]
|
|
|
|
}]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`
|