Skip to content

Instantly share code, notes, and snippets.

@kylebrandt
Last active February 16, 2021 21:11
Show Gist options
  • Save kylebrandt/3074065e35489f783fe3b0928fef06f4 to your computer and use it in GitHub Desktop.
Save kylebrandt/3074065e35489f783fe3b0928fef06f4 to your computer and use it in GitHub Desktop.
Dashboard Alerting keep state issues
{
name: "pending -> error(keep) with for duration have passed",
expected: models.AlertStatePending,
applyFn: func(ec *EvalContext) {
ec.PrevAlertState = models.AlertStatePending
ec.Rule.ExecutionErrorState = models.ExecutionErrorKeepState
ec.Error = errors.New("test error")
ec.Rule.For = time.Minute * 5
ec.Rule.LastStateChange = time.Now().Add(-time.Minute * 20)
},
},
{
name: "pending -> error(keep) with for duration have not passed",
expected: models.AlertStatePending,
applyFn: func(ec *EvalContext) {
ec.PrevAlertState = models.AlertStatePending
ec.Rule.ExecutionErrorState = models.ExecutionErrorKeepState
ec.Error = errors.New("test error")
ec.Rule.For = time.Minute * 5
ec.Rule.LastStateChange = time.Now().Add(-time.Minute * 2)
},
},
{
name: "pending -> no_data(keep_last) with for duration have passed",
expected: models.AlertStatePending,
applyFn: func(ec *EvalContext) {
ec.PrevAlertState = models.AlertStatePending
ec.Rule.NoDataState = models.NoDataKeepState
ec.NoDataFound = true
ec.Rule.For = time.Minute * 5
ec.Rule.LastStateChange = time.Now().Add(-time.Minute * 20)
},
},
{
name: "pending -> no_data(keep_last) with for duration have not passed",
expected: models.AlertStatePending,
applyFn: func(ec *EvalContext) {
ec.PrevAlertState = models.AlertStatePending
ec.Rule.NoDataState = models.NoDataKeepState
ec.NoDataFound = true
ec.Rule.For = time.Minute * 5
ec.Rule.LastStateChange = time.Now().Add(-time.Minute * 2)
},
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment