plugin

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2025 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateTableFramesFromQuery

func CreateTableFramesFromQuery(ctx context.Context, tableName string, cursor *mongo.Cursor) (*data.Frame, error)

func CreateTableFramesFromStream added in v0.3.0

func CreateTableFramesFromStream(ctx context.Context, tableName string, stream *mongo.ChangeStream) (*data.Frame, error)

func CreateTimeSeriesFramesFromQuery

func CreateTimeSeriesFramesFromQuery(ctx context.Context, cursor *mongo.Cursor) (map[string]*data.Frame, error)

Create time-series data frames of different names on Mongo query result. Each data frame has field "ts", "value" and "name"

func CreateTimeSeriesFramesFromStream added in v0.3.0

func CreateTimeSeriesFramesFromStream(ctx context.Context, tableName string, stream *mongo.ChangeStream) (*data.Frame, error)

func MongoUri

func MongoUri(config *models.PluginSettings) (string, error)

Validate mongo connection configuration and return connection string

func NewDatasource

NewDatasource creates a new MongoDB datasource instance.

func PrintDataFrame

func PrintDataFrame(dataFrame *data.Frame)

Types

type Datasource

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

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

func (*Datasource) CallResource added in v0.4.1

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.3.0

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.3.0

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

func (*Datasource) SubscribeStream added in v0.3.0

type TimeSeriesRow

type TimeSeriesRow[T any] struct {
	Timestamp time.Time `bson:"ts"`
	Name      string    `bson:"name"`
	Value     T         `bson:"value"`
}

Jump to

Keyboard shortcuts

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