plugin

package
v0.0.0-...-741799f Latest Latest
Warning

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

Go to latest
Published: May 19, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckHealth

CheckHealth ensures that the datasource settings are able to retrieve data from

func GetDatasourceOpts

func GetDatasourceOpts() datasource.ServeOpts

GetDatasourceOpts returns the datasource.ServeOpts for this plugin

func GetQueryHandlers

func GetQueryHandlers(s *Server) *datasource.QueryTypeMux

GetQueryHandlers creates the QueryTypeMux type for handling queries

func HandleQueryData

HandleQueryData handles the `QueryData` request for the datasource

func UnmarshalQuery

func UnmarshalQuery(b []byte, v interface{}) *backend.DataResponse

UnmarshalQuery attempts to unmarshal a query from JSON

Types

type Datasource

type Datasource interface {
	HandleMetricsQuery(context.Context, *models.MetricsQuery, backend.DataQuery) (dfutil.Framer, error)
	HandleLogQuery(context.Context, *models.LogQuery, backend.DataQuery) (dfutil.Framer, error)
	HandleApplicationErrorsQuery(context.Context, *models.ApplicationErrorsQuery, backend.DataQuery) (dfutil.Framer, error)
	CheckHealth(context.Context) error
}

The Datasource type handles the requests sent to the datasource backend

type Handler

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

Handler is the plugin entrypoint and implements all of the necessary handler functions for dataqueries, healthchecks, and resources.

func (*Handler) 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 (*Handler) QueryData

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

type Instance

type Instance struct {
	Datasource Datasource
}

Instance is the root Datasource implementation that wraps a Datasource

func NewInstance

func NewInstance(ctx context.Context, settings models.Settings) *Instance

NewInstance creates a new Instance using the settings to determine if things like the Caching Wrapper should be enabled

func (*Instance) CheckHealth

func (i *Instance) CheckHealth(ctx context.Context) error

CheckHealth ...

func (*Instance) HandleApplicationErrorsQuery

func (i *Instance) HandleApplicationErrorsQuery(ctx context.Context, q *models.ApplicationErrorsQuery, req backend.DataQuery) (dfutil.Framer, error)

func (*Instance) HandleLogQuery

func (i *Instance) HandleLogQuery(ctx context.Context, q *models.LogQuery, req backend.DataQuery) (dfutil.Framer, error)

func (*Instance) HandleMetricsQuery

func (i *Instance) HandleMetricsQuery(ctx context.Context, q *models.MetricsQuery, req backend.DataQuery) (dfutil.Framer, error)

type QueryHandlerFunc

type QueryHandlerFunc func(context.Context, backend.DataQuery) backend.DataResponse

QueryHandlerFunc is the function signature used for mux.HandleFunc

type Server

type Server struct {
	Datasource Datasource
}

Server is the main handler for datasource queries. It forwards requests to the embedded datasource interface.

func (*Server) HandleApplicationErrors

func (s *Server) HandleApplicationErrors(ctx context.Context, req *backend.QueryDataRequest) (*backend.QueryDataResponse, error)

func (*Server) HandleLog

func (*Server) HandleMetrics

func (s *Server) HandleMetrics(ctx context.Context, req *backend.QueryDataRequest) (*backend.QueryDataResponse, error)

Jump to

Keyboard shortcuts

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