Documentation ¶
Index ¶
- Variables
- func Serve(opts ServeOpts) error
- func SetupPluginEnvironment(pluginID string) log.Logger
- type AppInstanceSettings
- type CallResourceHandler
- type CallResourceRequest
- type CallResourceResponse
- type CallResourceResponseSender
- type CheckHealthHandler
- type CheckHealthRequest
- type CheckHealthResult
- type ConvertFromProtobuf
- func (f ConvertFromProtobuf) CallResourceRequest(protoReq *pluginv2.CallResourceRequest) *CallResourceRequest
- func (f ConvertFromProtobuf) DataQuery(proto *pluginv2.DataQuery) *DataQuery
- func (f ConvertFromProtobuf) DataSourceConfig(proto *pluginv2.DataSourceConfig) *DataSourceConfig
- func (f ConvertFromProtobuf) HealthCheckRequest(protoReq *pluginv2.CheckHealthRequest) *CheckHealthRequest
- func (f ConvertFromProtobuf) PluginConfig(proto *pluginv2.PluginConfig) PluginConfig
- func (f ConvertFromProtobuf) QueryDataRequest(protoReq *pluginv2.QueryDataRequest) *QueryDataRequest
- func (f ConvertFromProtobuf) QueryDataResponse(protoRes *pluginv2.QueryDataResponse) (*QueryDataResponse, error)
- func (f ConvertFromProtobuf) TimeRange(proto *pluginv2.TimeRange) TimeRange
- func (f ConvertFromProtobuf) User(user *pluginv2.User) *User
- type DataQuery
- type DataResponse
- type DataSourceConfig
- type DataSourceInstanceSettings
- type GRPCSettings
- type HealthStatus
- type PluginConfig
- type PluginContext
- type QueryDataHandler
- type QueryDataRequest
- type QueryDataResponse
- type Responses
- type ServeOpts
- type TimeRange
- type TransformDataCallBackHandler
- type TransformDataHandler
- type TransformHandlers
- type User
Constants ¶
This section is empty.
Variables ¶
var Logger log.Logger = log.DefaultLogger
Logger is the default logger instance.
Functions ¶
func SetupPluginEnvironment ¶
SetupPluginEnvironment will read the environment variables and apply the standard environment behavior. As the SDK evolves, this will likely change!
Types ¶
type AppInstanceSettings ¶
type AppInstanceSettings struct { // JSONData repeats the properties at this level of the object (excluding DataSourceConfig), and also includes any //custom properties associated with the plugin config instance. JSONData json.RawMessage // DecryptedSecureJSONData contains key,value pairs where the encrypted configuration plugin instance in Grafana //server have been decrypted before passing them to the plugin. DecryptedSecureJSONData map[string]string // Updated is the last time this plugin instance's configuration was updated. Updated time.Time }
AppInstanceSettings represents settings for an app instance.
In Grafana an app instance is an app plugin of certain type that have been configured and enabled in a Grafana organization.
type CallResourceHandler ¶
type CallResourceHandler interface {
CallResource(ctx context.Context, req *CallResourceRequest, sender CallResourceResponseSender) error
}
CallResourceHandler handles resource calls.
type CallResourceRequest ¶
type CallResourceResponse ¶
type CallResourceResponseSender ¶
type CallResourceResponseSender interface {
Send(*CallResourceResponse) error
}
CallResourceResponseSender used for sending resource call responses.
type CheckHealthHandler ¶
type CheckHealthHandler interface {
CheckHealth(ctx context.Context, req *CheckHealthRequest) (*CheckHealthResult, error)
}
CheckHealthHandler enables users to send health check requests to a backend plugin
type CheckHealthRequest ¶
type CheckHealthRequest struct {
PluginConfig PluginConfig
}
CheckHealthRequest contains the healthcheck request
type CheckHealthResult ¶
type CheckHealthResult struct { Status HealthStatus Message string JSONDetails []byte }
CheckHealthResult contains the healthcheck response
type ConvertFromProtobuf ¶
type ConvertFromProtobuf struct { }
func FromProto ¶
func FromProto() ConvertFromProtobuf
func (ConvertFromProtobuf) CallResourceRequest ¶
func (f ConvertFromProtobuf) CallResourceRequest(protoReq *pluginv2.CallResourceRequest) *CallResourceRequest
func (ConvertFromProtobuf) DataQuery ¶
func (f ConvertFromProtobuf) DataQuery(proto *pluginv2.DataQuery) *DataQuery
func (ConvertFromProtobuf) DataSourceConfig ¶
func (f ConvertFromProtobuf) DataSourceConfig(proto *pluginv2.DataSourceConfig) *DataSourceConfig
func (ConvertFromProtobuf) HealthCheckRequest ¶
func (f ConvertFromProtobuf) HealthCheckRequest(protoReq *pluginv2.CheckHealthRequest) *CheckHealthRequest
HealthCheckRequest converts proto version to SDK version.
func (ConvertFromProtobuf) PluginConfig ¶
func (f ConvertFromProtobuf) PluginConfig(proto *pluginv2.PluginConfig) PluginConfig
func (ConvertFromProtobuf) QueryDataRequest ¶
func (f ConvertFromProtobuf) QueryDataRequest(protoReq *pluginv2.QueryDataRequest) *QueryDataRequest
func (ConvertFromProtobuf) QueryDataResponse ¶
func (f ConvertFromProtobuf) QueryDataResponse(protoRes *pluginv2.QueryDataResponse) (*QueryDataResponse, error)
type DataQuery ¶
type DataQuery struct { RefID string MaxDataPoints int64 Interval time.Duration TimeRange TimeRange JSON json.RawMessage }
DataQuery represents the query as sent from the frontend.
type DataResponse ¶
type DataResponse struct { // The data returned from the Query. Each Frame repeats the RefID. Frames data.Frames // Error is a property to be set if the the corresponding DataQuery has an error. Error error // Add Tables and Timeseries for compatibility with 6.7 Series []*pluginv2.TimeSeries Tables []*pluginv2.Table JSON string }
DataResponse contains the results from a DataQuery. A map of RefIDs (unique query identifers) to this type makes up the Responses property of a QueryDataResponse. The Error property is used to allow for partial success responses from the containing QueryDataResponse.
type DataSourceConfig ¶
type DataSourceConfig struct { ID int64 Name string URL string User string Database string BasicAuthEnabled bool BasicAuthUser string JSONData json.RawMessage DecryptedSecureJSONData map[string]string Updated time.Time }
DataSourceConfig configuration for a datasource plugin.
type DataSourceInstanceSettings ¶
type DataSourceInstanceSettings struct { // ID is the Grafana assigned numeric identifier of the the data source instance. ID int64 // Name is the configured name of the data source instance. Name string // URL is the configured URL of a data source instance (e.g. the URL of an API endpoint). URL string // User is a configured user for a data source instance. This is not a Grafana user, rather an arbitrary string. User string // Database is the configured database for a data source instance. (e.g. the default Database a SQL data source would connect to). Database string // BasicAuthEnabled indicates if this data source instance should use basic authentication. BasicAuthEnabled bool // BasicAuthUser is the configured user for basic authentication. (e.g. when a data source uses basic // authentication to connect to whatever API it fetches data from). BasicAuthUser string // JSONData contains the raw DataSourceConfig as JSON as stored by Grafana server. It repeats the properties in // this object and includes custom properties. JSONData json.RawMessage // DecryptedSecureJSONData contains key,value pairs where the encrypted configuration in Grafana server have been // decrypted before passing them to the plugin. DecryptedSecureJSONData map[string]string // Updated is the last time the configuration for the data source instance was updated. Updated time.Time }
DataSourceInstanceSettings represents settings for a data source instance.
In Grafana a data source instance is a data source plugin of certain type that have been configured and created in a Grafana organization.
type GRPCSettings ¶
type GRPCSettings struct { // MaxReceiveMsgSize the max gRPC message size in bytes the plugin can receive. // If this is <= 0, gRPC uses the default 16MB. MaxReceiveMsgSize int // MaxSendMsgSize the max gRPC message size in bytes the plugin can send. // If this is <= 0, gRPC uses the default `math.MaxInt32`. MaxSendMsgSize int }
GRPCSettings settings for gRPC.
type HealthStatus ¶
type HealthStatus int
HealthStatus is the status of the plugin.
const ( // HealthStatusUnknown means the status of the plugin is unknown. HealthStatusUnknown HealthStatus = iota // HealthStatusOk means the status of the plugin is good. HealthStatusOk // HealthStatusError means the plugin is in an error state. HealthStatusError )
type PluginConfig ¶
type PluginConfig struct { OrgID int64 PluginID string JSONData json.RawMessage DecryptedSecureJSONData map[string]string Updated time.Time DataSourceConfig *DataSourceConfig }
PluginConfig configuration for a plugin.
type PluginContext ¶
type PluginContext struct { // OrgID is The Grafana organization identifier the request originating from. OrgID int64 // PluginID is the unique identifier of the plugin that the request is for. PluginID string // User is the Grafana user making the request. // // Will not be provided if Grafana backend initiated the request, // for example when request is coming from Grafana Alerting. User *User // AppInstanceSettings is the configured app instance settings. // // In Grafana an app instance is an app plugin of certain // type that have been configured and enabled in a Grafana organization. // // Will only be set if request targeting an app instance. AppInstanceSettings *AppInstanceSettings // DataSourceConfig is the configured data source instance // settings. // // In Grafana a data source instance is a data source plugin of certain // type that have been configured and created in a Grafana organization. // // Will only be set if request targeting a data source instance. DataSourceInstanceSettings *DataSourceInstanceSettings }
PluginContext holds contextual information about a plugin request, such as Grafana organization, user and plugin instance settings.
type QueryDataHandler ¶
type QueryDataHandler interface {
QueryData(ctx context.Context, req *QueryDataRequest) (*QueryDataResponse, error)
}
QueryDataHandler handles data queries.
type QueryDataRequest ¶
type QueryDataRequest struct { PluginConfig PluginConfig Headers map[string]string Queries []DataQuery User *User }
type QueryDataResponse ¶
type QueryDataResponse struct { // Responses is a map of RefIDs (Unique Query ID) to *DataResponse. Responses Responses Frames []*data.Frame Metadata map[string]string Json string }
QueryDataResponse contains the results from a QueryDataRequest. It is the return type of a QueryData call.
func NewQueryDataResponse ¶
func NewQueryDataResponse() *QueryDataResponse
NewQueryDataResponse returns a QueryDataResponse with the Responses property initialized.
type Responses ¶
type Responses map[string]DataResponse
Responses is a map of RefIDs (Unique Query ID) to DataResponses. The QueryData method the QueryDataHandler method will set the RefId property on the DataRespones' frames based on these RefIDs.
type ServeOpts ¶
type ServeOpts struct { // CheckHealthHandler handler for health checks. CheckHealthHandler CheckHealthHandler // CallResourceHandler handler for resource calls. // Optional to implement. CallResourceHandler CallResourceHandler // QueryDataHandler handler for data queries. // Required to implement if data source. QueryDataHandler QueryDataHandler // TransformDataHandler handler for data transformations. // Very experimental and shouldn't be implemented in most cases. // Optional to implement. TransformDataHandler TransformDataHandler // GRPCSettings settings for gPRC. GRPCSettings GRPCSettings }
ServeOpts options for serving plugins.
type TransformDataCallBackHandler ¶
type TransformDataCallBackHandler interface { // TODO: Forget if I actually need PluginConfig on the callback or not. QueryData(ctx context.Context, req *QueryDataRequest) (*QueryDataResponse, error) }
type TransformDataHandler ¶
type TransformDataHandler interface {
TransformData(ctx context.Context, req *QueryDataRequest, callBack TransformDataCallBackHandler) (*QueryDataResponse, error)
}
type TransformHandlers ¶
type TransformHandlers interface { TransformDataHandler }
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package instancemgmt provides utilities for managing plugin instances.
|
Package instancemgmt provides utilities for managing plugin instances. |
resource
|
|
httpadapter
Package httpadapter provides support for handling resource calls using an http.Handler.
|
Package httpadapter provides support for handling resource calls using an http.Handler. |