promapi

package
v0.15.0-rc.0 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

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](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 AlertsResponseData struct {
	Alerts []*promapiv1.Alert `json:"alerts"`
}

type ErrorType

type ErrorType string
const (
	ErrorNone        ErrorType = ""
	ErrorTimeout     ErrorType = "timeout"
	ErrorCanceled    ErrorType = "canceled"
	ErrorExec        ErrorType = "execution"
	ErrorBadData     ErrorType = "bad_data"
	ErrorInternal    ErrorType = "internal"
	ErrorUnavailable ErrorType = "unavailable"
	ErrorNotFound    ErrorType = "not_found"
)

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

type RulesResponseData struct {
	Groups []*promapiv1.RuleGroup `json:"groups"`
}

Jump to

Keyboard shortcuts

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