Commit a9aaa5ad by Torkel Ödegaard

Merge branch 'master' of github.com:grafana/grafana

parents 6c1fee73 183f3239
...@@ -62,6 +62,7 @@ pages: ...@@ -62,6 +62,7 @@ pages:
- ['reference/templating.md', 'Reference', 'Templating'] - ['reference/templating.md', 'Reference', 'Templating']
- ['reference/scripting.md', 'Reference', 'Scripting'] - ['reference/scripting.md', 'Reference', 'Scripting']
- ['reference/playlist.md', 'Reference', 'Playlist'] - ['reference/playlist.md', 'Reference', 'Playlist']
- ['reference/plugins.md', 'Reference', 'Plugins']
- ['reference/export_import.md', 'Reference', 'Import & Export'] - ['reference/export_import.md', 'Reference', 'Import & Export']
- ['reference/admin.md', 'Reference', 'Administration'] - ['reference/admin.md', 'Reference', 'Administration']
- ['reference/http_api.md', 'Reference', 'HTTP API'] - ['reference/http_api.md', 'Reference', 'HTTP API']
......
---
page_title: Plugin guide
page_description: Plugin guide for Grafana
page_keywords: grafana, plugins, documentation
---
# Plugins
!Plugin support for panels is only available in nightly!
Adding support for all datasources and suggested panels would bloat grafana and make it impossible to maintain. That's why we implemented a plugin system that makes it possible for anyone to develop support for a datasource or custom panel without adding it to Grafana itself.
## Installing plugins
Installing a plugin is very simple. Just download it and place it in the Grafana plugins folder and restart grafana.
The default plugin folder is configurable under paths.plugins
It's also possible to add one specific plugin by linking to its folder.
```
[plugin.mirror]
path = /home/evil-queen/datasource-plugin-mirror
```
## Plugin implementation ##
Each plugin is defined in plugin.json file in the plugin folder.
Instead of massive documentation about how it works we created a reference implementation of a plugin.
You can find each reference implementation further down on this page.
## Datasource plugins
Datasource have three responsibilities.
* UI for configuring its settings
* Datasource object that can send queries, metricqueries and healthcheck the datasource
* Query editor within panels
https://github.com/grafana/datasource-plugin-genericdatasource
## Panel plugins
Panel plugins are responsible for
* UI for Panel options.
* Creating a directive that can render something based on datasource data.
We currently dont have a reference implementation for panel plugins but you can checkout https://github.com/grafana/panel-plugin-piechart
...@@ -43,18 +43,29 @@ func init() { ...@@ -43,18 +43,29 @@ func init() {
} }
} }
func handleGetMetricStatistics(req *cwRequest, c *middleware.Context) { var awsCredentials map[string]*credentials.Credentials = make(map[string]*credentials.Credentials)
func getCredentials(profile string) *credentials.Credentials {
if _, ok := awsCredentials[profile]; ok {
return awsCredentials[profile]
}
sess := session.New() sess := session.New()
creds := credentials.NewChainCredentials( creds := credentials.NewChainCredentials(
[]credentials.Provider{ []credentials.Provider{
&credentials.EnvProvider{}, &credentials.EnvProvider{},
&credentials.SharedCredentialsProvider{Filename: "", Profile: req.DataSource.Database}, &credentials.SharedCredentialsProvider{Filename: "", Profile: profile},
&ec2rolecreds.EC2RoleProvider{Client: ec2metadata.New(sess), ExpiryWindow: 5 * time.Minute}, &ec2rolecreds.EC2RoleProvider{Client: ec2metadata.New(sess), ExpiryWindow: 5 * time.Minute},
}) })
awsCredentials[profile] = creds
return creds
}
func handleGetMetricStatistics(req *cwRequest, c *middleware.Context) {
cfg := &aws.Config{ cfg := &aws.Config{
Region: aws.String(req.Region), Region: aws.String(req.Region),
Credentials: creds, Credentials: getCredentials(req.DataSource.Database),
} }
svc := cloudwatch.New(session.New(cfg), cfg) svc := cloudwatch.New(session.New(cfg), cfg)
...@@ -92,17 +103,9 @@ func handleGetMetricStatistics(req *cwRequest, c *middleware.Context) { ...@@ -92,17 +103,9 @@ func handleGetMetricStatistics(req *cwRequest, c *middleware.Context) {
} }
func handleListMetrics(req *cwRequest, c *middleware.Context) { func handleListMetrics(req *cwRequest, c *middleware.Context) {
sess := session.New()
creds := credentials.NewChainCredentials(
[]credentials.Provider{
&credentials.EnvProvider{},
&credentials.SharedCredentialsProvider{Filename: "", Profile: req.DataSource.Database},
&ec2rolecreds.EC2RoleProvider{Client: ec2metadata.New(sess), ExpiryWindow: 5 * time.Minute},
})
cfg := &aws.Config{ cfg := &aws.Config{
Region: aws.String(req.Region), Region: aws.String(req.Region),
Credentials: creds, Credentials: getCredentials(req.DataSource.Database),
} }
svc := cloudwatch.New(session.New(cfg), cfg) svc := cloudwatch.New(session.New(cfg), cfg)
...@@ -140,17 +143,9 @@ func handleListMetrics(req *cwRequest, c *middleware.Context) { ...@@ -140,17 +143,9 @@ func handleListMetrics(req *cwRequest, c *middleware.Context) {
} }
func handleDescribeAlarmsForMetric(req *cwRequest, c *middleware.Context) { func handleDescribeAlarmsForMetric(req *cwRequest, c *middleware.Context) {
sess := session.New()
creds := credentials.NewChainCredentials(
[]credentials.Provider{
&credentials.EnvProvider{},
&credentials.SharedCredentialsProvider{Filename: "", Profile: req.DataSource.Database},
&ec2rolecreds.EC2RoleProvider{Client: ec2metadata.New(sess), ExpiryWindow: 5 * time.Minute},
})
cfg := &aws.Config{ cfg := &aws.Config{
Region: aws.String(req.Region), Region: aws.String(req.Region),
Credentials: creds, Credentials: getCredentials(req.DataSource.Database),
} }
svc := cloudwatch.New(session.New(cfg), cfg) svc := cloudwatch.New(session.New(cfg), cfg)
...@@ -188,17 +183,9 @@ func handleDescribeAlarmsForMetric(req *cwRequest, c *middleware.Context) { ...@@ -188,17 +183,9 @@ func handleDescribeAlarmsForMetric(req *cwRequest, c *middleware.Context) {
} }
func handleDescribeAlarmHistory(req *cwRequest, c *middleware.Context) { func handleDescribeAlarmHistory(req *cwRequest, c *middleware.Context) {
sess := session.New()
creds := credentials.NewChainCredentials(
[]credentials.Provider{
&credentials.EnvProvider{},
&credentials.SharedCredentialsProvider{Filename: "", Profile: req.DataSource.Database},
&ec2rolecreds.EC2RoleProvider{Client: ec2metadata.New(sess), ExpiryWindow: 5 * time.Minute},
})
cfg := &aws.Config{ cfg := &aws.Config{
Region: aws.String(req.Region), Region: aws.String(req.Region),
Credentials: creds, Credentials: getCredentials(req.DataSource.Database),
} }
svc := cloudwatch.New(session.New(cfg), cfg) svc := cloudwatch.New(session.New(cfg), cfg)
...@@ -232,17 +219,9 @@ func handleDescribeAlarmHistory(req *cwRequest, c *middleware.Context) { ...@@ -232,17 +219,9 @@ func handleDescribeAlarmHistory(req *cwRequest, c *middleware.Context) {
} }
func handleDescribeInstances(req *cwRequest, c *middleware.Context) { func handleDescribeInstances(req *cwRequest, c *middleware.Context) {
sess := session.New()
creds := credentials.NewChainCredentials(
[]credentials.Provider{
&credentials.EnvProvider{},
&credentials.SharedCredentialsProvider{Filename: "", Profile: req.DataSource.Database},
&ec2rolecreds.EC2RoleProvider{Client: ec2metadata.New(sess), ExpiryWindow: 5 * time.Minute},
})
cfg := &aws.Config{ cfg := &aws.Config{
Region: aws.String(req.Region), Region: aws.String(req.Region),
Credentials: creds, Credentials: getCredentials(req.DataSource.Database),
} }
svc := ec2.New(session.New(cfg), cfg) svc := ec2.New(session.New(cfg), cfg)
......
...@@ -44,7 +44,7 @@ ...@@ -44,7 +44,7 @@
<table class="grafana-options-table"> <table class="grafana-options-table">
<tr ng-repeat="annotation in annotations"> <tr ng-repeat="annotation in annotations">
<td style="width:90%"> <td style="width:90%">
<i class="fa fa-bolt"></i> &nbsp; <i class="fa fa-bolt" style="color:{{annotation.iconColor}}"></i> &nbsp;
{{annotation.name}} {{annotation.name}}
</td> </td>
<td style="width: 1%"><i ng-click="_.move(annotations,$index,$index-1)" ng-hide="$first" class="pointer fa fa-arrow-up"></i></td> <td style="width: 1%"><i ng-click="_.move(annotations,$index,$index-1)" ng-hide="$first" class="pointer fa fa-arrow-up"></i></td>
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
<ul class="tight-form-list" ng-if="dashboard.annotations.list.length > 0"> <ul class="tight-form-list" ng-if="dashboard.annotations.list.length > 0">
<li ng-repeat="annotation in dashboard.annotations.list" class="submenu-item annotation-segment" ng-class="{'annotation-disabled': !annotation.enable}"> <li ng-repeat="annotation in dashboard.annotations.list" class="submenu-item annotation-segment" ng-class="{'annotation-disabled': !annotation.enable}">
<a ng-click="disableAnnotation(annotation)"> <a ng-click="disableAnnotation(annotation)">
<i class="fa fa-bolt"></i> <i class="fa fa-bolt" style="color:{{annotation.iconColor}}"></i>
{{annotation.name}} {{annotation.name}}
<input class="cr1" id="hideYAxis" type="checkbox" ng-model="annotation.enable" ng-checked="annotation.enable"> <input class="cr1" id="hideYAxis" type="checkbox" ng-model="annotation.enable" ng-checked="annotation.enable">
<label for="hideYAxis" class="cr1"></label> <label for="hideYAxis" class="cr1"></label>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment