prometheus

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LabelNamespace             = "namespace"
	LabelServiceLevelObjective = "service_level_objective"
	LabelObjectiveName         = "objective_name"
	LabelObjectiveId           = "objective_id"
	LabelStatus                = "status"
)

Metric labels used across all metrics

Variables

View Source
var (

	// ObjectiveStatus indicates whether the SLO objective is met (1) or not (0)
	ObjectiveStatus = prometheus.NewGaugeVec(
		prometheus.GaugeOpts{
			Name: "slok_slo_objective_status",
			Help: "Status of the SLO objective (1 = met, 0 = not met)",
		},
		[]string{LabelNamespace, LabelServiceLevelObjective, LabelObjectiveName, LabelStatus, LabelObjectiveId},
	)

	ObjectivePercentRemaining = prometheus.NewGaugeVec(
		prometheus.GaugeOpts{
			Name: "slok_slo_objective_percent_remaining",
			Help: "Percentage of error budget remaining for the SLOss objective",
		},
		[]string{LabelNamespace, LabelServiceLevelObjective, LabelObjectiveName, LabelObjectiveId},
	)

	ObjectiveTarget = prometheus.NewGaugeVec(
		prometheus.GaugeOpts{
			Name: "slok_slo_objective_target",
			Help: "Target value for the SLO objective",
		},
		[]string{LabelNamespace, LabelServiceLevelObjective, LabelObjectiveName, LabelObjectiveId},
	)

	ObjectiveActual = prometheus.NewGaugeVec(
		prometheus.GaugeOpts{
			Name: "slok_slo_objective_actual",
			Help: "Actual value for the SLO objective",
		},
		[]string{LabelNamespace, LabelServiceLevelObjective, LabelObjectiveName, LabelObjectiveId},
	)
)

Functions

func CreateAggregatedPrometheusRule

func CreateAggregatedPrometheusRule(sloCompositionName, sloCompositionNamespace string, spec observabilityv1alpha1.SLOCompositionSpec, slos []observabilityv1alpha1.ServiceLevelObjective) (monitoringv1.PrometheusRule, error)

func CreatePrometheusRule

func CreatePrometheusRule(sloName, sloNamespace string, objective observabilityv1alpha1.Objective) (monitoringv1.PrometheusRule, error)

Types

type CacheEntry

type CacheEntry struct {
	// contains filtered or unexported fields
}

type CachedClient

type CachedClient struct {
	// contains filtered or unexported fields
}

func NewCachedClient

func NewCachedClient(client PrometheusClient, ttl time.Duration) *CachedClient

func (*CachedClient) CheckConnection

func (c *CachedClient) CheckConnection(ctx context.Context) error

func (*CachedClient) GetURL

func (c *CachedClient) GetURL() string

func (*CachedClient) QuerySLI

func (c *CachedClient) QuerySLI(ctx context.Context, query string) (float64, error)

func (*CachedClient) QuerySLINotNormalized

func (c *CachedClient) QuerySLINotNormalized(ctx context.Context, query string) (float64, error)

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(prometheusURL string) (*Client, error)

func (*Client) CheckConnection

func (c *Client) CheckConnection(ctx context.Context) error

CheckConnection verifies Prometheus is reachable

func (*Client) GetURL

func (c *Client) GetURL() string

func (*Client) QuerySLI

func (c *Client) QuerySLI(ctx context.Context, query string) (float64, error)

func (*Client) QuerySLINotNormalized

func (c *Client) QuerySLINotNormalized(ctx context.Context, query string) (float64, error)

type PrometheusClient

type PrometheusClient interface {
	QuerySLI(ctx context.Context, query string) (float64, error)
	CheckConnection(ctx context.Context) error
	QuerySLINotNormalized(ctx context.Context, query string) (float64, error)
	GetURL() string
}

PrometheusClient defines the interface for Prometheus operations

Jump to

Keyboard shortcuts

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