Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
21fcb2c6
Commit
21fcb2c6
authored
Sep 20, 2016
by
bergquist
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'mtanda-cloudwatch_expand_template'
parents
87be56a4
46866add
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
66 additions
and
1 deletions
+66
-1
CHANGELOG.md
+1
-0
docs/sources/installation/configuration.md
+1
-1
public/app/plugins/datasource/cloudwatch/datasource.js
+32
-0
public/app/plugins/datasource/cloudwatch/specs/datasource_specs.ts
+32
-0
No files found.
CHANGELOG.md
View file @
21fcb2c6
...
...
@@ -12,6 +12,7 @@
*
**Graphite**
: Add support for groupByNode, closes
[
#5613
](
https://github.com/grafana/grafana/pull/5613
)
*
**Influxdb**
: Add support for elapsed(), closes
[
#5827
](
https://github.com/grafana/grafana/pull/5827
)
*
**OAuth**
: Add support for generic oauth, closes
[
#4718
](
https://github.com/grafana/grafana/pull/4718
)
*
**Cloudwatch**
: Add support to expand multi select template variable, closes
[
#5003
](
https://github.com/grafana/grafana/pull/5003
)
### Breaking changes
*
**SystemD**
: Change systemd description, closes
[
#5971
](
https://github.com/grafana/grafana/pull/5971
)
...
...
docs/sources/installation/configuration.md
View file @
21fcb2c6
...
...
@@ -428,7 +428,7 @@ session provider you have configured.
-
**mysql:**
go-sql-driver/mysql dsn config string, e.g.
`user:password@tcp(127.0.0.1:3306)/database_name`
-
**postgres:**
ex: user=a password=b host=localhost port=5432 dbname=c sslmode=disable
-
**memcache:**
ex: 127.0.0.1:11211
-
**redis:**
ex:
`addr=127.0.0.1:6379,pool_size=100,
db
=grafana`
-
**redis:**
ex:
`addr=127.0.0.1:6379,pool_size=100,
prefix
=grafana`
If you use MySQL or Postgres as the session store you need to create the
session table manually.
...
...
public/app/plugins/datasource/cloudwatch/datasource.js
View file @
21fcb2c6
...
...
@@ -23,6 +23,7 @@ function (angular, _, moment, dateMath, CloudWatchAnnotationQuery) {
var
queries
=
[];
options
=
angular
.
copy
(
options
);
options
.
targets
=
this
.
expandTemplateVariable
(
options
.
targets
,
templateSrv
);
_
.
each
(
options
.
targets
,
function
(
target
)
{
if
(
target
.
hide
||
!
target
.
namespace
||
!
target
.
metricName
||
_
.
isEmpty
(
target
.
statistics
))
{
return
;
...
...
@@ -337,6 +338,37 @@ function (angular, _, moment, dateMath, CloudWatchAnnotationQuery) {
});
}
this
.
getExpandedVariables
=
function
(
target
,
dimensionKey
,
variable
)
{
return
_
.
chain
(
variable
.
options
)
.
filter
(
function
(
v
)
{
return
v
.
selected
;
})
.
map
(
function
(
v
)
{
var
t
=
angular
.
copy
(
target
);
t
.
dimensions
[
dimensionKey
]
=
v
.
value
;
return
t
;
}).
value
();
};
this
.
expandTemplateVariable
=
function
(
targets
,
templateSrv
)
{
var
self
=
this
;
return
_
.
chain
(
targets
)
.
map
(
function
(
target
)
{
var
dimensionKey
=
_
.
findKey
(
target
.
dimensions
,
function
(
v
)
{
return
templateSrv
.
variableExists
(
v
);
});
if
(
dimensionKey
)
{
var
variable
=
_
.
find
(
templateSrv
.
variables
,
function
(
variable
)
{
return
templateSrv
.
containsVariable
(
target
.
dimensions
[
dimensionKey
],
variable
.
name
);
});
return
self
.
getExpandedVariables
(
target
,
dimensionKey
,
variable
);
}
else
{
return
[
target
];
}
}).
flatten
().
value
();
};
this
.
convertToCloudWatchTime
=
function
(
date
,
roundUp
)
{
if
(
_
.
isString
(
date
))
{
date
=
dateMath
.
parse
(
date
,
roundUp
);
...
...
public/app/plugins/datasource/cloudwatch/specs/datasource_specs.ts
View file @
21fcb2c6
...
...
@@ -98,6 +98,38 @@ describe('CloudWatchDatasource', function() {
});
ctx
.
$rootScope
.
$apply
();
});
it
(
'should generate the correct targets by expanding template variables'
,
function
()
{
var
templateSrv
=
{
variables
:
[
{
name
:
'instance_id'
,
options
:
[
{
value
:
'i-23456789'
,
selected
:
false
},
{
value
:
'i-34567890'
,
selected
:
true
}
]
}
],
variableExists
:
function
(
e
)
{
return
true
;
},
containsVariable
:
function
(
str
,
variableName
)
{
return
str
.
indexOf
(
'$'
+
variableName
)
!==
-
1
;
}
};
var
targets
=
[
{
region
:
'us-east-1'
,
namespace
:
'AWS/EC2'
,
metricName
:
'CPUUtilization'
,
dimensions
:
{
InstanceId
:
'$instance_id'
},
statistics
:
[
'Average'
],
period
:
300
}
];
var
result
=
ctx
.
ds
.
expandTemplateVariable
(
targets
,
templateSrv
);
expect
(
result
[
0
].
dimensions
.
InstanceId
).
to
.
be
(
'i-34567890'
);
});
});
function
describeMetricFindQuery
(
query
,
func
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment