plugin

package
v0.18.0 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2025 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewDatasource

NewDatasource creates a new datasource instance.

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 Datasource

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

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

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) Dispose

func (d *Datasource) 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.

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) RunStream added in v0.7.0

func (d *Datasource) RunStream(ctx context.Context, request *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.

type GrafanaSettings added in v0.13.3

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

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 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"`

	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