infinity

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 26, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

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.

func ToString

func ToString(v any) string

ToString converts a value to its string representation for table rendering.

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 Column

type Column struct {
	Name string `json:"name"`
	Type string `json:"type"`
}

Column describes a single column in the query result.

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 Field

type Field struct {
	Name string `json:"name,omitempty"`
	Type string `json:"type,omitempty"`
}

Field describes one field/column in a data frame.

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

type QueryResponse struct {
	Columns []Column `json:"columns"`
	Rows    [][]any  `json:"rows"`
}

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL