Files
grafana/pkg/services/ngalert/models/provisioning.go
Alexander Akhmetov b641fd64f9 Alerting: API to create rule groups using mimirtool (#100558)
What is this feature?

Adds an API endpoint to create alert rules with mimirtool:

- POST /convert/prometheus/config/v1/rules/{NamespaceTitle} - Accepts a single rule group in a Prometheus YAML format and creates or updates a Grafana rule group from it.

The endpoint uses the conversion package from #100224.

Key parts

The API works similarly to the provisioning API. If the rule does not exist, it will be created, otherwise updated. Any rules not present in the new group will be deleted, ensuring the group is fully synchronized with the provided configuration.

Since the API works with namespace titles (folders), the handler automatically creates a folder in the root based on the provided title if it does not exist. It also requires a special header, X-Grafana-Alerting-Datasource-UID. This header specifies which datasource to use for the new rules.

If the rule group's evaluation interval is not specified, it uses the DefaultRuleEvaluationInterval from settings.
2025-02-25 11:26:36 +01:00

24 lines
756 B
Go

package models
type Provenance string
const (
// ProvenanceNone reflects the provenance when no provenance is stored
// for the requested object in the database.
ProvenanceNone Provenance = ""
ProvenanceAPI Provenance = "api"
ProvenanceFile Provenance = "file"
// ProvenanceConvertedPrometheus is used for objects converted from Prometheus definitions.
ProvenanceConvertedPrometheus Provenance = "converted_prometheus"
)
var (
KnownProvenances = []Provenance{ProvenanceNone, ProvenanceAPI, ProvenanceFile, ProvenanceConvertedPrometheus}
)
// Provisionable represents a resource that can be created through a provisioning mechanism, such as Terraform or config file.
type Provisionable interface {
ResourceType() string
ResourceID() string
}