mirror of
https://github.com/grafana/grafana.git
synced 2024-11-25 10:20:29 -06:00
Cloud Monitoring: Add standalone files and modify plugin.json (#81596)
This commit is contained in:
parent
1966ce609c
commit
be6efd9518
@ -34,7 +34,7 @@ func corePlugins(rt *thema.Runtime) []pfs.ParsedPlugin {
|
||||
return []pfs.ParsedPlugin{
|
||||
parsePluginOrPanic("public/app/plugins/datasource/alertmanager", "alertmanager", rt),
|
||||
parsePluginOrPanic("public/app/plugins/datasource/azuremonitor", "grafana_azure_monitor_datasource", rt),
|
||||
parsePluginOrPanic("public/app/plugins/datasource/cloud-monitoring", "stackdriver", rt),
|
||||
parsePluginOrPanic("public/app/plugins/datasource/cloud-monitoring", "grafana_cloud_monitoring_datasource", rt),
|
||||
parsePluginOrPanic("public/app/plugins/datasource/cloudwatch", "cloudwatch", rt),
|
||||
parsePluginOrPanic("public/app/plugins/datasource/dashboard", "dashboard", rt),
|
||||
parsePluginOrPanic("public/app/plugins/datasource/elasticsearch", "elasticsearch", rt),
|
||||
|
@ -16,7 +16,7 @@ schemas: [{
|
||||
// grafana.com, then the plugin `id` has to follow the naming
|
||||
// conventions.
|
||||
id: string & strings.MinRunes(1)
|
||||
id: =~"^([0-9a-z]+\\-([0-9a-z]+\\-)?(\(strings.Join([ for t in _types {t}], "|"))))|(alertGroups|alertlist|annolist|barchart|bargauge|candlestick|canvas|dashlist|debug|datagrid|gauge|geomap|gettingstarted|graph|heatmap|histogram|icon|live|logs|news|nodeGraph|piechart|pluginlist|stat|state-timeline|status-history|table|table-old|text|timeseries|trend|traces|welcome|xychart|alertmanager|cloudwatch|dashboard|elasticsearch|grafana|grafana-azure-monitor-datasource|graphite|influxdb|jaeger|loki|mixed|mssql|mysql|opentsdb|postgres|prometheus|stackdriver|tempo|grafana-testdata-datasource|zipkin|phlare|parca)$"
|
||||
id: =~"^([0-9a-z]+\\-([0-9a-z]+\\-)?(\(strings.Join([ for t in _types {t}], "|"))))|(alertGroups|alertlist|annolist|barchart|bargauge|candlestick|canvas|dashlist|debug|datagrid|gauge|geomap|gettingstarted|graph|heatmap|histogram|icon|live|logs|news|nodeGraph|piechart|pluginlist|stat|state-timeline|status-history|table|table-old|text|timeseries|trend|traces|welcome|xychart|alertmanager|cloudwatch|dashboard|elasticsearch|grafana|grafana-azure-monitor-datasource|grafana-cloud-monitoring-datasource|graphite|influxdb|jaeger|loki|mixed|mssql|mysql|opentsdb|postgres|prometheus|stackdriver|tempo|grafana-testdata-datasource|zipkin|phlare|parca)$"
|
||||
|
||||
// An alias is useful when migrating from one plugin id to another (rebranding etc)
|
||||
// This should be used sparingly, and is currently only supported though a hardcoded checklist
|
||||
|
@ -165,29 +165,29 @@ func verifyCorePluginCatalogue(t *testing.T, ctx context.Context, ps *pluginstor
|
||||
}
|
||||
|
||||
expDataSources := map[string]struct{}{
|
||||
"cloudwatch": {},
|
||||
"stackdriver": {},
|
||||
"grafana-azure-monitor-datasource": {},
|
||||
"elasticsearch": {},
|
||||
"graphite": {},
|
||||
"influxdb": {},
|
||||
"loki": {},
|
||||
"opentsdb": {},
|
||||
"prometheus": {},
|
||||
"tempo": {},
|
||||
"grafana-testdata-datasource": {},
|
||||
"grafana-postgresql-datasource": {},
|
||||
"mysql": {},
|
||||
"mssql": {},
|
||||
"grafana": {},
|
||||
"alertmanager": {},
|
||||
"dashboard": {},
|
||||
"input": {},
|
||||
"jaeger": {},
|
||||
"mixed": {},
|
||||
"zipkin": {},
|
||||
"grafana-pyroscope-datasource": {},
|
||||
"parca": {},
|
||||
"cloudwatch": {},
|
||||
"grafana-azure-monitor-datasource": {},
|
||||
"grafana-cloud-monitoring-datasource": {},
|
||||
"elasticsearch": {},
|
||||
"graphite": {},
|
||||
"influxdb": {},
|
||||
"loki": {},
|
||||
"opentsdb": {},
|
||||
"prometheus": {},
|
||||
"tempo": {},
|
||||
"grafana-testdata-datasource": {},
|
||||
"grafana-postgresql-datasource": {},
|
||||
"mysql": {},
|
||||
"mssql": {},
|
||||
"grafana": {},
|
||||
"alertmanager": {},
|
||||
"dashboard": {},
|
||||
"input": {},
|
||||
"jaeger": {},
|
||||
"mixed": {},
|
||||
"zipkin": {},
|
||||
"grafana-pyroscope-datasource": {},
|
||||
"parca": {},
|
||||
}
|
||||
|
||||
expApps := map[string]struct{}{
|
||||
|
@ -626,7 +626,7 @@
|
||||
{
|
||||
"name": "Google Cloud Monitoring",
|
||||
"type": "datasource",
|
||||
"id": "stackdriver",
|
||||
"id": "grafana-cloud-monitoring-datasource",
|
||||
"enabled": true,
|
||||
"pinned": false,
|
||||
"info": {
|
||||
@ -652,7 +652,7 @@
|
||||
},
|
||||
"latestVersion": "",
|
||||
"hasUpdate": false,
|
||||
"defaultNavUrl": "/plugins/stackdriver/",
|
||||
"defaultNavUrl": "/plugins/grafana-cloud-monitoring-datasource/",
|
||||
"category": "cloud",
|
||||
"state": "",
|
||||
"signature": "internal",
|
||||
|
38
pkg/tsdb/cloud-monitoring/standalone/datasource.go
Normal file
38
pkg/tsdb/cloud-monitoring/standalone/datasource.go
Normal file
@ -0,0 +1,38 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/grafana/grafana-plugin-sdk-go/backend"
|
||||
"github.com/grafana/grafana-plugin-sdk-go/backend/httpclient"
|
||||
"github.com/grafana/grafana-plugin-sdk-go/backend/instancemgmt"
|
||||
cloudmonitoring "github.com/grafana/grafana/pkg/tsdb/cloud-monitoring"
|
||||
)
|
||||
|
||||
var (
|
||||
_ backend.QueryDataHandler = (*Datasource)(nil)
|
||||
_ backend.CheckHealthHandler = (*Datasource)(nil)
|
||||
_ backend.CallResourceHandler = (*Datasource)(nil)
|
||||
)
|
||||
|
||||
func NewDatasource(context.Context, backend.DataSourceInstanceSettings) (instancemgmt.Instance, error) {
|
||||
return &Datasource{
|
||||
Service: cloudmonitoring.ProvideService(httpclient.NewProvider()),
|
||||
}, nil
|
||||
}
|
||||
|
||||
type Datasource struct {
|
||||
Service *cloudmonitoring.Service
|
||||
}
|
||||
|
||||
func (d *Datasource) QueryData(ctx context.Context, req *backend.QueryDataRequest) (*backend.QueryDataResponse, error) {
|
||||
return d.Service.QueryData(ctx, req)
|
||||
}
|
||||
|
||||
func (d *Datasource) CallResource(ctx context.Context, req *backend.CallResourceRequest, sender backend.CallResourceResponseSender) error {
|
||||
return d.Service.CallResource(ctx, req, sender)
|
||||
}
|
||||
|
||||
func (d *Datasource) CheckHealth(ctx context.Context, req *backend.CheckHealthRequest) (*backend.CheckHealthResult, error) {
|
||||
return d.Service.CheckHealth(ctx, req)
|
||||
}
|
23
pkg/tsdb/cloud-monitoring/standalone/main.go
Normal file
23
pkg/tsdb/cloud-monitoring/standalone/main.go
Normal file
@ -0,0 +1,23 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"github.com/grafana/grafana-plugin-sdk-go/backend/datasource"
|
||||
"github.com/grafana/grafana-plugin-sdk-go/backend/log"
|
||||
)
|
||||
|
||||
func main() {
|
||||
// Start listening to requests sent from Grafana. This call is blocking so
|
||||
// it won't finish until Grafana shuts down the process or the plugin choose
|
||||
// to exit by itself using os.Exit. Manage automatically manages life cycle
|
||||
// of datasource instances. It accepts datasource instance factory as first
|
||||
// argument. This factory will be automatically called on incoming request
|
||||
// from Grafana to create different instances of SampleDatasource (per datasource
|
||||
// ID). When datasource configuration changed Dispose method will be called and
|
||||
// new datasource instance created using NewSampleDatasource factory.
|
||||
if err := datasource.Manage("grafana-cloud-monitoring-datasource", NewDatasource, datasource.ManageOpts{}); err != nil {
|
||||
log.DefaultLogger.Error(err.Error())
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
@ -1,13 +1,14 @@
|
||||
{
|
||||
"name": "Google Cloud Monitoring",
|
||||
"type": "datasource",
|
||||
"id": "stackdriver",
|
||||
"name": "Google Cloud Monitoring",
|
||||
"id": "grafana-cloud-monitoring-datasource",
|
||||
"category": "cloud",
|
||||
|
||||
"metrics": true,
|
||||
"alerting": true,
|
||||
"annotations": true,
|
||||
"backend": true,
|
||||
"logs": true,
|
||||
"includes": [
|
||||
{
|
||||
"type": "dashboard",
|
||||
@ -79,7 +80,7 @@
|
||||
"maxDataPoints": true,
|
||||
"cacheTimeout": true
|
||||
},
|
||||
|
||||
"executable": "gpx_cloudmonitoring",
|
||||
"info": {
|
||||
"description": "Data source for Google's monitoring service (formerly named Stackdriver)",
|
||||
"version": "%VERSION%",
|
||||
|
Loading…
Reference in New Issue
Block a user