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 ConfigOverride
- type EnforcerIn
- type PromErrorCallback
- type PromResultCallback
- type PrometheusEnforcer
- 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, 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 ¶
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 ¶
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.