prometheus

package
v2.29.2 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2023 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Module

func Module() fx.Option

Module provides a singleton pointer to prometheusv1.API via FX.

func NewAlertQueryJob

func NewAlertQueryJob(
	query string,
	endTimestamp time.Time,
	promAPI prometheusv1.API,
	enforcer *PrometheusEnforcer,
	timeout time.Duration,
	forDuration time.Duration,
	alertActiveCallback,
	alertInactiveCallback AlertCallback,
	errorCallback PromErrorCallback,
	cbArgs ...interface{},
) jobs.JobCallback

NewAlertQueryJob takes Alert active and Alert inactive callbacks which get invoked when the alert gets active, inactive respectively. Also, it takes an error callback which gets invoked when there's an error from running PromQL. Alert is computed via a PromQL query using semantics similar to Prometheus alert rules. It returns a callback compatible with scheduler BasicJob.

func NewPromQueryJob

func NewPromQueryJob(
	query string,
	endTimestamp time.Time,
	promAPI prometheusv1.API,
	enforcer *PrometheusEnforcer,
	timeout time.Duration,
	resultCallback PromResultCallback,
	errorCallback PromErrorCallback,
	cbArgs ...interface{},
) jobs.JobCallback

NewPromQueryJob creates a new job that executes a prometheus query. It takes a PromResultCallback which gets invoked periodically with results of the query and an error callback which gets invoked when there's an error from running PromQL then it returns a callback compatible with scheduler BasicJob.

func NewScalarQueryJob

func NewScalarQueryJob(
	query string,
	endTimestamp time.Time,
	promAPI prometheusv1.API,
	enforcer *PrometheusEnforcer,
	timeout time.Duration,
	resultCallback ScalarResultCallback,
	errorCallback PromErrorCallback,
	cbArgs ...interface{},
) jobs.JobCallback

NewScalarQueryJob creates a new job that executes a prometheus query job with given scalar query.

Types

type AlertCallback

type AlertCallback func(context.Context, ...interface{}) (proto.Message, error)

AlertCallback is a callback function that gets invoked respectively when the alert gets active, inactive.

type ClientIn

type ClientIn struct {
	fx.In
	HTTPClient     *http.Client       `name:"prometheus.http-client"`
	TokenSource    oauth2.TokenSource `optional:"true"`
	Unmarshaller   config.Unmarshaller
	ConfigOverride *ConfigOverride `optional:"true"`
}

ClientIn holds fields, parameters, to provide Prometheus Client.

type ConfigOverride added in v2.9.0

type ConfigOverride struct {
	SkipClientCreation bool
}

ConfigOverride can be provided by an extension to control client creation behavior.

type EnforcerIn added in v2.8.0

type EnforcerIn struct {
	fx.In
	Unmarshaller config.Unmarshaller
}

EnforcerIn holds fields, parameters, to provide Prometheus Label Injector .

type PromErrorCallback

type PromErrorCallback func(error, ...interface{}) (proto.Message, error)

PromErrorCallback is a callback that gets invoked when there's an error from running PromQL.

type PromResultCallback

type PromResultCallback func(context.Context, prometheusmodel.Value, ...interface{}) (proto.Message, error)

PromResultCallback is a callback that gets invoked with the result of the prom query.

type PrometheusEnforcer added in v2.8.0

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

PrometheusEnforcer is responsible for enforcing extra set of labels that should be present in every PromQL query executed.

func (*PrometheusEnforcer) EnforceLabels added in v2.8.0

func (e *PrometheusEnforcer) EnforceLabels(query string) (string, error)

EnforceLabels transforms given query, making sure that all the required labels are in place.

type ScalarQuery

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

ScalarQuery is a wrapper that holds prometheus query and the ScalarResultCallback that returns the result of the scalar query.

type ScalarResultCallback

type ScalarResultCallback func(context.Context, float64, ...interface{}) (proto.Message, error)

ScalarResultCallback is a callback that gets invoked with the result of the scalar query.

Directories

Path Synopsis
+kubebuilder:validation:Optional
+kubebuilder:validation:Optional

Jump to

Keyboard shortcuts

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