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
e1e6ba36
Commit
e1e6ba36
authored
Jul 01, 2014
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactoring influxdb datasource, split out response handling
parent
435a50de
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
51 deletions
+9
-51
src/app/services/influxdb/influxdbDatasource.js
+9
-51
No files found.
src/app/services/influxdb/influxdbDatasource.js
View file @
e1e6ba36
define
([
'angular'
,
'underscore'
,
'kbn'
'kbn'
,
'./influxSeries'
],
function
(
angular
,
_
,
kbn
)
{
function
(
angular
,
_
,
kbn
,
InfluxSeries
)
{
'use strict'
;
var
module
=
angular
.
module
(
'kibana.services'
);
...
...
@@ -194,57 +195,14 @@ function (angular, _, kbn) {
return
deferred
.
promise
;
};
function
handleInfluxQueryResponse
(
alias
,
groupByField
,
data
)
{
var
output
=
[];
_
.
each
(
data
,
function
(
series
)
{
var
seriesName
;
var
timeCol
=
series
.
columns
.
indexOf
(
'time'
);
var
valueCol
=
1
;
var
groupByCol
=
-
1
;
if
(
groupByField
)
{
groupByCol
=
series
.
columns
.
indexOf
(
groupByField
);
}
// find value column
_
.
each
(
series
.
columns
,
function
(
column
,
index
)
{
if
(
column
!==
'time'
&&
column
!==
'sequence_number'
&&
column
!==
groupByField
)
{
valueCol
=
index
;
}
});
var
groups
=
{};
if
(
groupByField
)
{
groups
=
_
.
groupBy
(
series
.
points
,
function
(
point
)
{
return
point
[
groupByCol
];
});
}
else
{
groups
[
series
.
columns
[
valueCol
]]
=
series
.
points
;
}
_
.
each
(
groups
,
function
(
groupPoints
,
key
)
{
var
datapoints
=
[];
for
(
var
i
=
0
;
i
<
groupPoints
.
length
;
i
++
)
{
var
metricValue
=
isNaN
(
groupPoints
[
i
][
valueCol
])
?
null
:
groupPoints
[
i
][
valueCol
];
datapoints
[
i
]
=
[
metricValue
,
groupPoints
[
i
][
timeCol
]];
}
seriesName
=
alias
?
alias
:
(
series
.
name
+
'.'
+
key
);
// if mulitple groups append key to alias
if
(
alias
&&
groupByField
)
{
seriesName
+=
key
;
}
output
.
push
({
target
:
seriesName
,
datapoints
:
datapoints
});
});
function
handleInfluxQueryResponse
(
alias
,
groupByField
,
seriesList
)
{
var
influxSeries
=
new
InfluxSeries
({
seriesList
:
seriesList
,
alias
:
alias
,
groupByField
:
groupByField
});
return
output
;
return
influxSeries
.
getTimeSeries
()
;
}
function
getTimeFilter
(
options
)
{
...
...
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