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
e1fe15e0
Commit
e1fe15e0
authored
Sep 26, 2017
by
Mitsuhiro Tanda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix annotation query
parent
bf5268c0
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
14 deletions
+22
-14
pkg/tsdb/cloudwatch/annotation_query.go
+19
-13
public/app/plugins/datasource/cloudwatch/datasource.js
+3
-1
No files found.
pkg/tsdb/cloudwatch/annotation_query.go
View file @
e1fe15e0
...
@@ -20,16 +20,16 @@ func (e *CloudWatchExecutor) executeAnnotationQuery(ctx context.Context, queryCo
...
@@ -20,16 +20,16 @@ func (e *CloudWatchExecutor) executeAnnotationQuery(ctx context.Context, queryCo
queryResult
:=
&
tsdb
.
QueryResult
{
Meta
:
simplejson
.
New
(),
RefId
:
firstQuery
.
RefId
}
queryResult
:=
&
tsdb
.
QueryResult
{
Meta
:
simplejson
.
New
(),
RefId
:
firstQuery
.
RefId
}
parameters
:=
firstQuery
.
Model
parameters
:=
firstQuery
.
Model
usePrefixMatch
:=
parameters
.
Get
(
"prefixMatching"
)
.
MustBool
()
usePrefixMatch
:=
parameters
.
Get
(
"prefixMatching"
)
.
MustBool
(
false
)
region
:=
parameters
.
Get
(
"region"
)
.
MustString
(
""
)
region
:=
parameters
.
Get
(
"region"
)
.
MustString
(
""
)
namespace
:=
parameters
.
Get
(
"namespace"
)
.
MustString
(
""
)
namespace
:=
parameters
.
Get
(
"namespace"
)
.
MustString
(
""
)
metricName
:=
parameters
.
Get
(
"metricName"
)
.
MustString
(
""
)
metricName
:=
parameters
.
Get
(
"metricName"
)
.
MustString
(
""
)
dimensions
:=
parameters
.
Get
(
"dimensions"
)
.
MustMap
()
dimensions
:=
parameters
.
Get
(
"dimensions"
)
.
MustMap
()
statistics
:=
parameters
.
Get
(
"statistics"
)
.
MustStringArray
()
statistics
:=
parameters
.
Get
(
"statistics"
)
.
MustStringArray
()
extendedStatistics
:=
parameters
.
Get
(
"extendedStatistics"
)
.
MustStringArray
()
extendedStatistics
:=
parameters
.
Get
(
"extendedStatistics"
)
.
MustStringArray
()
period
:=
int64
(
300
)
period
:=
int64
(
parameters
.
Get
(
"period"
)
.
MustInt
(
0
)
)
if
usePrefixMatch
{
if
period
==
0
&&
!
usePrefixMatch
{
period
=
int64
(
parameters
.
Get
(
"period"
)
.
MustInt
(
0
))
period
=
300
}
}
actionPrefix
:=
parameters
.
Get
(
"actionPrefix"
)
.
MustString
(
""
)
actionPrefix
:=
parameters
.
Get
(
"actionPrefix"
)
.
MustString
(
""
)
alarmNamePrefix
:=
parameters
.
Get
(
"alarmNamePrefix"
)
.
MustString
(
""
)
alarmNamePrefix
:=
parameters
.
Get
(
"alarmNamePrefix"
)
.
MustString
(
""
)
...
@@ -75,9 +75,9 @@ func (e *CloudWatchExecutor) executeAnnotationQuery(ctx context.Context, queryCo
...
@@ -75,9 +75,9 @@ func (e *CloudWatchExecutor) executeAnnotationQuery(ctx context.Context, queryCo
params
:=
&
cloudwatch
.
DescribeAlarmsForMetricInput
{
params
:=
&
cloudwatch
.
DescribeAlarmsForMetricInput
{
Namespace
:
aws
.
String
(
namespace
),
Namespace
:
aws
.
String
(
namespace
),
MetricName
:
aws
.
String
(
metricName
),
MetricName
:
aws
.
String
(
metricName
),
Period
:
aws
.
Int64
(
int64
(
period
)),
Dimensions
:
qd
,
Dimensions
:
qd
,
Statistic
:
aws
.
String
(
s
),
Statistic
:
aws
.
String
(
s
),
Period
:
aws
.
Int64
(
int64
(
period
)),
}
}
resp
,
err
:=
svc
.
DescribeAlarmsForMetric
(
params
)
resp
,
err
:=
svc
.
DescribeAlarmsForMetric
(
params
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -91,9 +91,9 @@ func (e *CloudWatchExecutor) executeAnnotationQuery(ctx context.Context, queryCo
...
@@ -91,9 +91,9 @@ func (e *CloudWatchExecutor) executeAnnotationQuery(ctx context.Context, queryCo
params
:=
&
cloudwatch
.
DescribeAlarmsForMetricInput
{
params
:=
&
cloudwatch
.
DescribeAlarmsForMetricInput
{
Namespace
:
aws
.
String
(
namespace
),
Namespace
:
aws
.
String
(
namespace
),
MetricName
:
aws
.
String
(
metricName
),
MetricName
:
aws
.
String
(
metricName
),
Period
:
aws
.
Int64
(
int64
(
period
)),
Dimensions
:
qd
,
Dimensions
:
qd
,
ExtendedStatistic
:
aws
.
String
(
s
),
ExtendedStatistic
:
aws
.
String
(
s
),
Period
:
aws
.
Int64
(
int64
(
period
)),
}
}
resp
,
err
:=
svc
.
DescribeAlarmsForMetric
(
params
)
resp
,
err
:=
svc
.
DescribeAlarmsForMetric
(
params
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -109,7 +109,6 @@ func (e *CloudWatchExecutor) executeAnnotationQuery(ctx context.Context, queryCo
...
@@ -109,7 +109,6 @@ func (e *CloudWatchExecutor) executeAnnotationQuery(ctx context.Context, queryCo
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
endTime
,
err
:=
queryContext
.
TimeRange
.
ParseTo
()
endTime
,
err
:=
queryContext
.
TimeRange
.
ParseTo
()
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
...
@@ -175,17 +174,20 @@ func filterAlarms(alarms *cloudwatch.DescribeAlarmsOutput, namespace string, met
...
@@ -175,17 +174,20 @@ func filterAlarms(alarms *cloudwatch.DescribeAlarmsOutput, namespace string, met
}
}
match
:=
true
match
:=
true
for
_
,
d
:=
range
alarm
.
Dimensions
{
if
len
(
dimensions
)
==
0
{
if
_
,
ok
:=
dimensions
[
*
d
.
Name
];
!
ok
{
// all match
match
=
false
}
else
if
len
(
alarm
.
Dimensions
)
!=
len
(
dimensions
)
{
match
=
false
}
else
{
for
_
,
d
:=
range
alarm
.
Dimensions
{
if
_
,
ok
:=
dimensions
[
*
d
.
Name
];
!
ok
{
match
=
false
}
}
}
}
}
if
!
match
{
if
!
match
{
continue
continue
}
}
if
period
!=
0
&&
*
alarm
.
Period
!=
period
{
continue
}
if
len
(
statistics
)
!=
0
{
if
len
(
statistics
)
!=
0
{
found
:=
false
found
:=
false
...
@@ -211,6 +213,10 @@ func filterAlarms(alarms *cloudwatch.DescribeAlarmsOutput, namespace string, met
...
@@ -211,6 +213,10 @@ func filterAlarms(alarms *cloudwatch.DescribeAlarmsOutput, namespace string, met
}
}
}
}
if
period
!=
0
&&
*
alarm
.
Period
!=
period
{
continue
}
alarmNames
=
append
(
alarmNames
,
alarm
.
AlarmName
)
alarmNames
=
append
(
alarmNames
,
alarm
.
AlarmName
)
}
}
...
...
public/app/plugins/datasource/cloudwatch/datasource.js
View file @
e1fe15e0
...
@@ -259,6 +259,7 @@ function (angular, _, moment, dateMath, kbn, templatingVariable) {
...
@@ -259,6 +259,7 @@ function (angular, _, moment, dateMath, kbn, templatingVariable) {
this
.
annotationQuery
=
function
(
options
)
{
this
.
annotationQuery
=
function
(
options
)
{
var
annotation
=
options
.
annotation
;
var
annotation
=
options
.
annotation
;
var
statistics
=
_
.
map
(
annotation
.
statistics
,
function
(
s
)
{
return
templateSrv
.
replace
(
s
);
});
var
defaultPeriod
=
annotation
.
prefixMatching
?
''
:
'300'
;
var
defaultPeriod
=
annotation
.
prefixMatching
?
''
:
'300'
;
var
period
=
annotation
.
period
||
defaultPeriod
;
var
period
=
annotation
.
period
||
defaultPeriod
;
period
=
parseInt
(
period
,
10
);
period
=
parseInt
(
period
,
10
);
...
@@ -268,7 +269,8 @@ function (angular, _, moment, dateMath, kbn, templatingVariable) {
...
@@ -268,7 +269,8 @@ function (angular, _, moment, dateMath, kbn, templatingVariable) {
namespace
:
templateSrv
.
replace
(
annotation
.
namespace
),
namespace
:
templateSrv
.
replace
(
annotation
.
namespace
),
metricName
:
templateSrv
.
replace
(
annotation
.
metricName
),
metricName
:
templateSrv
.
replace
(
annotation
.
metricName
),
dimensions
:
this
.
convertDimensionFormat
(
annotation
.
dimensions
,
{}),
dimensions
:
this
.
convertDimensionFormat
(
annotation
.
dimensions
,
{}),
statistics
:
_
.
map
(
annotation
.
statistics
,
function
(
s
)
{
return
templateSrv
.
replace
(
s
);
}),
statistics
:
_
.
filter
(
statistics
,
function
(
s
)
{
return
_
.
includes
(
self
.
standardStatistics
,
s
);
}),
extendedStatistics
:
_
.
filter
(
statistics
,
function
(
s
)
{
return
!
_
.
includes
(
self
.
standardStatistics
,
s
);
}),
period
:
period
,
period
:
period
,
actionPrefix
:
annotation
.
actionPrefix
||
''
,
actionPrefix
:
annotation
.
actionPrefix
||
''
,
alarmNamePrefix
:
annotation
.
alarmNamePrefix
||
''
alarmNamePrefix
:
annotation
.
alarmNamePrefix
||
''
...
...
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