Documentation
¶
Overview ¶
Copyright 2013 Prometheus Team * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License.
Index ¶
- Constants
- func GraphLinkForExpression(expr string) string
- func LoadExprFromFile(fileName string) (ast.Node, error)
- func LoadExprFromReader(exprReader io.Reader) (ast.Node, error)
- func LoadExprFromString(exprString string) (ast.Node, error)
- func NewArithExpr(opTypeStr string, lhs ast.Node, rhs ast.Node) (ast.Node, error)
- func NewFunctionCall(name string, args []ast.Node) (ast.Node, error)
- func NewMatrixSelector(vector ast.Node, intervalStr string) (ast.MatrixNode, error)
- func NewVectorAggregation(aggrTypeStr string, vector ast.Node, groupBy clientmodel.LabelNames, ...) (*ast.VectorAggregation, error)
- func TableLinkForExpression(expr string) string
- type Alert
- type AlertState
- type AlertingRule
- func (rule *AlertingRule) ActiveAlerts() []Alert
- func (rule *AlertingRule) Eval(timestamp clientmodel.Timestamp, storage local.Storage) (ast.Vector, error)
- func (rule *AlertingRule) EvalRaw(timestamp clientmodel.Timestamp, storage local.Storage) (ast.Vector, error)
- func (rule *AlertingRule) HTMLSnippet() template.HTML
- func (rule *AlertingRule) Name() string
- func (rule *AlertingRule) State() AlertState
- func (rule *AlertingRule) String() string
- func (rule *AlertingRule) ToDotGraph() string
- type RecordingRule
- func (rule RecordingRule) Eval(timestamp clientmodel.Timestamp, storage local.Storage) (ast.Vector, error)
- func (rule RecordingRule) EvalRaw(timestamp clientmodel.Timestamp, storage local.Storage) (ast.Vector, error)
- func (rule RecordingRule) HTMLSnippet() template.HTML
- func (rule RecordingRule) Name() string
- func (rule RecordingRule) String() string
- func (rule RecordingRule) ToDotGraph() string
- type Rule
- type RulesLexer
Constants ¶
const ( // AlertMetricName is the metric name for synthetic alert timeseries. AlertMetricName clientmodel.LabelValue = "ALERTS" // AlertNameLabel is the label name indicating the name of an alert. AlertNameLabel clientmodel.LabelName = "alertname" // AlertStateLabel is the label name indicating the state of an alert. AlertStateLabel clientmodel.LabelName = "alertstate" )
const ADDITIVE_OP = 57358
const AGGR_OP = 57356
const ALERT = 57360
const CMP_OP = 57357
const DESCRIPTION = 57365
const DURATION = 57350
const FOR = 57362
const GROUP_OP = 57354
const IDENTIFIER = 57348
const IF = 57361
const KEEPING_EXTRA = 57355
const METRICNAME = 57351
const MULT_OP = 57359
const NUMBER = 57352
const PERMANENT = 57353
const START_EXPRESSION = 57347
const START_RULES = 57346
const STRING = 57349
const SUMMARY = 57364
const WITH = 57363
Variables ¶
This section is empty.
Functions ¶
func GraphLinkForExpression ¶
GraphLinkForExpression creates an escaped relative link to the graph view of the provided expression.
func LoadExprFromFile ¶
LoadExprFromFile parses a single expression from the file of the provided name and returns it as an AST node.
func LoadExprFromReader ¶
LoadExprFromReader parses a single expression from the provided reader and returns it as an AST node.
func LoadExprFromString ¶
LoadExprFromString parses a single expression from the provided string and returns it as an AST node.
func NewArithExpr ¶
NewArithExpr is a convenience function to create a new AST arithmetic expression.
func NewFunctionCall ¶
NewFunctionCall is a convenience function to create a new AST function-call node.
func NewMatrixSelector ¶
NewMatrixSelector is a convenience function to create a new AST matrix selector.
func NewVectorAggregation ¶
func NewVectorAggregation(aggrTypeStr string, vector ast.Node, groupBy clientmodel.LabelNames, keepExtraLabels bool) (*ast.VectorAggregation, error)
NewVectorAggregation is a convenience function to create a new AST vector aggregation.
func TableLinkForExpression ¶
TableLinkForExpression creates an escaped relative link to the table view of the provided expression.
Types ¶
type Alert ¶
type Alert struct {
// The name of the alert.
Name string
// The vector element labelset triggering this alert.
Labels clientmodel.LabelSet
// The state of the alert (Pending or Firing).
State AlertState
// The time when the alert first transitioned into Pending state.
ActiveSince clientmodel.Timestamp
// The value of the alert expression for this vector element.
Value clientmodel.SampleValue
}
Alert is used to track active (pending/firing) alerts over time.
type AlertState ¶
type AlertState int
AlertState denotes the state of an active alert.
const ( // Inactive alerts are neither firing nor pending. Inactive AlertState = iota // Pending alerts have been active for less than the configured // threshold duration. Pending // Firing alerts have been active for longer than the configured // threshold duration. Firing )
func (AlertState) String ¶
func (s AlertState) String() string
type AlertingRule ¶
type AlertingRule struct {
// The vector expression from which to generate alerts.
Vector ast.VectorNode
// Extra labels to attach to the resulting alert sample vectors.
Labels clientmodel.LabelSet
// Short alert summary, suitable for email subjects.
Summary string
// More detailed alert description.
Description string
// contains filtered or unexported fields
}
An AlertingRule generates alerts from its vector expression.
func CreateAlertingRule ¶
func CreateAlertingRule(name string, expr ast.Node, holdDurationStr string, labels clientmodel.LabelSet, summary string, description string) (*AlertingRule, error)
CreateAlertingRule is a convenience function to create a new alerting rule.
func NewAlertingRule ¶
func NewAlertingRule(name string, vector ast.VectorNode, holdDuration time.Duration, labels clientmodel.LabelSet, summary string, description string) *AlertingRule
NewAlertingRule constructs a new AlertingRule.
func (*AlertingRule) ActiveAlerts ¶
func (rule *AlertingRule) ActiveAlerts() []Alert
ActiveAlerts returns a slice of active alerts.
func (*AlertingRule) Eval ¶
func (rule *AlertingRule) Eval(timestamp clientmodel.Timestamp, storage local.Storage) (ast.Vector, error)
Eval evaluates the rule expression and then creates pending alerts and fires or removes previously pending alerts accordingly.
func (*AlertingRule) EvalRaw ¶
func (rule *AlertingRule) EvalRaw(timestamp clientmodel.Timestamp, storage local.Storage) (ast.Vector, error)
EvalRaw returns the raw value of the rule expression, without creating alerts.
func (*AlertingRule) HTMLSnippet ¶
func (rule *AlertingRule) HTMLSnippet() template.HTML
HTMLSnippet returns an HTML snippet representing this alerting rule.
func (*AlertingRule) Name ¶
func (rule *AlertingRule) Name() string
Name returns the name of the alert.
func (*AlertingRule) State ¶
func (rule *AlertingRule) State() AlertState
State returns the "maximum" state: firing > pending > inactive.
func (*AlertingRule) String ¶
func (rule *AlertingRule) String() string
func (*AlertingRule) ToDotGraph ¶
func (rule *AlertingRule) ToDotGraph() string
ToDotGraph returns the text representation of a dot graph.
type RecordingRule ¶
type RecordingRule struct {
// contains filtered or unexported fields
}
A RecordingRule records its vector expression into new timeseries.
func CreateRecordingRule ¶
func CreateRecordingRule(name string, labels clientmodel.LabelSet, expr ast.Node, permanent bool) (*RecordingRule, error)
CreateRecordingRule is a convenience function to create a recording rule.
func (RecordingRule) Eval ¶
func (rule RecordingRule) Eval(timestamp clientmodel.Timestamp, storage local.Storage) (ast.Vector, error)
Eval evaluates the rule and then overrides the metric names and labels accordingly.
func (RecordingRule) EvalRaw ¶
func (rule RecordingRule) EvalRaw(timestamp clientmodel.Timestamp, storage local.Storage) (ast.Vector, error)
EvalRaw returns the raw value of the rule expression.
func (RecordingRule) HTMLSnippet ¶
func (rule RecordingRule) HTMLSnippet() template.HTML
HTMLSnippet returns an HTML snippet representing this rule.
func (RecordingRule) String ¶
func (rule RecordingRule) String() string
func (RecordingRule) ToDotGraph ¶
func (rule RecordingRule) ToDotGraph() string
ToDotGraph returns the text representation of a dot graph.
type Rule ¶
type Rule interface {
// Name returns the name of the rule.
Name() string
// EvalRaw evaluates the rule's vector expression without triggering any
// other actions, like recording or alerting.
EvalRaw(timestamp clientmodel.Timestamp, storage local.Storage) (ast.Vector, error)
// Eval evaluates the rule, including any associated recording or alerting actions.
Eval(timestamp clientmodel.Timestamp, storage local.Storage) (ast.Vector, error)
// ToDotGraph returns a Graphviz dot graph of the rule.
ToDotGraph() string
// String returns a human-readable string representation of the rule.
String() string
// HTMLSnippet returns a human-readable string representation of the rule,
// decorated with HTML elements for use the web frontend.
HTMLSnippet() template.HTML
}
A Rule encapsulates a vector expression which is evaluated at a specified interval and acted upon (currently either recorded or used for alerting).
func LoadRulesFromFile ¶
LoadRulesFromFile parses rules from the file of the provided name and returns them.
func LoadRulesFromReader ¶
LoadRulesFromReader parses rules from the provided reader and returns them.
func LoadRulesFromString ¶
LoadRulesFromString parses rules from the provided string returns them.
type RulesLexer ¶
type RulesLexer struct {
// contains filtered or unexported fields
}
RulesLexer is the lexer for rule expressions.
func (*RulesLexer) Error ¶
func (lexer *RulesLexer) Error(errorStr string)
func (*RulesLexer) Lex ¶
func (lexer *RulesLexer) Lex(lval *yySymType) int
Lex is called by the parser generated by "go tool yacc" to obtain each token. The method is opened before the matching rules block and closed at the end of the file.