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
defb15be
Commit
defb15be
authored
Jan 04, 2016
by
Mitsuhiro Tanda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
CloudWatch multiple alarm annotation support
parent
10016d9d
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
58 additions
and
4 deletions
+58
-4
public/app/plugins/datasource/cloudwatch/datasource.js
+40
-4
public/app/plugins/datasource/cloudwatch/partials/annotations.editor.html
+18
-0
No files found.
public/app/plugins/datasource/cloudwatch/datasource.js
View file @
defb15be
...
...
@@ -230,21 +230,57 @@ function (angular, _, moment, dateMath) {
this
.
annotationQuery
=
function
(
options
)
{
var
annotation
=
options
.
annotation
;
var
usePrefixMatch
=
annotation
.
prefixMatching
;
var
region
=
templateSrv
.
replace
(
annotation
.
region
);
var
namespace
=
templateSrv
.
replace
(
annotation
.
namespace
);
var
metricName
=
templateSrv
.
replace
(
annotation
.
metricName
);
var
dimensions
=
convertDimensionFormat
(
annotation
.
dimensions
);
var
statistics
=
_
.
map
(
annotation
.
statistics
,
function
(
s
)
{
return
templateSrv
.
replace
(
s
);
});
var
period
=
annotation
.
period
||
'300'
;
var
defaultPeriod
=
usePrefixMatch
?
''
:
'300'
;
var
period
=
annotation
.
period
||
defaultPeriod
;
period
=
parseInt
(
period
,
10
);
if
(
!
region
||
!
namespace
||
!
metricName
||
_
.
isEmpty
(
statistics
))
{
return
$q
.
when
([]);
}
var
actionPrefix
=
annotation
.
actionPrefix
||
''
;
var
alarmNamePrefix
=
annotation
.
alarmNamePrefix
||
''
;
var
d
=
$q
.
defer
();
var
self
=
this
;
var
allQueryPromise
=
_
.
map
(
statistics
,
function
(
statistic
)
{
var
allQueryPromise
;
if
(
usePrefixMatch
)
{
allQueryPromise
=
[
this
.
performDescribeAlarms
(
region
,
actionPrefix
,
alarmNamePrefix
,
[],
''
).
then
(
function
(
alarms
)
{
alarms
.
MetricAlarms
=
_
.
filter
(
alarms
.
MetricAlarms
,
function
(
alarm
)
{
if
(
!
_
.
isEmpty
(
namespace
)
&&
alarm
.
Namespace
!==
namespace
)
{
return
false
;
}
if
(
!
_
.
isEmpty
(
metricName
)
&&
alarm
.
MetricName
!==
metricName
)
{
return
false
;
}
var
sd
=
function
(
d
)
{
return
d
.
Name
;
};
var
isSameDimensions
=
JSON
.
stringify
(
_
.
sortBy
(
alarm
.
Dimensions
,
sd
))
===
JSON
.
stringify
(
_
.
sortBy
(
dimensions
,
sd
));
if
(
!
_
.
isEmpty
(
dimensions
)
&&
!
isSameDimensions
)
{
return
false
;
}
if
(
!
_
.
isEmpty
(
statistics
)
&&
!
_
.
contains
(
statistics
,
alarm
.
Statistic
))
{
return
false
;
}
if
(
!
_
.
isNaN
(
period
)
&&
alarm
.
Period
!==
period
)
{
return
false
;
}
return
true
;
});
return
alarms
;
})
];
}
else
{
if
(
!
region
||
!
namespace
||
!
metricName
||
_
.
isEmpty
(
statistics
))
{
return
$q
.
when
([]);
}
allQueryPromise
=
_
.
map
(
statistics
,
function
(
statistic
)
{
return
self
.
performDescribeAlarmsForMetric
(
region
,
namespace
,
metricName
,
dimensions
,
statistic
,
period
);
});
}
$q
.
all
(
allQueryPromise
).
then
(
function
(
alarms
)
{
var
eventList
=
[];
...
...
public/app/plugins/datasource/cloudwatch/partials/annotations.editor.html
View file @
defb15be
<cloudwatch-query-parameter
target=
"ctrl.annotation"
datasource=
"ctrl.datasource"
></cloudwatch-query-parameter>
<div
class=
"editor-row"
>
<div
class=
"section"
>
<h5>
Prefix matching
</h5>
<div
class=
"editor-option"
>
<editor-checkbox
text=
"Enable"
model=
"ctrl.annotation.prefixMatching"
></editor-checkbox>
</div>
<div
class=
"editor-option"
ng-if=
"ctrl.annotation.prefixMatching"
>
<label
class=
"small"
>
Action
</label>
<input
type=
"text"
class=
"input-small"
ng-model=
'ctrl.annotation.actionPrefix'
></input>
</div>
<div
class=
"editor-option"
ng-if=
"ctrl.annotation.prefixMatching"
>
<label
class=
"small"
>
Alarm Name
</label>
<input
type=
"text"
class=
"input-small"
ng-model=
'ctrl.annotation.alarmNamePrefix'
></input>
</div>
</div>
</div>
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