You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: wasp/alert.go
+15-2Lines changed: 15 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -23,6 +23,10 @@ type AlertChecker struct {
23
23
grafanaClient*grafana.Client
24
24
}
25
25
26
+
// NewAlertChecker initializes a new AlertChecker instance by retrieving the Grafana URL and API token from the environment variables.
27
+
// It panics if either the GRAFANA_URL or GRAFANA_TOKEN environment variable is not set, ensuring that the necessary configuration is available.
28
+
// The function creates a Grafana client using the provided URL and API token, and sets up the AlertChecker with a default requirement label key and a logger.
29
+
// It returns a pointer to the newly created AlertChecker instance, which can be used for checking alerts in Grafana.
// CheckDashobardAlerts checks for alerts in the given dashboardUUIDs between from and to times
87
+
// CheckDashboardAlerts retrieves annotations of type "alert" from a specified Grafana dashboard within a given time range.
88
+
// It returns a slice of annotations and an error if any occurred during the retrieval process.
89
+
// If the retrieval is successful, the function sorts the annotations by time from oldest to newest and checks if any alerts are in an "alerting" state.
90
+
// If at least one alert is found to be firing, it returns the annotations along with an error indicating that an alert was firing.
91
+
// If no alerts are firing, it returns the annotations with a nil error.
79
92
funcCheckDashboardAlerts(grafanaClient*grafana.Client, from, to time.Time, dashboardUIDstring) ([]grafana.Annotation, error) {
0 commit comments