|
| 1 | +# Alerts observability library |
| 2 | + |
| 3 | +Single `ALERTS` signal with one alerts-overview dashboard (alertlist panel grouped by configurable labels). |
| 4 | +Note that this library doesn't provide prometheus alerts themselves, only alerts presenation as annotations and dashboard panel that can be easily imported into other libraries or mixins. |
| 5 | + |
| 6 | +## Example |
| 7 | + |
| 8 | +### Simple init |
| 9 | +```jsonnet |
| 10 | +local alertslib = import 'alerts-observ-lib/main.libsonnet'; |
| 11 | +
|
| 12 | +alertslib.new() |
| 13 | ++ alertslib.withConfigMixin({ |
| 14 | + filteringSelector: 'job="integrations/myapp"', |
| 15 | + groupLabels: ['cluster', 'container'], |
| 16 | + instanceLabels: ['instance'], |
| 17 | + uid: 'myapp', |
| 18 | +}) |
| 19 | +| asMonitoringMixin() |
| 20 | +``` |
| 21 | + |
| 22 | +### Import into another observ-lib |
| 23 | + |
| 24 | +``` |
| 25 | +# dashboards.libsonnet |
| 26 | +local g = import './g.libsonnet'; |
| 27 | +local commonlib = import 'common-lib/common/main.libsonnet'; |
| 28 | +local alertsOverviewlib = import 'alerts-observ-lib/main.libsonnet'; |
| 29 | +
|
| 30 | +
|
| 31 | +{ |
| 32 | + new(this): |
| 33 | + { |
| 34 | + local alertsOverview = |
| 35 | + alertsOverviewlib.new() |
| 36 | + + alertsOverviewlib.withConfigMixin(this.config), |
| 37 | +
|
| 38 | + 'some-dashboard-overview.json': |
| 39 | + g.dashboard.new(this.config.dashboardNamePrefix + 'overview') |
| 40 | + + g.dashboard.withUid(this.config.uid + '-overview') |
| 41 | + + g.dashboard.withTags(this.config.dashboardTags) |
| 42 | + //insert here annotations: |
| 43 | + + g.dashboard.withAnnotations(std.objectValues(alertsOverview.grafana.annotations)) |
| 44 | + + g.dashboard.withPanels( |
| 45 | + g.util.grid.wrapPanels( |
| 46 | + g.util.panel.resolveCollapsedFlagOnRows( |
| 47 | + [ |
| 48 | + g.panel.row.new('Overview') |
| 49 | + + g.panel.row.withCollapsed(false) |
| 50 | + + g.panel.row.withPanels( |
| 51 | + [ |
| 52 | + //insert here resized alerts panel annotations |
| 53 | + alertsOverview.grafana.panels.alertsOverview { gridPos: { w: 12, h: 12 } }, |
| 54 | + // some other panel |
| 55 | + panels.serviceMap { gridPos: { w: 12, h: 12 } }, |
| 56 | + ], |
| 57 | + ), |
| 58 | + ], |
| 59 | + ), |
| 60 | + ), setPanelIDs=false // required to reuse queries |
| 61 | + ), |
| 62 | + }, |
| 63 | +} |
| 64 | +
|
| 65 | +
|
| 66 | +``` |
0 commit comments