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
393891d6
Commit
393891d6
authored
Nov 14, 2015
by
Mitsuhiro Tanda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(cloudwatch) fill null if the datapoint missing
parent
305f8d69
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
7 deletions
+33
-7
public/app/plugins/datasource/cloudwatch/datasource.js
+17
-7
public/app/plugins/datasource/cloudwatch/specs/datasource_specs.ts
+16
-0
No files found.
public/app/plugins/datasource/cloudwatch/datasource.js
View file @
393891d6
...
...
@@ -25,6 +25,7 @@ function (angular, _) {
var
end
=
convertToCloudWatchTime
(
options
.
range
.
to
);
var
queries
=
[];
options
=
_
.
clone
(
options
);
_
.
each
(
options
.
targets
,
_
.
bind
(
function
(
target
)
{
if
(
target
.
hide
||
!
target
.
namespace
||
!
target
.
metricName
||
_
.
isEmpty
(
target
.
statistics
))
{
return
;
...
...
@@ -38,11 +39,11 @@ function (angular, _) {
query
.
statistics
=
target
.
statistics
;
var
range
=
end
-
start
;
query
.
period
=
parseInt
(
target
.
period
,
10
)
||
60
;
query
.
period
=
parseInt
(
target
.
period
,
10
)
||
(
query
.
namespace
===
'AWS/EC2'
?
300
:
60
);
if
(
range
/
query
.
period
>=
1440
)
{
query
.
period
=
Math
.
ceil
(
range
/
1440
/
60
)
*
60
;
}
target
.
period
=
query
.
period
;
queries
.
push
(
query
);
},
this
));
...
...
@@ -252,13 +253,22 @@ function (angular, _) {
};
_
.
extend
(
aliasData
,
options
.
dimensions
);
var
periodMs
=
options
.
period
*
1000
;
return
_
.
map
(
options
.
statistics
,
function
(
stat
)
{
var
dps
=
_
.
chain
(
md
.
Datapoints
).
map
(
function
(
dp
)
{
return
[
dp
[
stat
],
new
Date
(
dp
.
Timestamp
).
getTime
()]
;
}
)
var
dps
=
[];
var
lastTimestamp
=
null
;
_
.
chain
(
md
.
Datapoints
)
.
sortBy
(
function
(
dp
)
{
return
dp
[
1
];
}).
value
();
return
dp
.
Timestamp
;
})
.
each
(
function
(
dp
)
{
var
timestamp
=
new
Date
(
dp
.
Timestamp
).
getTime
();
if
(
lastTimestamp
&&
(
timestamp
-
lastTimestamp
)
>
periodMs
*
2
)
{
dps
.
push
([
null
,
lastTimestamp
+
periodMs
]);
}
lastTimestamp
=
timestamp
;
dps
.
push
([
dp
[
stat
],
timestamp
]);
});
aliasData
.
stat
=
stat
;
var
seriesName
=
aliasPattern
.
replace
(
aliasRegex
,
function
(
match
,
g1
)
{
...
...
public/app/plugins/datasource/cloudwatch/specs/datasource_specs.ts
View file @
393891d6
...
...
@@ -48,6 +48,14 @@ describe('CloudWatchDatasource', function() {
{
Average
:
1
,
Timestamp
:
'Wed Dec 31 1969 16:00:00 GMT-0800 (PST)'
},
{
Average
:
2
,
Timestamp
:
'Wed Dec 31 1969 16:05:00 GMT-0800 (PST)'
},
{
Average
:
5
,
Timestamp
:
'Wed Dec 31 1969 16:20:00 GMT-0800 (PST)'
}
],
Label
:
'CPUUtilization'
...
...
@@ -82,6 +90,14 @@ describe('CloudWatchDatasource', function() {
});
ctx
.
$rootScope
.
$apply
();
});
it
(
'should return null for missing data point'
,
function
(
done
)
{
ctx
.
ds
.
query
(
query
).
then
(
function
(
result
)
{
expect
(
result
.
data
[
0
].
datapoints
[
2
][
0
]).
to
.
be
(
null
);
done
();
});
ctx
.
$rootScope
.
$apply
();
});
});
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