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
4b61c7cd
Commit
4b61c7cd
authored
May 08, 2018
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'influx-db-select-query-variable'
parents
8d132768
b894a5ff
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
5 deletions
+40
-5
public/app/plugins/datasource/influxdb/response_parser.ts
+14
-5
public/app/plugins/datasource/influxdb/specs/response_parser.jest.ts
+26
-0
No files found.
public/app/plugins/datasource/influxdb/response_parser.ts
View file @
4b61c7cd
...
@@ -11,14 +11,23 @@ export default class ResponseParser {
...
@@ -11,14 +11,23 @@ export default class ResponseParser {
return
[];
return
[];
}
}
var
influxdb11format
=
query
.
toLowerCase
().
indexOf
(
'show tag values'
)
>=
0
;
var
res
=
{};
var
res
=
{};
_
.
each
(
influxResults
.
series
,
serie
=>
{
_
.
each
(
influxResults
.
series
,
serie
=>
{
_
.
each
(
serie
.
values
,
value
=>
{
_
.
each
(
serie
.
values
,
value
=>
{
if
(
_
.
isArray
(
value
))
{
if
(
_
.
isArray
(
value
))
{
if
(
influxdb11format
)
{
// In general, there are 2 possible shapes for the returned value.
addUnique
(
res
,
value
[
1
]
||
value
[
0
]);
// The first one is a two-element array,
// where the first element is somewhat a metadata value:
// the tag name for SHOW TAG VALUES queries,
// the time field for SELECT queries, etc.
// The second shape is an one-element array,
// that is containing an immediate value.
// For example, SHOW FIELD KEYS queries return such shape.
// Note, pre-0.11 versions return
// the second shape for SHOW TAG VALUES queries
// (while the newer versions—first).
if
(
value
[
1
]
!==
undefined
)
{
addUnique
(
res
,
value
[
1
]);
}
else
{
}
else
{
addUnique
(
res
,
value
[
0
]);
addUnique
(
res
,
value
[
0
]);
}
}
...
@@ -29,7 +38,7 @@ export default class ResponseParser {
...
@@ -29,7 +38,7 @@ export default class ResponseParser {
});
});
return
_
.
map
(
res
,
value
=>
{
return
_
.
map
(
res
,
value
=>
{
return
{
text
:
value
};
return
{
text
:
value
.
toString
()
};
});
});
}
}
}
}
...
...
public/app/plugins/datasource/influxdb/specs/response_parser.jest.ts
View file @
4b61c7cd
...
@@ -85,6 +85,32 @@ describe('influxdb response parser', () => {
...
@@ -85,6 +85,32 @@ describe('influxdb response parser', () => {
});
});
});
});
describe
(
'SELECT response'
,
()
=>
{
var
query
=
'SELECT "usage_iowait" FROM "cpu" LIMIT 10'
;
var
response
=
{
results
:
[
{
series
:
[
{
name
:
'cpu'
,
columns
:
[
'time'
,
'usage_iowait'
],
values
:
[[
1488465190006040638
,
0.0
],
[
1488465190006040638
,
15.0
],
[
1488465190006040638
,
20.2
]],
},
],
},
],
};
var
result
=
parser
.
parse
(
query
,
response
);
it
(
'should return second column'
,
()
=>
{
expect
(
_
.
size
(
result
)).
toBe
(
3
);
expect
(
result
[
0
].
text
).
toBe
(
'0'
);
expect
(
result
[
1
].
text
).
toBe
(
'15'
);
expect
(
result
[
2
].
text
).
toBe
(
'20.2'
);
});
});
describe
(
'SHOW FIELD response'
,
()
=>
{
describe
(
'SHOW FIELD response'
,
()
=>
{
var
query
=
'SHOW FIELD KEYS FROM "cpu"'
;
var
query
=
'SHOW FIELD KEYS FROM "cpu"'
;
describe
(
'response from 0.10.0'
,
()
=>
{
describe
(
'response from 0.10.0'
,
()
=>
{
...
...
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