Documentation
¶
Overview ¶
Package promql provides utilities for parsing and rewriting PromQL queries.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func OuterAggregator ¶
OuterAggregator returns the name of the outermost PromQL aggregation operator in query (lowercased), and true if one was found. The remainder of the query string is unchanged; this function only inspects the prefix.
Examples:
OuterAggregator("sum(rate(http_requests_total[5m]))") → "sum", true
OuterAggregator("avg by (region) (requests)") → "avg", true
OuterAggregator("http_requests_total{job=\"api\"}") → "", false
OuterAggregator("avg_over_time(cpu[5m])") → "", false (function, not aggregator)
func ReplaceOuterAggregator ¶
ReplaceOuterAggregator substitutes the outermost aggregator keyword in query with replacement, preserving the rest of the query verbatim. aggregator must match the lowercased aggregator as returned by OuterAggregator.
Example:
ReplaceOuterAggregator("avg by (r) (errors)", "avg", "sum") → "sum by (r) (errors)"
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.