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
fd96e30c
Commit
fd96e30c
authored
Aug 10, 2015
by
Mitsuhiro Tanda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add region field in query editor
parent
6a697eed
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
57 additions
and
10 deletions
+57
-10
public/app/plugins/datasource/cloudwatch/datasource.js
+24
-7
public/app/plugins/datasource/cloudwatch/partials/config.html
+2
-2
public/app/plugins/datasource/cloudwatch/partials/query.editor.html
+14
-0
public/app/plugins/datasource/cloudwatch/queryCtrl.js
+17
-1
No files found.
public/app/plugins/datasource/cloudwatch/datasource.js
View file @
fd96e30c
...
@@ -19,11 +19,11 @@ function (angular, _, kbn) {
...
@@ -19,11 +19,11 @@ function (angular, _, kbn) {
this
.
name
=
datasource
.
name
;
this
.
name
=
datasource
.
name
;
this
.
supportMetrics
=
true
;
this
.
supportMetrics
=
true
;
AWS
.
config
.
update
({
region
:
datasource
.
jsonData
.
region
})
;
this
.
defaultRegion
=
datasource
.
jsonData
.
defaultRegion
;
this
.
c
loudwatch
=
new
AWS
.
CloudWatch
(
{
this
.
c
redentials
=
{
accessKeyId
:
datasource
.
jsonData
.
accessKeyId
,
accessKeyId
:
datasource
.
jsonData
.
accessKeyId
,
secretAccessKey
:
datasource
.
jsonData
.
secretAccessKey
,
secretAccessKey
:
datasource
.
jsonData
.
secretAccessKey
}
)
;
};
}
}
// Called once per panel (graph)
// Called once per panel (graph)
...
@@ -38,6 +38,7 @@ function (angular, _, kbn) {
...
@@ -38,6 +38,7 @@ function (angular, _, kbn) {
}
}
var
query
=
{};
var
query
=
{};
query
.
region
=
templateSrv
.
replace
(
target
.
region
,
options
.
scopedVars
);
query
.
namespace
=
templateSrv
.
replace
(
target
.
namespace
,
options
.
scopedVars
);
query
.
namespace
=
templateSrv
.
replace
(
target
.
namespace
,
options
.
scopedVars
);
query
.
metricName
=
templateSrv
.
replace
(
target
.
metricName
,
options
.
scopedVars
);
query
.
metricName
=
templateSrv
.
replace
(
target
.
metricName
,
options
.
scopedVars
);
query
.
dimensions
=
_
.
map
(
_
.
keys
(
target
.
dimensions
),
function
(
key
)
{
query
.
dimensions
=
_
.
map
(
_
.
keys
(
target
.
dimensions
),
function
(
key
)
{
...
@@ -85,6 +86,8 @@ function (angular, _, kbn) {
...
@@ -85,6 +86,8 @@ function (angular, _, kbn) {
};
};
CloudWatchDatasource
.
prototype
.
performTimeSeriesQuery
=
function
(
query
,
start
,
end
)
{
CloudWatchDatasource
.
prototype
.
performTimeSeriesQuery
=
function
(
query
,
start
,
end
)
{
var
cloudwatch
=
this
.
getCloudWatchClient
(
query
.
region
);
var
params
=
{
var
params
=
{
Namespace
:
query
.
namespace
,
Namespace
:
query
.
namespace
,
MetricName
:
query
.
metricName
,
MetricName
:
query
.
metricName
,
...
@@ -96,7 +99,7 @@ function (angular, _, kbn) {
...
@@ -96,7 +99,7 @@ function (angular, _, kbn) {
};
};
var
d
=
$q
.
defer
();
var
d
=
$q
.
defer
();
this
.
cloudwatch
.
getMetricStatistics
(
params
,
function
(
err
,
data
)
{
cloudwatch
.
getMetricStatistics
(
params
,
function
(
err
,
data
)
{
if
(
err
)
{
if
(
err
)
{
return
d
.
reject
(
err
);
return
d
.
reject
(
err
);
}
}
...
@@ -106,10 +109,12 @@ function (angular, _, kbn) {
...
@@ -106,10 +109,12 @@ function (angular, _, kbn) {
return
d
.
promise
;
return
d
.
promise
;
};
};
CloudWatchDatasource
.
prototype
.
performSuggestQuery
=
function
(
params
)
{
CloudWatchDatasource
.
prototype
.
performSuggestQuery
=
function
(
region
,
params
)
{
var
cloudwatch
=
this
.
getCloudWatchClient
(
region
);
var
d
=
$q
.
defer
();
var
d
=
$q
.
defer
();
this
.
cloudwatch
.
listMetrics
(
params
,
function
(
err
,
data
)
{
cloudwatch
.
listMetrics
(
params
,
function
(
err
,
data
)
{
if
(
err
)
{
if
(
err
)
{
return
d
.
reject
(
err
);
return
d
.
reject
(
err
);
}
}
...
@@ -126,6 +131,18 @@ function (angular, _, kbn) {
...
@@ -126,6 +131,18 @@ function (angular, _, kbn) {
});
});
};
};
CloudWatchDatasource
.
prototype
.
getCloudWatchClient
=
function
(
region
)
{
return
new
AWS
.
CloudWatch
({
region
:
region
,
accessKeyId
:
this
.
credentials
.
accessKeyId
,
secretAccessKey
:
this
.
credentials
.
secretAccessKey
});
};
CloudWatchDatasource
.
prototype
.
getDefaultRegion
=
function
()
{
return
this
.
defaultRegion
;
};
function
transformMetricData
(
md
,
options
)
{
function
transformMetricData
(
md
,
options
)
{
var
result
=
[];
var
result
=
[];
...
...
public/app/plugins/datasource/cloudwatch/partials/config.html
View file @
fd96e30c
...
@@ -3,10 +3,10 @@
...
@@ -3,10 +3,10 @@
<div
class=
"tight-form"
>
<div
class=
"tight-form"
>
<ul
class=
"tight-form-list"
>
<ul
class=
"tight-form-list"
>
<li
class=
"tight-form-item"
style=
"width: 80px"
>
<li
class=
"tight-form-item"
style=
"width: 80px"
>
Region
Default
Region
</li>
</li>
<li>
<li>
<input
type=
"text"
class=
"tight-form-input input-large"
ng-model=
'current.jsonData.
r
egion'
placeholder=
""
required
></input>
<input
type=
"text"
class=
"tight-form-input input-large"
ng-model=
'current.jsonData.
defaultR
egion'
placeholder=
""
required
></input>
</li>
</li>
</ul>
</ul>
<div
class=
"clearfix"
></div>
<div
class=
"clearfix"
></div>
...
...
public/app/plugins/datasource/cloudwatch/partials/query.editor.html
View file @
fd96e30c
...
@@ -203,6 +203,20 @@
...
@@ -203,6 +203,20 @@
<i
class=
"fa fa-warning"
></i>
<i
class=
"fa fa-warning"
></i>
</a>
</a>
</li>
</li>
<li
class=
"tight-form-item"
>
Region
</li>
<li>
<input
type=
"text"
class=
"input-medium tight-form-input"
ng-model=
"target.region"
spellcheck=
'false'
bs-typeahead=
"suggestRegion"
placeholder=
"region"
data-min-length=
0
data-items=
100
ng-change=
"refreshMetricData()"
>
</li>
</ul>
</ul>
<div
class=
"clearfix"
></div>
<div
class=
"clearfix"
></div>
...
...
public/app/plugins/datasource/cloudwatch/queryCtrl.js
View file @
fd96e30c
...
@@ -8,6 +8,17 @@ function (angular, _) {
...
@@ -8,6 +8,17 @@ function (angular, _) {
var
module
=
angular
.
module
(
'grafana.controllers'
);
var
module
=
angular
.
module
(
'grafana.controllers'
);
/* jshint -W101 */
/* jshint -W101 */
var
supportedRegion
=
[
'us-east-1'
,
'us-west-2'
,
'us-west-1'
,
'eu-west-1'
,
'eu-central-1'
,
'ap-southeast-1'
,
'ap-southeast-2'
,
'ap-northeast-1'
,
'sa-east-1'
,
];
var
supportedMetrics
=
{
var
supportedMetrics
=
{
"AWS/AutoScaling"
:
[
"AWS/AutoScaling"
:
[
"GroupMinSize"
,
"GroupMaxSize"
,
"GroupDesiredCapacity"
,
"GroupInServiceInstances"
,
"GroupPendingInstances"
,
"GroupStandbyInstances"
,
"GroupTerminatingInstances"
,
"GroupTotalInstances"
"GroupMinSize"
,
"GroupMaxSize"
,
"GroupDesiredCapacity"
,
"GroupInServiceInstances"
,
"GroupPendingInstances"
,
"GroupStandbyInstances"
,
"GroupTerminatingInstances"
,
"GroupTotalInstances"
...
@@ -157,6 +168,7 @@ function (angular, _) {
...
@@ -157,6 +168,7 @@ function (angular, _) {
$scope
.
target
.
dimensions
=
$scope
.
target
.
dimensions
||
{};
$scope
.
target
.
dimensions
=
$scope
.
target
.
dimensions
||
{};
$scope
.
target
.
statistics
=
$scope
.
target
.
statistics
||
{};
$scope
.
target
.
statistics
=
$scope
.
target
.
statistics
||
{};
$scope
.
target
.
period
=
$scope
.
target
.
period
||
60
;
$scope
.
target
.
period
=
$scope
.
target
.
period
||
60
;
$scope
.
target
.
region
=
$scope
.
target
.
region
||
$scope
.
datasource
.
getDefaultRegion
();
$scope
.
target
.
errors
=
validateTarget
();
$scope
.
target
.
errors
=
validateTarget
();
};
};
...
@@ -180,6 +192,10 @@ function (angular, _) {
...
@@ -180,6 +192,10 @@ function (angular, _) {
$scope
.
panel
.
targets
.
push
(
clone
);
$scope
.
panel
.
targets
.
push
(
clone
);
};
};
$scope
.
suggestRegion
=
function
(
query
,
callback
)
{
// jshint unused:false
return
supportedRegion
;
};
$scope
.
suggestNamespace
=
function
(
query
,
callback
)
{
// jshint unused:false
$scope
.
suggestNamespace
=
function
(
query
,
callback
)
{
// jshint unused:false
return
_
.
keys
(
supportedMetrics
);
return
_
.
keys
(
supportedMetrics
);
};
};
...
@@ -206,7 +222,7 @@ function (angular, _) {
...
@@ -206,7 +222,7 @@ function (angular, _) {
}
}
$scope
.
datasource
$scope
.
datasource
.
performSuggestQuery
(
params
)
.
performSuggestQuery
(
$scope
.
target
.
region
,
params
)
.
then
(
function
(
result
)
{
.
then
(
function
(
result
)
{
var
suggestData
=
_
.
chain
(
result
.
Metrics
)
var
suggestData
=
_
.
chain
(
result
.
Metrics
)
.
map
(
function
(
metric
)
{
.
map
(
function
(
metric
)
{
...
...
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