Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( Equal = nameToOperator("=") // Value = 1. Equal translates to using '=' operator. NotEqual = nameToOperator("!=") // NotEqual translates to using '!=' operator. EqualRegex = nameToOperator("=~") // EqualRegex translates to using '=~' operator. NotEqualRegex = nameToOperator("!=~") // NotEqualRegex translates to using '!=~' operator. )
Starting indices from 1 to not have Equal as the default matching operator. This also helps checking if a matching operator was provided. If the value is 0, then it would indicate that no matching operator was provided.
var ( Other = labelTypeIota() // Default label type. TaskID = labelTypeIota() // Indicates a dedicated label that can be keyed in to get unique task identifier. TaskHostname = labelTypeIota() // Indicates a dedicated label that can be keyed in to get name of host on which task is running. )
By default, label matchers are assigned the "Other" type. However, if the label in a label matcher can be used to fetch the task identifier and/or name of the host on which the task is currently running, the type of the label matcher should be set to TaskID or TaskHostname respectively.
var ( Seconds = nameToUnit("s") // Value = 1 Minutes = nameToUnit("m") Hours = nameToUnit("h") Days = nameToUnit("d") Weeks = nameToUnit("w") Years = nameToUnit("y") None = nameToUnit("none") // Represents nil value for TimeUnit. )
Starting indices from 1 to not have Seconds as the default time unit. This also helps checking if a time unit was provided. If the value is 0, then it would indicate that time unit was not provided.
Functions ¶
This section is empty.
Types ¶
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
Builder represents a query builder that is used to build a query string in promQL format.
func NewBuilder ¶ added in v0.4.0
NewBuilder returns a new Builder by applying all the given options.
func (Builder) BuildQuery ¶
BuildQuery builds and returns the query string.
type LabelMatchOperator ¶
type LabelMatchOperator int
Label match operator to use when filtering time series data.
func (LabelMatchOperator) IsValid ¶
func (o LabelMatchOperator) IsValid() bool
IsValid returns if an operator is valid.
func (LabelMatchOperator) String ¶
func (o LabelMatchOperator) String() string
String returns the string representation of the operator.
type LabelMatcher ¶
type LabelMatcher struct { // Type of the label matcher. // This information is used internally and is not required to build the prometheus query. // If Type != Other, then label matcher is considered a dedicated label matcher. Type LabelType // Label name used to filter the time series data. Label string // Operator is used to specify the operator to use when matching (=, !=, =~, !=~). Operator LabelMatchOperator // Value to match for. // If the regex matching, then value represents the regular expression. Value string }
LabelMatcher represents a single label matcher containing the label name (key), the matching operator and the value.
func (LabelMatcher) String ¶
func (m LabelMatcher) String() string
String returns the label, operator and value in the format <Label><Operator>"<Value>". This string can directly be used in the query string.
type Option ¶
type Option func(*Builder)
func WithLabelMatchers ¶
func WithLabelMatchers(labelMatchers ...*LabelMatcher) Option
WithLabelMatchers returns an option that initializes the label matchers to use as filters in the query string.
func WithMetric ¶
WithMetric returns an option that initializes the name of the metric to query.