Skip to content

Commit

Permalink
Add new alert for no heap allocations
Browse files Browse the repository at this point in the history
A new alert for "No heap allocations" has been incorporated into the row/row_test.go file. This alert uses a Prometheus query and triggers if the average is below 0.01. The test assertions are updated accordingly to check for two alerts rather than one.
  • Loading branch information
lueurxax committed Apr 30, 2024
1 parent 5a1d1be commit 44c4aad
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions row/row_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,20 @@ func TestRowsCanHaveGraphsAndAlert(t *testing.T) {
),
alert.If(alert.Avg, "A", alert.IsAbove(3)),
),
graph.Alert(
"No heap allocations",
alert.WithPrometheusQuery(
"A",
"sum(go_memstats_heap_alloc_bytes{app!=\"\"}) by (app)",
),
alert.If(alert.Avg, "A", alert.IsBelow(0.01)),
),
),
)

req.NoError(err)
req.Len(panel.builder.Panels, 1)
req.Len(panel.Alerts(), 1)
req.Len(panel.Alerts(), 2)

req.Equal("Prometheus", panel.Alerts()[0].Datasource)
}
Expand Down Expand Up @@ -107,12 +115,20 @@ func TestRowsCanHaveTimeSeriesAndAlert(t *testing.T) {
),
alert.If(alert.Avg, "A", alert.IsAbove(3)),
),
timeseries.Alert(
"No heap allocations",
alert.WithPrometheusQuery(
"A",
"sum(go_memstats_heap_alloc_bytes{app!=\"\"}) by (app)",
),
alert.If(alert.Avg, "A", alert.IsBelow(0.01)),
),
),
)

req.NoError(err)
req.Len(panel.builder.Panels, 1)
req.Len(panel.Alerts(), 1)
req.Len(panel.Alerts(), 2)

req.Equal("Prometheus", panel.Alerts()[0].Datasource)
}
Expand Down

0 comments on commit 44c4aad

Please sign in to comment.