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
a30ceefa
Commit
a30ceefa
authored
Nov 25, 2015
by
Mauro Stettler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add tests for elastic search versioning in query builder and make es version 2 default
parent
ada9bfca
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
3 deletions
+36
-3
public/app/features/org/datasourceEditCtrl.js
+1
-1
public/app/plugins/datasource/elasticsearch/query_builder.js
+2
-2
public/app/plugins/datasource/elasticsearch/specs/query_builder_specs.ts
+33
-0
No files found.
public/app/features/org/datasourceEditCtrl.js
View file @
a30ceefa
...
@@ -13,7 +13,7 @@ function (angular, _, config) {
...
@@ -13,7 +13,7 @@ function (angular, _, config) {
$scope
.
httpConfigPartialSrc
=
'app/features/org/partials/datasourceHttpConfig.html'
;
$scope
.
httpConfigPartialSrc
=
'app/features/org/partials/datasourceHttpConfig.html'
;
var
defaults
=
{
name
:
''
,
type
:
'graphite'
,
url
:
''
,
access
:
'proxy'
};
var
defaults
=
{
name
:
''
,
type
:
'graphite'
,
url
:
''
,
access
:
'proxy'
,
jsonData
:
{
'elasticsearchVersion'
:
2
}
};
$scope
.
indexPatternTypes
=
[
$scope
.
indexPatternTypes
=
[
{
name
:
'No pattern'
,
value
:
undefined
},
{
name
:
'No pattern'
,
value
:
undefined
},
...
...
public/app/plugins/datasource/elasticsearch/query_builder.js
View file @
a30ceefa
...
@@ -13,7 +13,7 @@ function (angular) {
...
@@ -13,7 +13,7 @@ function (angular) {
var
filter
=
{};
var
filter
=
{};
filter
[
this
.
timeField
]
=
{
"gte"
:
"$timeFrom"
,
"lte"
:
"$timeTo"
};
filter
[
this
.
timeField
]
=
{
"gte"
:
"$timeFrom"
,
"lte"
:
"$timeTo"
};
// elastic search versions
above 2.0
require the time format to be specified
// elastic search versions
2.x
require the time format to be specified
if
(
this
.
elasticsearchVersion
>=
2
)
{
if
(
this
.
elasticsearchVersion
>=
2
)
{
filter
[
this
.
timeField
][
"format"
]
=
"epoch_millis"
;
filter
[
this
.
timeField
][
"format"
]
=
"epoch_millis"
;
}
}
...
@@ -136,7 +136,7 @@ function (angular) {
...
@@ -136,7 +136,7 @@ function (angular) {
"min_doc_count"
:
0
,
"min_doc_count"
:
0
,
"extended_bounds"
:
{
"min"
:
"$timeFrom"
,
"max"
:
"$timeTo"
}
"extended_bounds"
:
{
"min"
:
"$timeFrom"
,
"max"
:
"$timeTo"
}
};
};
// elastic search versions
above 2.0
require the time format to be specified
// elastic search versions
2.x
require the time format to be specified
if
(
this
.
elasticsearchVersion
>=
2
)
{
if
(
this
.
elasticsearchVersion
>=
2
)
{
esAgg
[
"date_histogram"
][
"format"
]
=
"epoch_millis"
;
esAgg
[
"date_histogram"
][
"format"
]
=
"epoch_millis"
;
}
}
...
...
public/app/plugins/datasource/elasticsearch/specs/query_builder_specs.ts
View file @
a30ceefa
...
@@ -44,6 +44,39 @@ describe('ElasticQueryBuilder', function() {
...
@@ -44,6 +44,39 @@ describe('ElasticQueryBuilder', function() {
expect
(
query
.
aggs
[
"2"
].
aggs
[
"3"
].
date_histogram
.
field
).
to
.
be
(
"@timestamp"
);
expect
(
query
.
aggs
[
"2"
].
aggs
[
"3"
].
date_histogram
.
field
).
to
.
be
(
"@timestamp"
);
});
});
it
(
'with es1.x and es2.x date histogram queries check time format'
,
function
()
{
var
builder_2x
=
new
ElasticQueryBuilder
({
timeField
:
'@timestamp'
,
elasticsearchVersion
:
2
});
var
query_params
=
{
metrics
:
[],
bucketAggs
:
[
{
type
:
'date_histogram'
,
field
:
'@timestamp'
,
id
:
'1'
}
],
};
// format should not be specified in 1.x queries
expect
(
"format"
in
builder
.
build
(
query_params
)[
"aggs"
][
"1"
][
"date_histogram"
]).
to
.
be
(
false
);
// 2.x query should specify format to be "epoch_millis"
expect
(
builder_2x
.
build
(
query_params
)[
"aggs"
][
"1"
][
"date_histogram"
][
"format"
]).
to
.
be
(
"epoch_millis"
);
});
it
(
'with es1.x and es2.x range filter check time format'
,
function
()
{
var
builder_2x
=
new
ElasticQueryBuilder
({
timeField
:
'@timestamp'
,
elasticsearchVersion
:
2
});
// format should not be specified in 1.x queries
expect
(
"format"
in
builder
.
getRangeFilter
()[
"@timestamp"
]).
to
.
be
(
false
);
// 2.x query should specify format to be "epoch_millis"
expect
(
builder_2x
.
getRangeFilter
()[
"@timestamp"
][
"format"
]).
to
.
be
(
"epoch_millis"
);
});
it
(
'with select field'
,
function
()
{
it
(
'with select field'
,
function
()
{
var
query
=
builder
.
build
({
var
query
=
builder
.
build
({
metrics
:
[{
type
:
'avg'
,
field
:
'@value'
,
id
:
'1'
}],
metrics
:
[{
type
:
'avg'
,
field
:
'@value'
,
id
:
'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