plugin

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsPersonalToken added in v0.1.4

func IsPersonalToken(token string) bool

IsPersonalToken returns true if the given token is a personal token.

func NewDatasource

NewDatasource creates a new datasource instance.

Types

type AplQueryRequest added in v0.1.3

type AplQueryRequest struct {
	query.Options

	// APL is the APL query string.
	APL string `json:"apl"`
}

type AplQueryResponse added in v0.1.3

type AplQueryResponse struct {
	query.Result

	// HINT(lukasmalkmus): Ignore these fields as they are not relevant for the
	// user and/or will change with the new query result format.
	LegacyRequest struct {
		StartTime         any          `json:"startTime"`
		EndTime           any          `json:"endTime"`
		Resolution        any          `json:"resolution"`
		Aggregations      any          `json:"aggregations"`
		Filter            any          `json:"filter"`
		Order             any          `json:"order"`
		Limit             any          `json:"limit"`
		VirtualFields     any          `json:"virtualFields"`
		Projections       []Projection `json:"project"`
		Cursor            any          `json:"cursor"`
		IncludeCursor     any          `json:"includeCursor"`
		ContinuationToken any          `json:"continuationToken"`

		// HINT(lukasmalkmus): Preserve the legacy request's "groupBy"
		// field for now. This is needed to properly render some results.
		GroupBy []string `json:"groupBy"`
	} `json:"request"`
	FieldsMeta any `json:"fieldsMetaMap"`
}

type DatasetField added in v0.1.4

type DatasetField struct {
	Name        string `json:"name"`
	Type        string `json:"type"`
	Unit        string `json:"unit"`
	Hidden      bool   `json:"hidden"`
	Description string `json:"description"`
}

type DatasetFields added in v0.1.4

type DatasetFields struct {
	DatasetName string         `json:"datasetName"`
	Fields      []DatasetField `json:"fields"`
}

type Datasource

type Datasource struct {
	backend.CallResourceHandler
	// 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) DatasetFields added in v0.1.4

func (d *Datasource) DatasetFields(ctx context.Context) ([]*DatasetFields, error)

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) 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) QueryOverride added in v0.1.3

func (d *Datasource) QueryOverride(ctx context.Context, apl string, options ...query.Option) (*AplQueryResponse, error)

func (*Datasource) ServeHTTP added in v0.1.7

func (d *Datasource) ServeHTTP(w http.ResponseWriter, r *http.Request)

type Projection added in v0.1.3

type Projection struct {
	Field string `json:"field"`
	Alias string `json:"alias"`
}

Jump to

Keyboard shortcuts

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