promql

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: May 2, 2023 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoQueriesReturned = errors.New("no queries returned until now")

ErrNoQueriesReturned is returned when no queries are returned by the policy (initial state).

Functions

func Module

func Module() fx.Option

Module returns fx options for PromQL in the main app.

func ModuleForPolicyApp

func ModuleForPolicyApp(circuitAPI runtime.CircuitAPI) fx.Option

ModuleForPolicyApp returns fx options for PromQL in the policy app. Invoked only once per policy.

Types

type PromQL

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

PromQL is a component that runs a Prometheus query in the background and returns the result as a signal Reading.

func NewPromQLAndOptions

func NewPromQLAndOptions(
	promQLProto *policylangv1.PromQL,
	componentID string,
	policyReadAPI iface.Policy,
) (*PromQL, fx.Option, error)

NewPromQLAndOptions creates PromQL and its fx options.

func (*PromQL) DynamicConfigUpdate

func (promQL *PromQL) DynamicConfigUpdate(event notifiers.Event, unmarshaller config.Unmarshaller)

DynamicConfigUpdate is a no-op for PromQL.

func (*PromQL) Execute

func (promQL *PromQL) Execute(inPortReadings runtime.PortToReading,
	tickInfo runtime.TickInfo,
) (outPortReadings runtime.PortToReading, err error)

Execute implements runtime.Component.Execute.

func (*PromQL) IsActuator added in v1.1.0

func (*PromQL) IsActuator() bool

IsActuator implements runtime.Component.

func (*PromQL) Name

func (*PromQL) Name() string

Name implements runtime.Component.

func (*PromQL) ShortDescription

func (promQL *PromQL) ShortDescription() string

ShortDescription implements runtime.Component.

func (*PromQL) Type

func (*PromQL) Type() runtime.ComponentType

Type implements runtime.Component.

type ScalarQuery

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

ScalarQuery is a construct that can be used by other components to get tick aligned scalar results of a PromQL query.

func NewScalarQueryAndOptions

func NewScalarQueryAndOptions(
	queryString string,
	evaluationInterval time.Duration,
	componentID string,
	policyReadAPI iface.Policy,
	jobPostFix string,
) (*ScalarQuery, fx.Option, error)

NewScalarQueryAndOptions creates a new ScalarQuery and its fx options.

func (*ScalarQuery) ExecuteScalarQuery

func (scalarQuery *ScalarQuery) ExecuteScalarQuery(tickInfo runtime.TickInfo) (ScalarResult, error)

ExecuteScalarQuery runs a ScalarQueryJob and returns the current results: value and err. This function is supposed to be run under Circuit Execution Lock (Execution of Circuit Components is protected by this lock).

type ScalarResult

type ScalarResult struct {
	TickInfo runtime.TickInfo
	Value    float64
}

ScalarResult is the result of a ScalarQuery.

type TaggedQuery

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

TaggedQuery is a construct that can be used by other components to get tick aligned prometheus value results of a PromQL query.

func NewTaggedQueryAndOptions

func NewTaggedQueryAndOptions(
	queryString string,
	evaluationInterval time.Duration,
	componentID string,
	policyReadAPI iface.Policy,
	jobPostFix string,
) (*TaggedQuery, fx.Option, error)

NewTaggedQueryAndOptions creates a new TaggedQuery and its fx options.

func (*TaggedQuery) ExecuteTaggedQuery

func (taggedQuery *TaggedQuery) ExecuteTaggedQuery(tickInfo runtime.TickInfo) (TaggedResult, error)

ExecuteTaggedQuery runs a PromQueryJob and returns the current results: res and err. This function is supposed to be run under Circuit Execution Lock (Execution of Circuit Components is protected by this lock).

type TaggedResult

type TaggedResult struct {
	TickInfo runtime.TickInfo
	Value    prometheusmodel.Value
}

TaggedResult is the result of a ScalarQuery.

Jump to

Keyboard shortcuts

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