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
feed90c0
Commit
feed90c0
authored
Sep 10, 2017
by
Mitsuhiro Tanda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
re-implement get regions
parent
0c951484
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
39 additions
and
7 deletions
+39
-7
pkg/api/cloudwatch/cloudwatch.go
+0
-4
pkg/tsdb/cloudwatch/cloudwatch.go
+14
-0
pkg/tsdb/cloudwatch/metric_find_query.go
+0
-0
public/app/plugins/datasource/cloudwatch/datasource.js
+25
-3
No files found.
pkg/api/cloudwatch/cloudwatch.go
View file @
feed90c0
...
...
@@ -80,10 +80,6 @@ func init() {
"DescribeAlarmsForMetric"
:
handleDescribeAlarmsForMetric
,
"DescribeAlarmHistory"
:
handleDescribeAlarmHistory
,
"DescribeInstances"
:
handleDescribeInstances
,
"__GetRegions"
:
handleGetRegions
,
"__GetNamespaces"
:
handleGetNamespaces
,
"__GetMetrics"
:
handleGetMetrics
,
"__GetDimensions"
:
handleGetDimensions
,
}
}
...
...
pkg/tsdb/cloudwatch/cloudwatch.go
View file @
feed90c0
...
...
@@ -53,6 +53,20 @@ func init() {
}
func
(
e
*
CloudWatchExecutor
)
Execute
(
ctx
context
.
Context
,
queries
tsdb
.
QuerySlice
,
queryContext
*
tsdb
.
QueryContext
)
*
tsdb
.
BatchResult
{
var
result
*
tsdb
.
BatchResult
queryType
:=
queries
[
0
]
.
Model
.
Get
(
"type"
)
.
MustString
()
switch
queryType
{
case
"timeSeriesQuery"
:
result
=
e
.
executeTimeSeriesQuery
(
ctx
,
queries
,
queryContext
)
break
case
"metricFindQuery"
:
result
=
e
.
executeMetricFindQuery
(
ctx
,
queries
,
queryContext
)
break
}
return
result
}
func
(
e
*
CloudWatchExecutor
)
executeTimeSeriesQuery
(
ctx
context
.
Context
,
queries
tsdb
.
QuerySlice
,
queryContext
*
tsdb
.
QueryContext
)
*
tsdb
.
BatchResult
{
result
:=
&
tsdb
.
BatchResult
{
QueryResults
:
make
(
map
[
string
]
*
tsdb
.
QueryResult
),
}
...
...
pkg/tsdb/cloudwatch/metric_find_query.go
View file @
feed90c0
This diff is collapsed.
Click to expand it.
public/app/plugins/datasource/cloudwatch/datasource.js
View file @
feed90c0
...
...
@@ -11,7 +11,7 @@ function (angular, _, moment, dateMath, kbn, templatingVariable, CloudWatchAnnot
'use strict'
;
/** @ngInject */
function
CloudWatchDatasource
(
instanceSettings
,
$q
,
backendSrv
,
templateSrv
)
{
function
CloudWatchDatasource
(
instanceSettings
,
$q
,
backendSrv
,
templateSrv
,
timeSrv
)
{
this
.
type
=
'cloudwatch'
;
this
.
name
=
instanceSettings
.
name
;
this
.
supportMetrics
=
true
;
...
...
@@ -133,7 +133,21 @@ function (angular, _, moment, dateMath, kbn, templatingVariable, CloudWatchAnnot
};
this
.
getRegions
=
function
()
{
return
this
.
awsRequest
({
action
:
'__GetRegions'
});
var
range
=
timeSrv
.
timeRange
();
return
backendSrv
.
post
(
'/api/tsdb/query'
,
{
from
:
range
.
from
,
to
:
range
.
to
,
queries
:
[
{
refId
:
'metricFindQuery'
,
intervalMs
:
1
,
// dummy
maxDataPoints
:
1
,
// dummy
datasourceId
:
this
.
instanceSettings
.
id
,
type
:
'metricFindQuery'
,
subtype
:
'regions'
}
]
});
};
this
.
getNamespaces
=
function
()
{
...
...
@@ -200,6 +214,14 @@ function (angular, _, moment, dateMath, kbn, templatingVariable, CloudWatchAnnot
var
namespace
;
var
metricName
;
var
transformSuggestDataFromTable
=
function
(
suggestData
)
{
return
_
.
map
(
suggestData
.
results
[
'metricFindQuery'
].
tables
[
0
].
rows
,
function
(
v
)
{
return
{
text
:
v
[
0
],
value
:
v
[
1
]
};
});
};
var
transformSuggestData
=
function
(
suggestData
)
{
return
_
.
map
(
suggestData
,
function
(
v
)
{
return
{
text
:
v
};
...
...
@@ -208,7 +230,7 @@ function (angular, _, moment, dateMath, kbn, templatingVariable, CloudWatchAnnot
var
regionQuery
=
query
.
match
(
/^regions
\(\)
/
);
if
(
regionQuery
)
{
return
this
.
getRegions
();
return
this
.
getRegions
()
.
then
(
function
(
r
)
{
return
transformSuggestDataFromTable
(
r
);
})
;
}
var
namespaceQuery
=
query
.
match
(
/^namespaces
\(\)
/
);
...
...
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