Documentation
¶
Overview ¶
Package providers contains the built-in data providers for the query engine. Each provider self-registers via init(); consumers enable them with a blank import:
import _ "github.com/flanksource/commons-db/query/providers"
Index ¶
- func FilterOpenSearch(body string, filters []query.ColumnFilterValue) (string, error)
- func NeedsOpenSearchTimeFieldMapping(params []esdsl.ParamBinding) bool
- func ReadOpenTelemetrySpans(ctx context.Context, read OpenTelemetryRead, emit func(query.Row)) error
- func ResolveOpenSearchTimeFieldMapping(ctx dbcontext.Context, request OpenSearchTimeFieldMappingRequest) (*esdsl.TimeFieldMapping, error)
- type BigQueryOptions
- type HTTPOptions
- type JaegerOptions
- type OpenSearchOptions
- type OpenSearchTimeFieldMappingRequest
- type OpenTelemetryOptions
- type OpenTelemetryRead
- type PostgRESTOptions
- type PrometheusOptions
- type PrometheusRange
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FilterOpenSearch ¶
func FilterOpenSearch(body string, filters []query.ColumnFilterValue) (string, error)
FilterOpenSearch folds the given selections into an already-rendered query body, for a caller that assembled its own DSL rather than a stored profile — the connection browser.
It exists so there is one clause compiler in the codebase: a second implementation would be a second set of rules for what excluding a value means, and the two would disagree on the day one of them was fixed.
With no active filter it returns the body byte for byte, so turning filtering on cannot change what an unfiltered query sends.
func NeedsOpenSearchTimeFieldMapping ¶
func NeedsOpenSearchTimeFieldMapping(params []esdsl.ParamBinding) bool
NeedsOpenSearchTimeFieldMapping reports whether resolved parameters contain a non-empty time bound.
func ReadOpenTelemetrySpans ¶ added in v0.1.49
func ReadOpenTelemetrySpans(ctx context.Context, read OpenTelemetryRead, emit func(query.Row)) error
ReadOpenTelemetrySpans emits each span read, normalized as the opentelemetry provider's rows are, with source_index and source_id naming its document. It reads in the date field's order with search_after, opening no point in time, so a follow sees what lands after it started.
func ResolveOpenSearchTimeFieldMapping ¶
func ResolveOpenSearchTimeFieldMapping(ctx dbcontext.Context, request OpenSearchTimeFieldMappingRequest) (*esdsl.TimeFieldMapping, error)
Types ¶
type BigQueryOptions ¶ added in v0.1.68
type BigQueryOptions struct {
// Project overrides the project carried by the connection.
Project string `json:"project,omitempty"`
// Mapping names the columns that carry the message, timestamp and severity.
// Worth setting: with no mapping the searcher has no defaults to fall back
// on and every row's message becomes the whole row, stringified.
Mapping *logs.FieldMappingConfig `json:"mapping,omitempty"`
}
func (BigQueryOptions) Validate ¶ added in v0.1.68
func (BigQueryOptions) Validate() error
Validate accepts every BigQueryOptions: the project and mapping are only checked by BigQuery itself.
type HTTPOptions ¶ added in v0.1.68
type HTTPOptions struct {
// URL is an inline HTTP base URL used when no stored connection is referenced.
URL string `json:"url,omitempty"`
// Method is the HTTP method (default GET).
Method string `json:"method,omitempty"`
// Body is the request body for POST/PUT/PATCH.
Body string `json:"body,omitempty"`
// JSONPath extracts an inner array/object from a wrapper response,
// e.g. "$.Traces" for {"Traces": [...]}.
JSONPath string `json:"jsonpath,omitempty"`
}
HTTPOptions are decoded from ProviderRequest.Options.
func (HTTPOptions) Validate ¶ added in v0.1.68
func (o HTTPOptions) Validate() error
Validate refuses a method the provider does not send.
type JaegerOptions ¶ added in v0.1.68
type JaegerOptions struct {
// URL is an inline Jaeger query base URL used when no stored connection is referenced.
URL string `json:"url,omitempty"`
Service string `json:"service,omitempty"`
Operation string `json:"operation,omitempty"`
Lookback string `json:"lookback,omitempty"`
Start string `json:"start,omitempty"`
End string `json:"end,omitempty"`
Limit string `json:"limit,omitempty"`
MinDuration string `json:"minDuration,omitempty"`
MaxDuration string `json:"maxDuration,omitempty"`
Tags string `json:"tags,omitempty"`
}
JaegerOptions are decoded from ProviderRequest.Options. When the request Query is set it is treated as a trace ID (GET /api/traces/{id}); otherwise a search (GET /api/traces?service=...) is performed and Service is required.
func (JaegerOptions) Validate ¶ added in v0.1.68
func (JaegerOptions) Validate() error
Validate accepts every JaegerOptions: whether a search needs Service depends on the request's query, so it is checked as the endpoint is built.
type OpenSearchOptions ¶ added in v0.1.68
type OpenSearchOptions struct {
// Address is an inline OpenSearch URL used when no stored connection is referenced.
Address string `json:"address,omitempty"`
// Index is the OpenSearch index to query.
Index string `json:"index,omitempty"`
// Limit is the maximum number of hits to return.
Limit string `json:"limit,omitempty"`
// Search is the structured search specification. It is mutually exclusive
// with the profile's raw query.
Search *esdsl.Search `json:"search,omitempty"`
// TailPoll is how long a caught-up tail waits before asking the index
// again. Empty is openSearchDefaultTailPoll. It has no effect on a query.
TailPoll string `json:"tailPoll,omitempty"`
// TailLag holds a tail's cursor that far behind now, so a document indexed
// later than it was written still lands ahead of the cursor rather than
// behind it. Empty is no lag: lines appear as soon as they are searchable,
// and one that arrives late is never emitted. See openSearchTailBound.
TailLag string `json:"tailLag,omitempty"`
}
func (OpenSearchOptions) Validate ¶ added in v0.1.68
func (o OpenSearchOptions) Validate() error
Validate refuses a limit that is no count and a tail pacing that is no usable duration.
type OpenSearchTimeFieldMappingRequest ¶
type OpenSearchTimeFieldMappingRequest struct {
Searcher *opensearch.Searcher
Index string
Search esdsl.Search
Params []esdsl.ParamBinding
Inspection query.InspectionOptions
}
ResolveOpenSearchTimeFieldMapping reads the exact field used by active time-role parameters. The mapping is runtime metadata and never becomes part of the stored profile.
type OpenTelemetryOptions ¶ added in v0.1.68
type OpenTelemetryOptions struct {
Format string `json:"format,omitempty"`
Index string `json:"index,omitempty"`
DateField string `json:"dateField,omitempty"`
TraceIDField string `json:"traceIdField,omitempty"`
SpanIDField string `json:"spanIdField,omitempty"`
ParentIDField string `json:"parentIdField,omitempty"`
ParentRefType string `json:"parentRefType,omitempty"`
ServiceField string `json:"serviceField,omitempty"`
OperationField string `json:"operationField,omitempty"`
StatusFields []string `json:"statusFields,omitempty"`
SelectFields []string `json:"selectFields,omitempty"`
SourceExcludes []string `json:"sourceExcludes,omitempty"`
Limit int `json:"limit,omitempty"`
// Search is the structured search specification. The trace-shaped options
// above fill whatever it leaves unset.
Search *esdsl.Search `json:"search,omitempty"`
}
func (OpenTelemetryOptions) Validate ¶ added in v0.1.68
func (options OpenTelemetryOptions) Validate() error
Validate refuses a format the provider cannot shape rows from; empty is flat.
type OpenTelemetryRead ¶ added in v0.1.49
type OpenTelemetryRead struct {
// Connection is the opentelemetry connection, and Options the
// opentelemetry provider's options for its index and fields.
Connection string
Options map[string]any
// From and To bound the read on the date field, as date math such as
// now-1h or RFC3339; empty leaves that side open.
From, To string
// Follow keeps reading the spans indexed after the read caught up, until
// ctx ends; it has no To.
Follow bool
// Poll is how long a caught-up follow waits before asking again; zero is
// two seconds. Lag holds a follow behind now, so spans indexed late still
// land before the read passes their instant.
Poll, Lag time.Duration
}
OpenTelemetryRead is one read of span documents.
type PostgRESTOptions ¶ added in v0.1.68
type PostgRESTOptions struct {
// URL is an inline PostgREST base URL used when no stored connection is referenced.
URL string `json:"url,omitempty"`
// JSONPath optionally extracts an inner array from the response.
JSONPath string `json:"jsonpath,omitempty"`
}
func (PostgRESTOptions) Validate ¶ added in v0.1.68
func (PostgRESTOptions) Validate() error
Validate accepts every PostgRESTOptions: the URL and path are only checked once the connection they extend is resolved.
type PrometheusOptions ¶ added in v0.1.68
type PrometheusOptions struct {
// URL is an inline Prometheus address used when no stored connection is referenced.
URL string `json:"url,omitempty"`
// Range, when set, runs a PromQL range query.
Range *PrometheusRange `json:"range,omitempty"`
// SelectLabels restricts result labels to a deterministic subset.
SelectLabels []string `json:"selectLabels,omitempty"`
}
PrometheusOptions are decoded from ProviderRequest.Options.
func (PrometheusOptions) Validate ¶ added in v0.1.68
func (o PrometheusOptions) Validate() error
Validate refuses a range the provider could not query.
type PrometheusRange ¶ added in v0.1.68
type PrometheusRange struct {
Start string `json:"start"`
End string `json:"end"`
Step string `json:"step"`
}
PrometheusRange is a range query's window: Start and End are times or date math such as now-1h, Step a duration such as 15s.
func (PrometheusRange) Validate ¶ added in v0.1.68
func (pr PrometheusRange) Validate() error
Validate refuses a range with a missing or unreadable bound or step, a step that is not positive, or an end before its start.
Source Files
¶
- azurelogs.go
- bigquery.go
- cloudwatch.go
- gcp.go
- gcplogging.go
- http.go
- jaeger.go
- k8s_diagnostics.go
- k8s_lookup.go
- k8s_target.go
- k8slogs.go
- loki.go
- opensearch.go
- opensearch_column_inspection.go
- opensearch_filter.go
- opensearch_lookup.go
- opensearch_search.go
- opensearch_tail.go
- opensearch_time.go
- opensearch_walk.go
- opentelemetry.go
- opentelemetry_parser.go
- opentelemetry_read.go
- opentelemetry_search.go
- postgrest.go
- prometheus.go
Directories
¶
| Path | Synopsis |
|---|---|
|
internal
|
|
|
Package sqlite holds the dialect-generic SQL query provider and registers it under the "sqlite" key.
|
Package sqlite holds the dialect-generic SQL query provider and registers it under the "sqlite" key. |