plugin

package
v0.23.3 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Data added in v0.8.0

type Data struct {
	ResultType string          `json:"resultType"`
	Result     json.RawMessage `json:"result"`
}

Data contains fields ResultType which defines type of the query response Result resents json of the query response

type DataSourceInstanceSettings added in v0.21.0

type DataSourceInstanceSettings struct {
	// URL is the configured URL of a data source instance (e.g. the URL of an API endpoint).
	URL string `json:"URL,omitempty"`

	// VMUIURL specifies the URL for the VictoriaMetrics UI, derived from the data source's base URL if not explicitly set.
	VMUIURL string `json:"vmuiUrl,omitempty"`
}

type Datasource

type Datasource struct {
	backend.CallResourceHandler
	// contains filtered or unexported fields
}

Datasource describes a plugin service that manages DatasourceInstance entities

func NewDatasource

func NewDatasource() *Datasource

NewDatasource creates a new datasource instance.

func (*Datasource) CheckHealth

CheckHealth handles health checks sent from Grafana to the plugin. The main use case for these health checks is the test button on the datasource configuration page which allows users to verify that a datasource is working as expected.

func (*Datasource) PublishStream added in v0.7.0

PublishStream called when a user tries to publish to a plugin/datasource managed channel path.

func (*Datasource) QueryData

QueryData handles multiple queries and returns multiple responses. req contains the queries []DataQuery (where each query contains RefID as a unique identifier). The QueryDataResponse contains a map of RefID to the response for each query, and each response contains Frames ([]*Frame).

func (*Datasource) RootHandler added in v0.19.0

func (d *Datasource) RootHandler(rw http.ResponseWriter, req *http.Request)

RootHandler returns generic response to unsupported paths

func (*Datasource) RunStream added in v0.7.0

func (d *Datasource) RunStream(ctx context.Context, req *backend.RunStreamRequest, sender *backend.StreamSender) error

RunStream will be called once for the first client successfully subscribed to a channel path. When Grafana detects that there are no longer any subscribers inside a channel, the call will be terminated until next active subscriber appears. Call termination can happen with a delay.

func (*Datasource) SubscribeStream added in v0.7.0

SubscribeStream called when a user tries to subscribe to a plugin/datasource managed channel path – thus plugin can check subscribe permissions and communicate options with Grafana Core. As soon as first subscriber joins channel RunStream will be called.

func (*Datasource) VLAPIQuery added in v0.19.0

func (d *Datasource) VLAPIQuery(rw http.ResponseWriter, req *http.Request)

VLAPIQuery performs request to VL API endpoints that doesn't return frames

func (*Datasource) VLAPITenantIDs added in v0.23.0

func (d *Datasource) VLAPITenantIDs(rw http.ResponseWriter, req *http.Request)

func (*Datasource) VMUIQuery added in v0.21.0

func (d *Datasource) VMUIQuery(rw http.ResponseWriter, req *http.Request)

VMUIQuery generates VMUI link to a native dashboard

type DatasourceInstance added in v0.19.0

type DatasourceInstance struct {
	// contains filtered or unexported fields
}

DatasourceInstance is an example datasource which can respond to data queries, reports its health and has streaming skills.

func (*DatasourceInstance) Dispose added in v0.19.0

func (di *DatasourceInstance) Dispose()

Dispose here tells plugin SDK that plugin wants to clean up resources when a new instance created. As soon as datasource settings change detected by SDK old datasource instance will be disposed and a new one will be created using NewSampleDatasource factory function.

type FieldsQuery added in v0.19.2

type FieldsQuery struct {
	Query              string `json:"query"`
	Limit              string `json:"limit"`
	Start              string `json:"start"`
	End                string `json:"end"`
	Field              string `json:"field"`
	ExtraFilters       string `json:"extra_filters"`
	ExtraStreamFilters string `json:"extra_stream_filters"`
}

type GrafanaSettings added in v0.13.3

type GrafanaSettings struct {
	HTTPMethod          string              `json:"httpMethod"`
	QueryParams         string              `json:"customQueryParameters"`
	CustomHeaders       http.Header         `json:"-"`
	MultitenancyHeaders MultitenancyHeaders `json:"-"`
}

GrafanaSettings contains the raw DataSourceConfig as JSON as stored by Grafana server. It repeats the properties in this object and includes custom properties.

func NewGrafanaSettings added in v0.13.3

func NewGrafanaSettings(settings backend.DataSourceInstanceSettings) (*GrafanaSettings, error)

type Hit added in v0.11.0

type Hit struct {
	Fields     map[string]string `json:"fields"`
	Timestamps []string          `json:"timestamps"`
	Values     []float64         `json:"values"`
	Total      int               `json:"total"`
}

Hit represents a single hit from the query

type HitsResponse added in v0.11.0

type HitsResponse struct {
	Hits []Hit `json:"hits"`
}

HitsResponse represents response from the hits query

type Labels added in v0.8.0

type Labels map[string]string

Labels represents timeseries labels

type MultitenancyHeaders added in v0.23.3

type MultitenancyHeaders struct {
	AccountID string `json:"AccountID"`
	ProjectID string `json:"ProjectID"`
}

type Query

type Query struct {
	backend.DataQuery `json:"inline"`

	Expr         string    `json:"expr"`
	LegendFormat string    `json:"legendFormat"`
	TimeInterval string    `json:"timeInterval"`
	Interval     string    `json:"interval"`
	IntervalMs   int64     `json:"intervalMs"`
	MaxLines     int       `json:"maxLines"`
	Step         string    `json:"step"`
	Fields       []string  `json:"fields"`
	QueryType    QueryType `json:"queryType"`
	ExtraFilters string    `json:"extraFilters"`

	ForAlerting bool `json:"-"`
	// contains filtered or unexported fields
}

Query represents backend query object

type QueryType added in v0.8.0

type QueryType string

QueryType represents query type

const (
	// QueryTypeInstant represents instant query type
	QueryTypeInstant QueryType = "instant"
	// QueryTypeStats represents stats query type
	QueryTypeStats QueryType = "stats"
	// QueryTypeStatsRange represents stats range query type
	QueryTypeStatsRange QueryType = "statsRange"
	// QueryTypeHits represents hits query type
	QueryTypeHits QueryType = "hits"
)

type Response

type Response struct {
	Status      string `json:"status"`
	Data        Data   `json:"data"`
	Error       string `json:"error"`
	ForAlerting bool   `json:"-"`
}

Response contains fields from query response

type Result added in v0.8.0

type Result struct {
	Labels Labels  `json:"metric"`
	Values []Value `json:"values"`
	Value  Value   `json:"value"`
}

Result represents timeseries from query

type Value added in v0.8.0

type Value [2]interface{}

Value represents timestamp and value of the timeseries

Jump to

Keyboard shortcuts

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