obsassets

package
v0.6.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 3, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

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

View Source
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.

View Source
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

func GrafanaAlerts(rf RuleFile) ([]byte, error)

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

func MetricNames(s string) []string

MetricNames returns the distinct halo_* metric names mentioned in s, histogram suffixes (_bucket, _sum, _count) included.

Types

type Group

type Group struct {
	Name  string `yaml:"name"`
	Rules []Rule `yaml:"rules"`
}

Group is a Prometheus rule group.

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

func ParseRules(b []byte) (RuleFile, error)

ParseRules decodes and validates the rule file: unique alert names, an expression, a severity label and a summary on every rule.

func (RuleFile) AlertNames

func (rf RuleFile) AlertNames() []string

AlertNames lists every alert in file order.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL