Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterProvider ¶ added in v0.2.8
func RegisterProvider(dp DatasourceProvider)
RegisterProvider adds a datasource provider to the global registry. Panics if a provider with the same Kind() is already registered.
Types ¶
type APIError ¶ added in v0.2.8
APIError is a typed error returned by the Grafana datasource REST API.
func NewAPIError ¶ added in v0.2.8
func (*APIError) APIServiceName ¶ added in v0.2.8
func (*APIError) APIUserMessage ¶ added in v0.2.8
func (*APIError) HTTPStatusCode ¶ added in v0.2.8
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client queries Grafana datasources via the NamespacedRESTConfig transport, ensuring OAuth proxy mode and token refresh are respected. It mirrors the approach used by internal/query/prometheus and internal/query/loki.
func NewClient ¶
func NewClient(cfg config.NamespacedRESTConfig) (*Client, error)
NewClient creates a client backed by the given REST config's transport (including WrapTransport / RefreshTransport in OAuth proxy mode).
type Datasource ¶
type Datasource struct {
UID string `json:"uid"`
Name string `json:"name"`
Type string `json:"type"`
URL string `json:"url"`
Access string `json:"access"`
IsDefault bool `json:"isDefault"`
ReadOnly bool `json:"readOnly"`
Database string `json:"database"`
BasicAuth bool `json:"basicAuth"`
WithCredentials bool `json:"withCredentials"`
JSONData any `json:"jsonData"`
}
Datasource holds the fields returned by the legacy Grafana datasource REST API.
type DatasourceProvider ¶ added in v0.2.8
type DatasourceProvider interface {
// Kind returns the datasource kind (e.g., "prometheus", "loki", "pyroscope", "tempo").
Kind() string
// ShortDesc returns a one-line description of the datasource provider.
ShortDesc() string
// QueryCmd returns the query subcommand. Every datasource must support querying.
QueryCmd(loader *providers.ConfigLoader) *cobra.Command
// ExtraCommands returns additional subcommands (labels, metrics, etc.).
// Returns nil when the provider has no commands beyond query.
ExtraCommands(loader *providers.ConfigLoader) []*cobra.Command
}
DatasourceProvider defines the interface for a datasource type plugin. Each implementation registers under `datasources $KIND` with its own set of subcommands - query is required, extra commands are optional.
The ConfigLoader is created and flag-bound by the mounting code in cmd/gcx/datasources/, so providers don't manage flag binding themselves.
func AllProviders ¶ added in v0.2.8
func AllProviders() []DatasourceProvider
AllProviders returns all registered datasource providers. Returns a non-nil empty slice when no providers have been registered.