Add datasource option to more elements
This change adds support for datasource option to: * graph panel * singlestat panel * templating This enables the user to use other datasource than the default datasource for graph/singlestat panels and templating. It is useful when more than one datasource are available in Grafana. Change-Id: I2e81a2dc4658c530bf82c4b349e2991dad348b01
This commit is contained in:
parent
3b01b4df7d
commit
f89102bbf9
@ -115,6 +115,7 @@ class Graph(Base):
|
||||
|
||||
graph = {
|
||||
v.Required('bars', default=False): v.All(bool),
|
||||
v.Optional('datasource'): v.All(str),
|
||||
v.Required('fill', default=1): v.All(int),
|
||||
v.Optional('hideTimeOverride'): v.All(bool),
|
||||
v.Optional('leftYAxisLabel'): v.All(str, v.Length(min=1)),
|
||||
|
@ -62,6 +62,7 @@ class Singlestat(Base):
|
||||
v.Match(r'^[1-9]?[0]{1}%$|^1[0-9]?[0]{1}%$|^200%$')),
|
||||
v.Required('valueName', default='avg'): v.Any(
|
||||
'avg', 'current', 'max', 'min', 'total'),
|
||||
v.Optional('datasource'): v.All(str),
|
||||
v.Optional('decimals'): v.All(int, v.Range(min=0, max=12)),
|
||||
v.Optional('hideTimeOverride'): v.All(bool),
|
||||
v.Optional('timeFrom'): v.All(v.Match(r'[1-9]+[0-9]*[smhdw]')),
|
||||
|
@ -25,6 +25,7 @@ class Query(Base):
|
||||
v.Required('multi', default=False): v.All(bool),
|
||||
v.Required('query', default=''): v.All(str),
|
||||
v.Required('refresh', default=False): v.All(bool),
|
||||
v.Optional('datasource'): v.All(str),
|
||||
}
|
||||
query.update(self.base)
|
||||
return v.Schema(query)
|
||||
|
43
tests/schema/fixtures/dashboard-0019.json
Normal file
43
tests/schema/fixtures/dashboard-0019.json
Normal file
@ -0,0 +1,43 @@
|
||||
{
|
||||
"dashboard": {
|
||||
"new-dashboard": {
|
||||
"rows": [
|
||||
{
|
||||
"collapse": false,
|
||||
"editable": true,
|
||||
"height": "250px",
|
||||
"panels": [
|
||||
{
|
||||
"bars": false,
|
||||
"datasource": "graphite",
|
||||
"editable": true,
|
||||
"error": false,
|
||||
"fill": 1,
|
||||
"lines": true,
|
||||
"linewidth": 2,
|
||||
"percentage": false,
|
||||
"pointradius": 5,
|
||||
"points": false,
|
||||
"span": 12,
|
||||
"stack": false,
|
||||
"steppedLine": false,
|
||||
"targets": [],
|
||||
"title": "no title (click here)",
|
||||
"type": "graph",
|
||||
"x-axis": true,
|
||||
"y-axis": true
|
||||
}
|
||||
],
|
||||
"showTitle": false,
|
||||
"title": "New row"
|
||||
}
|
||||
],
|
||||
"templating": {
|
||||
"enabled": false,
|
||||
"list": []
|
||||
},
|
||||
"timezone": "utc",
|
||||
"title": "New dashboard"
|
||||
}
|
||||
}
|
||||
}
|
9
tests/schema/fixtures/dashboard-0019.yaml
Normal file
9
tests/schema/fixtures/dashboard-0019.yaml
Normal file
@ -0,0 +1,9 @@
|
||||
dashboard:
|
||||
title: New dashboard
|
||||
rows:
|
||||
- title: New row
|
||||
height: 250px
|
||||
panels:
|
||||
- title: no title (click here)
|
||||
type: graph
|
||||
datasource: graphite
|
48
tests/schema/fixtures/dashboard-0020.json
Normal file
48
tests/schema/fixtures/dashboard-0020.json
Normal file
@ -0,0 +1,48 @@
|
||||
{
|
||||
"dashboard": {
|
||||
"new-dashboard": {
|
||||
"rows": [
|
||||
{
|
||||
"collapse": false,
|
||||
"editable": true,
|
||||
"height": "250px",
|
||||
"panels": [
|
||||
{
|
||||
"colorBackground": false,
|
||||
"colorValue": false,
|
||||
"datasource": "graphite",
|
||||
"editable": true,
|
||||
"error": false,
|
||||
"maxDataPoints": 100,
|
||||
"postfix": "",
|
||||
"postfixFontSize": "50%",
|
||||
"prefix": "",
|
||||
"prefixFontSize": "50%",
|
||||
"span": 12,
|
||||
"sparkline": {
|
||||
"fillColor": "rgba(31, 118, 189, 0.18)",
|
||||
"full": false,
|
||||
"lineColor": "rgb(31, 120, 193)",
|
||||
"show": false
|
||||
},
|
||||
"targets": [],
|
||||
"thresholds": "",
|
||||
"title": "no title (click here)",
|
||||
"type": "singlestat",
|
||||
"valueFontSize": "80%",
|
||||
"valueName": "avg"
|
||||
}
|
||||
],
|
||||
"showTitle": false,
|
||||
"title": "New row"
|
||||
}
|
||||
],
|
||||
"templating": {
|
||||
"enabled": false,
|
||||
"list": []
|
||||
},
|
||||
"timezone": "utc",
|
||||
"title": "New dashboard"
|
||||
}
|
||||
}
|
||||
}
|
9
tests/schema/fixtures/dashboard-0020.yaml
Normal file
9
tests/schema/fixtures/dashboard-0020.yaml
Normal file
@ -0,0 +1,9 @@
|
||||
dashboard:
|
||||
title: New dashboard
|
||||
rows:
|
||||
- title: New row
|
||||
height: 250px
|
||||
panels:
|
||||
- title: no title (click here)
|
||||
type: singlestat
|
||||
datasource: graphite
|
57
tests/schema/fixtures/dashboard-0021.json
Normal file
57
tests/schema/fixtures/dashboard-0021.json
Normal file
@ -0,0 +1,57 @@
|
||||
{
|
||||
"dashboard": {
|
||||
"new-dashboard": {
|
||||
"rows": [
|
||||
{
|
||||
"collapse": false,
|
||||
"editable": true,
|
||||
"height": "250px",
|
||||
"panels": [
|
||||
{
|
||||
"bars": false,
|
||||
"datasource": "graphite",
|
||||
"editable": true,
|
||||
"error": false,
|
||||
"fill": 1,
|
||||
"lines": true,
|
||||
"linewidth": 2,
|
||||
"percentage": false,
|
||||
"pointradius": 5,
|
||||
"points": false,
|
||||
"span": 12,
|
||||
"stack": false,
|
||||
"steppedLine": false,
|
||||
"targets": [
|
||||
{
|
||||
"target": "$hostname.Cpu.cpu_prct_used"
|
||||
}
|
||||
],
|
||||
"title": "no title (click here)",
|
||||
"type": "graph",
|
||||
"x-axis": true,
|
||||
"y-axis": true
|
||||
}
|
||||
],
|
||||
"showTitle": false,
|
||||
"title": "New row"
|
||||
}
|
||||
],
|
||||
"templating": {
|
||||
"enabled": true,
|
||||
"list": [
|
||||
{
|
||||
"datasource": "graphite",
|
||||
"includeAll": false,
|
||||
"multi": false,
|
||||
"name": "hostname",
|
||||
"query": "node*",
|
||||
"refresh": true,
|
||||
"type": "query"
|
||||
}
|
||||
]
|
||||
},
|
||||
"timezone": "utc",
|
||||
"title": "New dashboard"
|
||||
}
|
||||
}
|
||||
}
|
17
tests/schema/fixtures/dashboard-0021.yaml
Normal file
17
tests/schema/fixtures/dashboard-0021.yaml
Normal file
@ -0,0 +1,17 @@
|
||||
dashboard:
|
||||
templating:
|
||||
- name: hostname
|
||||
type: query
|
||||
datasource: graphite
|
||||
query: node*
|
||||
refresh: true
|
||||
title: New dashboard
|
||||
rows:
|
||||
- title: New row
|
||||
height: 250px
|
||||
panels:
|
||||
- title: no title (click here)
|
||||
type: graph
|
||||
datasource: graphite
|
||||
targets:
|
||||
- target: $hostname.Cpu.cpu_prct_used
|
Loading…
Reference in New Issue
Block a user