Documentation ¶
Index ¶
- func Module() fx.Option
- func NewAlertQueryJob(query string, endTimestamp time.Time, promAPI prometheusv1.API, ...) jobs.JobCallback
- func NewPromQueryJob(query string, endTimestamp time.Time, promAPI prometheusv1.API, ...) jobs.JobCallback
- func NewScalarQueryJob(query string, endTimestamp time.Time, promAPI prometheusv1.API, ...) jobs.JobCallback
- type AlertCallback
- type ClientIn
- type PromErrorCallback
- type PromResultCallback
- type ScalarQuery
- type ScalarResultCallback
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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 ¶
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 ¶
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.