Documentation
¶
Index ¶
- func FormatLabelsTable(w io.Writer, resp *LabelsResponse) error
- func FormatMetricQueryTable(w io.Writer, resp *MetricQueryResponse) error
- func FormatQueryRaw(w io.Writer, resp *QueryResponse) error
- func FormatQueryTable(w io.Writer, resp *QueryResponse) error
- func FormatQueryTableWide(w io.Writer, resp *QueryResponse) error
- func FormatSeriesTable(w io.Writer, resp *SeriesResponse) error
- func NewRawQueryCodec() format.Codec
- type Client
- func (c *Client) LabelValues(ctx context.Context, datasourceUID, labelName string) (*LabelsResponse, error)
- func (c *Client) Labels(ctx context.Context, datasourceUID string) (*LabelsResponse, error)
- func (c *Client) MetricQuery(ctx context.Context, datasourceUID string, req QueryRequest) (*MetricQueryResponse, error)
- func (c *Client) Query(ctx context.Context, datasourceUID string, req QueryRequest) (*QueryResponse, error)
- func (c *Client) Series(ctx context.Context, datasourceUID string, matchers []string) (*SeriesResponse, error)
- type DataFrame
- type DataFrameData
- type DataFrameSchema
- type Field
- type FrameMeta
- type FrameNotice
- type FrameStat
- type GrafanaQueryResponse
- type GrafanaResult
- type LabelsResponse
- type MetricQueryData
- type MetricQueryResponse
- type MetricQuerySample
- type QueryRequest
- type QueryResponse
- type QueryResultData
- type QueryStats
- type QuerySummary
- type SeriesResponse
- type StreamEntry
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FormatLabelsTable ¶
func FormatLabelsTable(w io.Writer, resp *LabelsResponse) error
func FormatMetricQueryTable ¶ added in v0.2.2
func FormatMetricQueryTable(w io.Writer, resp *MetricQueryResponse) error
FormatMetricQueryTable formats a MetricQueryResponse as a table with TIMESTAMP, VALUE, and label columns.
func FormatQueryRaw ¶ added in v0.2.5
func FormatQueryRaw(w io.Writer, resp *QueryResponse) error
FormatQueryRaw prints only the original log line bodies.
func FormatQueryTable ¶
func FormatQueryTable(w io.Writer, resp *QueryResponse) error
func FormatQueryTableWide ¶
func FormatQueryTableWide(w io.Writer, resp *QueryResponse) error
func FormatSeriesTable ¶
func FormatSeriesTable(w io.Writer, resp *SeriesResponse) error
func NewRawQueryCodec ¶ added in v0.2.5
NewRawQueryCodec returns a codec that prints the original log line bodies without adding timestamps, labels, or structured parsing.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (*Client) LabelValues ¶
func (*Client) MetricQuery ¶ added in v0.2.2
func (c *Client) MetricQuery(ctx context.Context, datasourceUID string, req QueryRequest) (*MetricQueryResponse, error)
MetricQuery executes a metric LogQL query and returns a Prometheus-compatible time-series response. Metric LogQL expressions (e.g., rate, count_over_time) return time-series data rather than log streams.
func (*Client) Query ¶
func (c *Client) Query(ctx context.Context, datasourceUID string, req QueryRequest) (*QueryResponse, error)
type DataFrame ¶
type DataFrame struct {
Schema DataFrameSchema `json:"schema"`
Data DataFrameData `json:"data"`
}
DataFrame represents a Grafana data frame.
type DataFrameData ¶
type DataFrameData struct {
Values [][]any `json:"values,omitempty"`
Nanos [][]int `json:"nanos,omitempty"`
}
DataFrameData contains the actual data values.
type DataFrameSchema ¶
type DataFrameSchema struct {
RefId string `json:"refId,omitempty"`
Meta *FrameMeta `json:"meta,omitempty"`
Name string `json:"name,omitempty"`
Fields []Field `json:"fields,omitempty"`
}
DataFrameSchema describes the structure of a data frame.
type Field ¶
type Field struct {
Name string `json:"name,omitempty"`
Type string `json:"type,omitempty"`
Labels map[string]string `json:"labels,omitempty"`
}
Field describes a field in a data frame.
type FrameMeta ¶
type FrameMeta struct {
Type string `json:"type,omitempty"`
Stats []FrameStat `json:"stats,omitempty"`
Notices []FrameNotice `json:"notices,omitempty"`
ExecutedQueryString string `json:"executedQueryString,omitempty"`
}
FrameMeta contains metadata about a data frame.
type FrameNotice ¶
FrameNotice represents a notice or warning from the query.
type FrameStat ¶
type FrameStat struct {
DisplayName string `json:"displayName"`
Unit string `json:"unit,omitempty"`
Value float64 `json:"value"`
}
FrameStat represents a single statistic from query execution.
type GrafanaQueryResponse ¶
type GrafanaQueryResponse struct {
Results map[string]GrafanaResult `json:"results"`
}
GrafanaQueryResponse represents the response from Grafana's datasource query API.
type GrafanaResult ¶
type GrafanaResult struct {
Frames []DataFrame `json:"frames,omitempty"`
Error string `json:"error,omitempty"`
ErrorSource string `json:"errorSource,omitempty"`
Status int `json:"status,omitempty"`
}
GrafanaResult represents a single result from a Grafana query.
type LabelsResponse ¶
LabelsResponse represents the response from the Loki labels API.
type MetricQueryData ¶ added in v0.2.2
type MetricQueryData struct {
ResultType string `json:"resultType"`
Result []MetricQuerySample `json:"result"`
}
MetricQueryData holds the metric query result data.
type MetricQueryResponse ¶ added in v0.2.2
type MetricQueryResponse struct {
Status string `json:"status"`
Data MetricQueryData `json:"data"`
}
MetricQueryResponse represents the response from a metric LogQL query. It uses the same structure as a Prometheus response (time-series with metric labels).
type MetricQuerySample ¶ added in v0.2.2
type MetricQuerySample struct {
Metric map[string]string `json:"metric"`
Value []any `json:"value,omitempty"` // [timestamp, value] for instant queries
Values [][]any `json:"values,omitempty"` // [[timestamp, value], ...] for range queries
}
MetricQuerySample represents a single time-series from a metric LogQL query.
type QueryRequest ¶
type QueryRequest struct {
Query string
Start time.Time
End time.Time
Step time.Duration
Limit int
}
QueryRequest represents a Loki query request.
func (QueryRequest) IsRange ¶
func (r QueryRequest) IsRange() bool
IsRange returns true if this is a range query.
type QueryResponse ¶
type QueryResponse struct {
Status string `json:"status"`
Data QueryResultData `json:"data"`
ErrorType string `json:"errorType,omitempty"`
Error string `json:"error,omitempty"`
}
QueryResponse represents the response from a Loki query.
type QueryResultData ¶
type QueryResultData struct {
ResultType string `json:"resultType"`
Result []StreamEntry `json:"result"`
Stats *QueryStats `json:"stats,omitempty"`
Notices []FrameNotice `json:"notices,omitempty"`
}
QueryResultData holds the query result data.
type QueryStats ¶
type QueryStats struct {
Summary QuerySummary `json:"summary"`
}
QueryStats contains statistics about the query execution.
type QuerySummary ¶
type QuerySummary struct {
BytesProcessedPerSecond int64 `json:"bytesProcessedPerSecond,omitempty"`
LinesProcessedPerSecond int64 `json:"linesProcessedPerSecond,omitempty"`
TotalBytesProcessed int64 `json:"totalBytesProcessed,omitempty"`
TotalLinesProcessed int64 `json:"totalLinesProcessed,omitempty"`
ExecTime float64 `json:"execTime,omitempty"`
}
QuerySummary contains summary statistics.
type SeriesResponse ¶
SeriesResponse represents the response from the Loki series API.
type StreamEntry ¶
type StreamEntry struct {
Stream map[string]string `json:"stream"`
Values [][]string `json:"values"` // [[timestamp, line], ...]
}
StreamEntry represents a single log stream from the query result.