Documentation
¶
Overview ¶
Package obsassets keeps the observability assets that exist in more than one form in step.
The alert rules live once, in deploy/helm/halos/files/prometheus-rules.yaml (Prometheus rule-group syntax). The chart renders them as a PrometheusRule, and GrafanaAlerts derives the Grafana unified-alerting provisioning file from them so a team on Grafana alerting gets the same alerts. The dashboards live once in deploy/observability/grafana/dashboards and the chart ships byte-identical copies. `go run ./internal/tools/obsassets` regenerates the derived files; the package test fails when a committed copy drifts, when an alert is missing from the operations guide, or when a rule or panel names a metric that no binary exports.
Index ¶
Constants ¶
const ( RulesPath = "deploy/helm/halos/files/prometheus-rules.yaml" GrafanaAlertsPath = "deploy/observability/grafana/provisioning/alerting/halos-alerts.yaml" DashboardsDir = "deploy/observability/grafana/dashboards" ChartDashboardsDir = "deploy/helm/halos/files/dashboards" OperationsGuide = "docs/src/content/docs/guides/operations.md" )
Paths, relative to the repository root.
const DatasourceUID = "prometheus"
DatasourceUID is the Grafana datasource uid the generated alert queries use. It is the uid kube-prometheus-stack gives its Prometheus datasource; change it in the generated file (or provision a datasource with this uid) for another setup.
Variables ¶
This section is empty.
Functions ¶
func GrafanaAlerts ¶
GrafanaAlerts renders rf as a Grafana alert-rule provisioning file.
A Prometheus alert fires for every series its expression returns. Grafana evaluates a rule from a condition instead, so each rule becomes: A the expression as an instant query rewritten to `(expr) * 0 + 1` (the same series, with the value 1, labels kept so annotations like {{ $labels.sink }} still resolve), B reduce A to its last value, C threshold B > 0. An empty result is "no data", which maps to OK, exactly as an alert that returns nothing in Prometheus.
func MetricNames ¶
MetricNames returns the distinct halo_* metric names mentioned in s, histogram suffixes (_bucket, _sum, _count) included.
Types ¶
type Rule ¶
type Rule struct {
Alert string `yaml:"alert"`
Expr string `yaml:"expr"`
For string `yaml:"for,omitempty"`
Labels map[string]string `yaml:"labels,omitempty"`
Annotations map[string]string `yaml:"annotations,omitempty"`
}
Rule is one Prometheus alerting rule.
type RuleFile ¶
type RuleFile struct {
Groups []Group `yaml:"groups"`
}
RuleFile is the content of prometheus-rules.yaml.
func ParseRules ¶
ParseRules decodes and validates the rule file: unique alert names, an expression, a severity label and a summary on every rule.
func (RuleFile) AlertNames ¶
AlertNames lists every alert in file order.