Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FormatTable ¶
func FormatTable(w io.Writer, resp *QueryResponse) error
FormatTable renders a QueryResponse as a terminal table.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client executes Infinity queries via Grafana's datasource query API.
func NewClient ¶
func NewClient(cfg config.NamespacedRESTConfig) (*Client, error)
NewClient creates a new Infinity query client.
func (*Client) Query ¶
func (c *Client) Query(ctx context.Context, datasourceUID string, req QueryRequest) (*QueryResponse, error)
Query executes an Infinity query against the specified datasource.
type DataFrame ¶
type DataFrame struct {
Schema DataFrameSchema `json:"schema"`
Data DataFrameData `json:"data"`
}
DataFrame is a Grafana data frame.
type DataFrameData ¶
type DataFrameData struct {
Values [][]any `json:"values,omitempty"`
}
DataFrameData holds column-oriented data values.
type DataFrameSchema ¶
type DataFrameSchema struct {
Name string `json:"name,omitempty"`
Fields []Field `json:"fields,omitempty"`
}
DataFrameSchema describes the frame structure.
type GrafanaQueryResponse ¶
type GrafanaQueryResponse struct {
Results map[string]GrafanaResult `json:"results"`
}
GrafanaQueryResponse is the raw 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 is a single result entry.
type QueryRequest ¶
type QueryRequest struct {
Expr string // optional root selector (JSONPath for JSON, XPath for XML/HTML)
Start time.Time
End time.Time
}
QueryRequest represents an Infinity datasource query request.
func (QueryRequest) IsRange ¶
func (r QueryRequest) IsRange() bool
IsRange returns true if both Start and End are set.
type QueryResponse ¶
QueryResponse holds the query result as generic tabular data.
func ConvertGrafanaResponse ¶
func ConvertGrafanaResponse(grafanaResp *GrafanaQueryResponse) *QueryResponse
ConvertGrafanaResponse converts a Grafana data frame response into a flat QueryResponse with columns and rows suitable for table rendering.