Documentation
¶
Index ¶
- type Data
- type DataSourceInstanceSettings
- type Datasource
- func (d *Datasource) CheckHealth(ctx context.Context, req *backend.CheckHealthRequest) (*backend.CheckHealthResult, error)
- func (d *Datasource) PublishStream(_ context.Context, _ *backend.PublishStreamRequest) (*backend.PublishStreamResponse, error)
- func (d *Datasource) QueryData(ctx context.Context, req *backend.QueryDataRequest) (*backend.QueryDataResponse, error)
- func (d *Datasource) RootHandler(rw http.ResponseWriter, req *http.Request)
- func (d *Datasource) RunStream(ctx context.Context, req *backend.RunStreamRequest, ...) error
- func (d *Datasource) SubscribeStream(ctx context.Context, req *backend.SubscribeStreamRequest) (*backend.SubscribeStreamResponse, error)
- func (d *Datasource) VLAPIQuery(rw http.ResponseWriter, req *http.Request)
- func (d *Datasource) VLAPITenantIDs(rw http.ResponseWriter, req *http.Request)
- func (d *Datasource) VMUIQuery(rw http.ResponseWriter, req *http.Request)
- type DatasourceInstance
- type FieldsQuery
- type GrafanaSettings
- type Hit
- type HitsResponse
- type Labels
- type MultitenancyHeaders
- type Query
- type QueryType
- type Response
- type Result
- type Value
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 ¶
func (d *Datasource) CheckHealth(ctx context.Context, req *backend.CheckHealthRequest) (*backend.CheckHealthResult, error)
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
func (d *Datasource) PublishStream(_ context.Context, _ *backend.PublishStreamRequest) (*backend.PublishStreamResponse, error)
PublishStream called when a user tries to publish to a plugin/datasource managed channel path.
func (*Datasource) QueryData ¶
func (d *Datasource) QueryData(ctx context.Context, req *backend.QueryDataRequest) (*backend.QueryDataResponse, error)
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
func (d *Datasource) SubscribeStream(ctx context.Context, req *backend.SubscribeStreamRequest) (*backend.SubscribeStreamResponse, error)
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 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 MultitenancyHeaders ¶ added in v0.23.3
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