-
| one is "alert" one is "expr" one is "for" alerting rules file like this: groups:
- name: example
  rules:
  - alert: HighRequestLatency
    expr: job:request_latency_seconds:mean5m{job="myjob"} > 0.5
    for: 10m
    labels:
      severity: page
    annotations:
      summary: High request latencyprometheus/prometheus, type Rule is type Rule struct {
	Record      string            `yaml:"record,omitempty"`
	Alert       string            `yaml:"alert,omitempty"`
	Expr        string            `yaml:"expr"`
	For         model.Duration    `yaml:"for,omitempty"`
	Labels      map[string]string `yaml:"labels,omitempty"`
	Annotations map[string]string `yaml:"annotations,omitempty"`
}but why prometheus/client_golang, type Rule is client_golang/api/prometheus/v1/api.go Line 350 in dc1559e type AlertingRule struct {
	Name           string         `json:"name"`
	Query          string         `json:"query"`
	Duration       float64        `json:"duration"`
	Labels         model.LabelSet `json:"labels"`
	Annotations    model.LabelSet `json:"annotations"`
	Alerts         []*Alert       `json:"alerts"`
	Health         RuleHealth     `json:"health"`
	LastError      string         `json:"lastError,omitempty"`
	EvaluationTime float64        `json:"evaluationTime"`
	LastEvaluation time.Time      `json:"lastEvaluation"`
	State          string         `json:"state"`
} | 
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
| @ikingye Hello, I believe type AlertingRule and RecordingRule type are mainly defined for the  At the rules API, additional data are added to enrich the raw rules https://github.com/prometheus/prometheus/blob/main/web/api/v1/api.go#L1235. Hope this helps. | 
Beta Was this translation helpful? Give feedback.
-
| Thanks @yeya24 | 
Beta Was this translation helpful? Give feedback.
-
| @ikingye Not sure what's your requirement exactly. Are you going to query prometheus API or just use the rule type? | 
Beta Was this translation helpful? Give feedback.
@ikingye Not sure what's your requirement exactly. Are you going to query prometheus API or just use the rule type?
If you need the API you can just use the API and structs provided in this repo.