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
ba48f40d
Commit
ba48f40d
authored
Mar 23, 2016
by
bergquist
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(influxdb): bases parsing upon query
parent
6fafc8db
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
64 additions
and
10 deletions
+64
-10
public/app/plugins/datasource/influxdb/datasource.ts
+1
-1
public/app/plugins/datasource/influxdb/response_parser.ts
+3
-3
public/app/plugins/datasource/influxdb/specs/response_parser_specs.ts
+60
-6
No files found.
public/app/plugins/datasource/influxdb/datasource.ts
View file @
ba48f40d
...
@@ -112,7 +112,7 @@ export function InfluxDatasource(instanceSettings, $q, backendSrv, templateSrv)
...
@@ -112,7 +112,7 @@ export function InfluxDatasource(instanceSettings, $q, backendSrv, templateSrv)
}
}
return
this
.
_seriesQuery
(
interpolated
)
return
this
.
_seriesQuery
(
interpolated
)
.
then
(
_
.
curry
(
this
.
responseParser
.
parse
)(
query
Type
));
.
then
(
_
.
curry
(
this
.
responseParser
.
parse
)(
query
));
};
};
this
.
_seriesQuery
=
function
(
query
)
{
this
.
_seriesQuery
=
function
(
query
)
{
...
...
public/app/plugins/datasource/influxdb/response_parser.ts
View file @
ba48f40d
...
@@ -4,7 +4,7 @@ import _ from 'lodash';
...
@@ -4,7 +4,7 @@ import _ from 'lodash';
export
default
class
ResponseParser
{
export
default
class
ResponseParser
{
parse
(
query
Type
,
results
)
{
parse
(
query
,
results
)
{
if
(
!
results
||
results
.
results
.
length
===
0
)
{
return
[];
}
if
(
!
results
||
results
.
results
.
length
===
0
)
{
return
[];
}
var
influxResults
=
results
.
results
[
0
];
var
influxResults
=
results
.
results
[
0
];
...
@@ -13,9 +13,9 @@ export default class ResponseParser {
...
@@ -13,9 +13,9 @@ export default class ResponseParser {
}
}
var
series
=
influxResults
.
series
[
0
];
var
series
=
influxResults
.
series
[
0
];
return
_
.
map
(
series
.
values
,
function
(
value
)
{
return
_
.
map
(
series
.
values
,
(
value
)
=>
{
if
(
_
.
isArray
(
value
))
{
if
(
_
.
isArray
(
value
))
{
if
(
query
Type
===
'SHOW_TAGS'
)
{
if
(
query
.
indexOf
(
'SHOW TAG VALUES'
)
>=
0
)
{
return
{
text
:
(
value
[
1
]
||
value
[
0
])
};
return
{
text
:
(
value
[
1
]
||
value
[
0
])
};
}
else
{
}
else
{
return
{
text
:
value
[
0
]
};
return
{
text
:
value
[
0
]
};
...
...
public/app/plugins/datasource/influxdb/specs/response_parser_specs.ts
View file @
ba48f40d
...
@@ -4,7 +4,56 @@ import ResponseParser from '../response_parser';
...
@@ -4,7 +4,56 @@ import ResponseParser from '../response_parser';
describe
(
"influxdb response parser"
,
()
=>
{
describe
(
"influxdb response parser"
,
()
=>
{
this
.
parser
=
new
ResponseParser
();
this
.
parser
=
new
ResponseParser
();
describe
(
"SHOW_TAGS response"
,
()
=>
{
describe
(
"SHOW TAG response"
,
()
=>
{
var
query
=
'SHOW TAG KEYS FROM "cpu"'
;
describe
(
"response from 0.10.0"
,
()
=>
{
var
response
=
{
"results"
:
[
{
"series"
:
[
{
"name"
:
"cpu"
,
"columns"
:
[
"tagKey"
],
"values"
:
[
[
"datacenter"
],
[
"hostname"
],
[
"source"
]
]
}
]
}
]
};
var
result
=
this
.
parser
.
parse
(
query
,
response
);
it
(
"expects three results"
,
()
=>
{
expect
(
_
.
size
(
result
)).
to
.
be
(
3
);
});
});
describe
(
"response from 0.11.0"
,
()
=>
{
var
response
=
{
"results"
:
[
{
"series"
:
[
{
"name"
:
"cpu"
,
"columns"
:
[
"tagKey"
],
"values"
:
[
[
"datacenter"
],
[
"hostname"
],
[
"source"
]
]
}
]
}
]
};
var
result
=
this
.
parser
.
parse
(
query
,
response
);
it
(
"expects three results"
,
()
=>
{
expect
(
_
.
size
(
result
)).
to
.
be
(
3
);
});
});
});
describe
(
"SHOW TAG VALUES response"
,
()
=>
{
var
query
=
'SHOW TAG VALUES FROM "cpu" WITH KEY = "hostname"'
;
describe
(
"response from 0.10.0"
,
()
=>
{
describe
(
"response from 0.10.0"
,
()
=>
{
var
response
=
{
var
response
=
{
"results"
:
[
"results"
:
[
...
@@ -20,7 +69,7 @@ describe("influxdb response parser", () => {
...
@@ -20,7 +69,7 @@ describe("influxdb response parser", () => {
]
]
};
};
var
result
=
this
.
parser
.
parse
(
'SHOW_TAGS'
,
response
);
var
result
=
this
.
parser
.
parse
(
query
,
response
);
it
(
"should get two responses"
,
()
=>
{
it
(
"should get two responses"
,
()
=>
{
expect
(
_
.
size
(
result
)).
to
.
be
(
2
);
expect
(
_
.
size
(
result
)).
to
.
be
(
2
);
...
@@ -44,7 +93,7 @@ describe("influxdb response parser", () => {
...
@@ -44,7 +93,7 @@ describe("influxdb response parser", () => {
]
]
};
};
var
result
=
this
.
parser
.
parse
(
'SHOW_TAGS'
,
response
);
var
result
=
this
.
parser
.
parse
(
query
,
response
);
it
(
"should get two responses"
,
()
=>
{
it
(
"should get two responses"
,
()
=>
{
expect
(
_
.
size
(
result
)).
to
.
be
(
2
);
expect
(
_
.
size
(
result
)).
to
.
be
(
2
);
...
@@ -52,9 +101,14 @@ describe("influxdb response parser", () => {
...
@@ -52,9 +101,14 @@ describe("influxdb response parser", () => {
expect
(
result
[
1
].
text
).
to
.
be
(
'api'
);
expect
(
result
[
1
].
text
).
to
.
be
(
'api'
);
});
});
});
});
});
});
describe
(
"SHOW_FIELDS response"
,
()
=>
{
describe
(
"SHOW FIELD response"
,
()
=>
{
var
query
=
'SHOW FIELD KEYS FROM "cpu"'
;
describe
(
"response from 0.10.0"
,
()
=>
{
describe
(
"response from 0.10.0"
,
()
=>
{
var
response
=
{
var
response
=
{
"results"
:
[
"results"
:
[
...
@@ -72,7 +126,7 @@ describe("influxdb response parser", () => {
...
@@ -72,7 +126,7 @@ describe("influxdb response parser", () => {
]
]
};
};
var
result
=
this
.
parser
.
parse
(
'SHOW_FIELDS'
,
response
);
var
result
=
this
.
parser
.
parse
(
query
,
response
);
it
(
"should get two responses"
,
()
=>
{
it
(
"should get two responses"
,
()
=>
{
expect
(
_
.
size
(
result
)).
to
.
be
(
6
);
expect
(
_
.
size
(
result
)).
to
.
be
(
6
);
});
});
...
@@ -93,7 +147,7 @@ describe("influxdb response parser", () => {
...
@@ -93,7 +147,7 @@ describe("influxdb response parser", () => {
]
]
};
};
var
result
=
this
.
parser
.
parse
(
'SHOW_FIELDS'
,
response
);
var
result
=
this
.
parser
.
parse
(
query
,
response
);
it
(
"should get two responses"
,
()
=>
{
it
(
"should get two responses"
,
()
=>
{
expect
(
_
.
size
(
result
)).
to
.
be
(
1
);
expect
(
_
.
size
(
result
)).
to
.
be
(
1
);
...
...
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