Documentation
¶
Index ¶
- func Execute(ctx context.Context, req Request, fetch Fetch) ([]map[string]any, error)
- func InitializeWorkspace(ctx context.Context, db *sql.DB) error
- func ValidateLabels(labels map[string]string) ([]string, error)
- type Fetch
- type Matcher
- type ProfileRows
- type ProfileTable
- type QueryPlan
- type Range
- type RangeQuery
- type Request
- type Sample
- type Source
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InitializeWorkspace ¶
InitializeWorkspace prepares an owned writable database for metric queries.
Types ¶
type Matcher ¶
Matcher is one label predicate pushed down to a metric source, in Prometheus matcher terms: Op is "=", "!=", "=~" or "!~". Pushdown only narrows what a source fetches; SQLite still evaluates the full WHERE clause, so a source may ignore any matcher it cannot express.
type ProfileRows ¶
type ProfileRows func(name string) (ProfileTable, error)
ProfileRows executes the named profile for a `profiles.<name>` reference.
type ProfileTable ¶
ProfileTable is the result of a profile referenced as `profiles.<name>` in metric SQL: its column names and its rows.
type QueryPlan ¶
QueryPlan is metric SQL rewritten onto its workspace tables. Prometheus reports a `prometheus(...)` reference; Profiles lists each `profiles.<name>` reference, loaded as table __profile_<index>.
type RangeQuery ¶
type RangeQuery struct {
Window Range
Fetch func(expr string, r Range, emit func(Sample) error) error
}
RangeQuery lets metric SQL read `prometheus(query, [start, end, step])`. Window is the provider's request range, the default for omitted bounds; Fetch evaluates one expression over a range, emitting each sample.
type Request ¶
type Request struct {
SQL string
Args []any
Labels map[string]string
Range *RangeQuery
Profiles ProfileRows
}
Request is one metric SQL statement. Range enables `prometheus(...)` and is nil for providers without range queries; Profiles enables `profiles.<name>` and is nil where no profile resolver is reachable.