prometheus

package
v1.6.0-rc.1 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2023 License: Apache-2.0 Imports: 18 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,
	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,
	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,
	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"`
	Unmarshaller config.Unmarshaller
}

ClientIn holds fields, parameters, to provide Prometheus Client.

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 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