Skip to content

Commit a9aaa5a

Browse files
committed
Merge branch 'master' of github.com:grafana/grafana
2 parents 6c1fee7 + 183f323 commit a9aaa5a

File tree

5 files changed

+71
-41
lines changed

5 files changed

+71
-41
lines changed

docs/mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ pages:
6262
- ['reference/templating.md', 'Reference', 'Templating']
6363
- ['reference/scripting.md', 'Reference', 'Scripting']
6464
- ['reference/playlist.md', 'Reference', 'Playlist']
65+
- ['reference/plugins.md', 'Reference', 'Plugins']
6566
- ['reference/export_import.md', 'Reference', 'Import & Export']
6667
- ['reference/admin.md', 'Reference', 'Administration']
6768
- ['reference/http_api.md', 'Reference', 'HTTP API']

docs/sources/reference/plugins.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
---
2+
page_title: Plugin guide
3+
page_description: Plugin guide for Grafana
4+
page_keywords: grafana, plugins, documentation
5+
---
6+
7+
# Plugins
8+
9+
!Plugin support for panels is only available in nightly!
10+
11+
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.
12+
13+
## Installing plugins
14+
15+
Installing a plugin is very simple. Just download it and place it in the Grafana plugins folder and restart grafana.
16+
17+
The default plugin folder is configurable under paths.plugins
18+
19+
It's also possible to add one specific plugin by linking to its folder.
20+
21+
```
22+
[plugin.mirror]
23+
path = /home/evil-queen/datasource-plugin-mirror
24+
```
25+
26+
## Plugin implementation ##
27+
28+
Each plugin is defined in plugin.json file in the plugin folder.
29+
30+
Instead of massive documentation about how it works we created a reference implementation of a plugin.
31+
You can find each reference implementation further down on this page.
32+
33+
## Datasource plugins
34+
35+
Datasource have three responsibilities.
36+
37+
* UI for configuring its settings
38+
* Datasource object that can send queries, metricqueries and healthcheck the datasource
39+
* Query editor within panels
40+
41+
https://github.com/grafana/datasource-plugin-genericdatasource
42+
43+
## Panel plugins
44+
45+
Panel plugins are responsible for
46+
47+
* UI for Panel options.
48+
* Creating a directive that can render something based on datasource data.
49+
50+
We currently dont have a reference implementation for panel plugins but you can checkout https://github.com/grafana/panel-plugin-piechart

pkg/api/cloudwatch/cloudwatch.go

Lines changed: 18 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -43,18 +43,29 @@ func init() {
4343
}
4444
}
4545

46-
func handleGetMetricStatistics(req *cwRequest, c *middleware.Context) {
46+
var awsCredentials map[string]*credentials.Credentials = make(map[string]*credentials.Credentials)
47+
48+
func getCredentials(profile string) *credentials.Credentials {
49+
if _, ok := awsCredentials[profile]; ok {
50+
return awsCredentials[profile]
51+
}
52+
4753
sess := session.New()
4854
creds := credentials.NewChainCredentials(
4955
[]credentials.Provider{
5056
&credentials.EnvProvider{},
51-
&credentials.SharedCredentialsProvider{Filename: "", Profile: req.DataSource.Database},
57+
&credentials.SharedCredentialsProvider{Filename: "", Profile: profile},
5258
&ec2rolecreds.EC2RoleProvider{Client: ec2metadata.New(sess), ExpiryWindow: 5 * time.Minute},
5359
})
60+
awsCredentials[profile] = creds
5461

62+
return creds
63+
}
64+
65+
func handleGetMetricStatistics(req *cwRequest, c *middleware.Context) {
5566
cfg := &aws.Config{
5667
Region: aws.String(req.Region),
57-
Credentials: creds,
68+
Credentials: getCredentials(req.DataSource.Database),
5869
}
5970

6071
svc := cloudwatch.New(session.New(cfg), cfg)
@@ -92,17 +103,9 @@ func handleGetMetricStatistics(req *cwRequest, c *middleware.Context) {
92103
}
93104

94105
func handleListMetrics(req *cwRequest, c *middleware.Context) {
95-
sess := session.New()
96-
creds := credentials.NewChainCredentials(
97-
[]credentials.Provider{
98-
&credentials.EnvProvider{},
99-
&credentials.SharedCredentialsProvider{Filename: "", Profile: req.DataSource.Database},
100-
&ec2rolecreds.EC2RoleProvider{Client: ec2metadata.New(sess), ExpiryWindow: 5 * time.Minute},
101-
})
102-
103106
cfg := &aws.Config{
104107
Region: aws.String(req.Region),
105-
Credentials: creds,
108+
Credentials: getCredentials(req.DataSource.Database),
106109
}
107110

108111
svc := cloudwatch.New(session.New(cfg), cfg)
@@ -140,17 +143,9 @@ func handleListMetrics(req *cwRequest, c *middleware.Context) {
140143
}
141144

142145
func handleDescribeAlarmsForMetric(req *cwRequest, c *middleware.Context) {
143-
sess := session.New()
144-
creds := credentials.NewChainCredentials(
145-
[]credentials.Provider{
146-
&credentials.EnvProvider{},
147-
&credentials.SharedCredentialsProvider{Filename: "", Profile: req.DataSource.Database},
148-
&ec2rolecreds.EC2RoleProvider{Client: ec2metadata.New(sess), ExpiryWindow: 5 * time.Minute},
149-
})
150-
151146
cfg := &aws.Config{
152147
Region: aws.String(req.Region),
153-
Credentials: creds,
148+
Credentials: getCredentials(req.DataSource.Database),
154149
}
155150

156151
svc := cloudwatch.New(session.New(cfg), cfg)
@@ -188,17 +183,9 @@ func handleDescribeAlarmsForMetric(req *cwRequest, c *middleware.Context) {
188183
}
189184

190185
func handleDescribeAlarmHistory(req *cwRequest, c *middleware.Context) {
191-
sess := session.New()
192-
creds := credentials.NewChainCredentials(
193-
[]credentials.Provider{
194-
&credentials.EnvProvider{},
195-
&credentials.SharedCredentialsProvider{Filename: "", Profile: req.DataSource.Database},
196-
&ec2rolecreds.EC2RoleProvider{Client: ec2metadata.New(sess), ExpiryWindow: 5 * time.Minute},
197-
})
198-
199186
cfg := &aws.Config{
200187
Region: aws.String(req.Region),
201-
Credentials: creds,
188+
Credentials: getCredentials(req.DataSource.Database),
202189
}
203190

204191
svc := cloudwatch.New(session.New(cfg), cfg)
@@ -232,17 +219,9 @@ func handleDescribeAlarmHistory(req *cwRequest, c *middleware.Context) {
232219
}
233220

234221
func handleDescribeInstances(req *cwRequest, c *middleware.Context) {
235-
sess := session.New()
236-
creds := credentials.NewChainCredentials(
237-
[]credentials.Provider{
238-
&credentials.EnvProvider{},
239-
&credentials.SharedCredentialsProvider{Filename: "", Profile: req.DataSource.Database},
240-
&ec2rolecreds.EC2RoleProvider{Client: ec2metadata.New(sess), ExpiryWindow: 5 * time.Minute},
241-
})
242-
243222
cfg := &aws.Config{
244223
Region: aws.String(req.Region),
245-
Credentials: creds,
224+
Credentials: getCredentials(req.DataSource.Database),
246225
}
247226

248227
svc := ec2.New(session.New(cfg), cfg)

public/app/features/annotations/partials/editor.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
<table class="grafana-options-table">
4545
<tr ng-repeat="annotation in annotations">
4646
<td style="width:90%">
47-
<i class="fa fa-bolt"></i> &nbsp;
47+
<i class="fa fa-bolt" style="color:{{annotation.iconColor}}"></i> &nbsp;
4848
{{annotation.name}}
4949
</td>
5050
<td style="width: 1%"><i ng-click="_.move(annotations,$index,$index-1)" ng-hide="$first" class="pointer fa fa-arrow-up"></i></td>

public/app/partials/submenu.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<ul class="tight-form-list" ng-if="dashboard.annotations.list.length > 0">
1414
<li ng-repeat="annotation in dashboard.annotations.list" class="submenu-item annotation-segment" ng-class="{'annotation-disabled': !annotation.enable}">
1515
<a ng-click="disableAnnotation(annotation)">
16-
<i class="fa fa-bolt"></i>
16+
<i class="fa fa-bolt" style="color:{{annotation.iconColor}}"></i>
1717
{{annotation.name}}
1818
<input class="cr1" id="hideYAxis" type="checkbox" ng-model="annotation.enable" ng-checked="annotation.enable">
1919
<label for="hideYAxis" class="cr1"></label>

0 commit comments

Comments
 (0)