Documentation
¶
Index ¶
- func BuildinfoHandlerFunc(logger log.Logger, binaryName, binaryVersion string) func(http.ResponseWriter, *http.Request)
- func WriteError(logger log.Logger, w http.ResponseWriter, errType ErrorType, errMsg string, ...)
- func WriteSuccessResponse[T RulesResponseData | AlertsResponseData | promapiv1.PrometheusVersion](logger log.Logger, w http.ResponseWriter, httpResponseCode int, ...)
- type AlertsResponseData
- type ErrorType
- type GenericResponseData
- type Response
- type RulesResponseData
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildinfoHandlerFunc ¶ added in v0.17.0
func BuildinfoHandlerFunc(logger log.Logger, binaryName, binaryVersion string) func(http.ResponseWriter, *http.Request)
BuildinfoHandlerFunc simulates the /api/v1/status/buildinfo prometheus endpoint. It is used by Grafana to determine the Prometheus flavor, e.g. to check whether the ruler-api is enabled. binary: e.g. "frontend" or "rule-evaluator".
func WriteError ¶
func WriteError(logger log.Logger, w http.ResponseWriter, errType ErrorType, errMsg string, httpResponseCode int, endpointURI string)
WriteError writes an error Response to the given responseWriter w.
func WriteSuccessResponse ¶
func WriteSuccessResponse[T RulesResponseData | AlertsResponseData | promapiv1.PrometheusVersion](logger log.Logger, w http.ResponseWriter, httpResponseCode int, endpointURI string, responseData T)
WriteSuccessResponse writes a successful Response to the given responseWriter w.
Types ¶
type AlertsResponseData ¶
type GenericResponseData ¶
type GenericResponseData interface{}
type Response ¶
type Response[T RulesResponseData | AlertsResponseData | GenericResponseData] struct { Status status `json:"status"` Data T `json:"data,omitempty"` ErrorType ErrorType `json:"errorType,omitempty"` Error string `json:"error,omitempty"` Warnings []string `json:"warnings,omitempty"` Infos []string `json:"infos,omitempty"` }
https://prometheus.io/docs/prometheus/latest/querying/api/#format-overview Response is the prometheus-compatible Response format.
type RulesResponseData ¶
Click to show internal directories.
Click to hide internal directories.