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
15dc30ed
Commit
15dc30ed
authored
Nov 13, 2015
by
Mitsuhiro Tanda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
if there isn't enough datapoint, add null data point
parent
730d4857
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
14 deletions
+23
-14
public/app/plugins/datasource/prometheus/datasource.js
+23
-14
No files found.
public/app/plugins/datasource/prometheus/datasource.js
View file @
15dc30ed
...
@@ -48,6 +48,7 @@ function (angular, _, moment, dateMath) {
...
@@ -48,6 +48,7 @@ function (angular, _, moment, dateMath) {
var
end
=
getPrometheusTime
(
options
.
range
.
to
,
true
);
var
end
=
getPrometheusTime
(
options
.
range
.
to
,
true
);
var
queries
=
[];
var
queries
=
[];
options
=
_
.
clone
(
options
);
_
.
each
(
options
.
targets
,
_
.
bind
(
function
(
target
)
{
_
.
each
(
options
.
targets
,
_
.
bind
(
function
(
target
)
{
if
(
!
target
.
expr
||
target
.
hide
)
{
if
(
!
target
.
expr
||
target
.
hide
)
{
return
;
return
;
...
@@ -58,7 +59,13 @@ function (angular, _, moment, dateMath) {
...
@@ -58,7 +59,13 @@ function (angular, _, moment, dateMath) {
var
interval
=
target
.
interval
||
options
.
interval
;
var
interval
=
target
.
interval
||
options
.
interval
;
var
intervalFactor
=
target
.
intervalFactor
||
1
;
var
intervalFactor
=
target
.
intervalFactor
||
1
;
query
.
step
=
this
.
calculateInterval
(
interval
,
intervalFactor
);
target
.
step
=
query
.
step
=
this
.
calculateInterval
(
interval
,
intervalFactor
);
var
range
=
Math
.
ceil
(
end
-
start
);
// Prometheus drop query if range/step > 11000
// calibrate step if it is too big
if
(
query
.
step
!==
0
&&
range
/
query
.
step
>
11000
)
{
target
.
step
=
query
.
step
=
Math
.
ceil
(
range
/
11000
);
}
queries
.
push
(
query
);
queries
.
push
(
query
);
},
this
));
},
this
));
...
@@ -96,17 +103,7 @@ function (angular, _, moment, dateMath) {
...
@@ -96,17 +103,7 @@ function (angular, _, moment, dateMath) {
};
};
PrometheusDatasource
.
prototype
.
performTimeSeriesQuery
=
function
(
query
,
start
,
end
)
{
PrometheusDatasource
.
prototype
.
performTimeSeriesQuery
=
function
(
query
,
start
,
end
)
{
var
url
=
'/api/v1/query_range?query='
+
encodeURIComponent
(
query
.
expr
)
+
'&start='
+
start
+
'&end='
+
end
;
var
url
=
'/api/v1/query_range?query='
+
encodeURIComponent
(
query
.
expr
)
+
'&start='
+
start
+
'&end='
+
end
+
'&step='
+
query
.
step
;
var
step
=
query
.
step
;
var
range
=
Math
.
ceil
(
end
-
start
);
// Prometheus drop query if range/step > 11000
// calibrate step if it is too big
if
(
step
!==
0
&&
range
/
step
>
11000
)
{
step
=
Math
.
ceil
(
range
/
11000
);
}
url
+=
'&step='
+
step
;
return
this
.
_request
(
'GET'
,
url
);
return
this
.
_request
(
'GET'
,
url
);
};
};
...
@@ -221,8 +218,20 @@ function (angular, _, moment, dateMath) {
...
@@ -221,8 +218,20 @@ function (angular, _, moment, dateMath) {
metricLabel
=
createMetricLabel
(
md
.
metric
,
options
);
metricLabel
=
createMetricLabel
(
md
.
metric
,
options
);
dps
=
_
.
map
(
md
.
values
,
function
(
value
)
{
var
stepMs
=
parseInt
(
options
.
step
.
slice
(
0
,
-
1
))
*
1000
;
return
[
parseFloat
(
value
[
1
]),
value
[
0
]
*
1000
];
var
lastTimestamp
=
null
;
_
.
each
(
md
.
values
,
function
(
value
)
{
var
dp_value
=
parseFloat
(
value
[
1
]);
if
(
_
.
isNaN
(
dp_value
))
{
dp_value
=
null
;
}
var
timestamp
=
value
[
0
]
*
1000
;
if
(
lastTimestamp
&&
(
timestamp
-
lastTimestamp
)
>
stepMs
)
{
dps
.
push
([
null
,
lastTimestamp
+
stepMs
]);
}
lastTimestamp
=
timestamp
;
dps
.
push
([
dp_value
,
timestamp
]);
});
});
return
{
target
:
metricLabel
,
datapoints
:
dps
};
return
{
target
:
metricLabel
,
datapoints
:
dps
};
...
...
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