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
99c5f7d5
Commit
99c5f7d5
authored
Dec 09, 2016
by
bergquist
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(elastic): remove support for ES 1.x
parent
873024b9
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
9 additions
and
50 deletions
+9
-50
public/app/plugins/datasource/elasticsearch/config_ctrl.ts
+0
-1
public/app/plugins/datasource/elasticsearch/datasource.js
+1
-4
public/app/plugins/datasource/elasticsearch/query_builder.js
+8
-12
public/app/plugins/datasource/elasticsearch/specs/query_builder_specs.ts
+0
-33
No files found.
public/app/plugins/datasource/elasticsearch/config_ctrl.ts
View file @
99c5f7d5
...
...
@@ -22,7 +22,6 @@ export class ElasticConfigCtrl {
];
esVersions
=
[
{
name
:
'1.x'
,
value
:
1
},
{
name
:
'2.x'
,
value
:
2
},
{
name
:
'5.x'
,
value
:
5
},
];
...
...
public/app/plugins/datasource/elasticsearch/datasource.js
View file @
99c5f7d5
...
...
@@ -81,12 +81,9 @@ function (angular, _, moment, kbn, ElasticQueryBuilder, IndexPattern, ElasticRes
range
[
timeField
]
=
{
from
:
options
.
range
.
from
.
valueOf
(),
to
:
options
.
range
.
to
.
valueOf
(),
format
:
"epoch_millis"
,
};
if
(
this
.
esVersion
>=
2
)
{
range
[
timeField
][
"format"
]
=
"epoch_millis"
;
}
var
queryInterpolated
=
templateSrv
.
replace
(
queryString
,
{},
'lucene'
);
var
query
=
{
"bool"
:
{
...
...
public/app/plugins/datasource/elasticsearch/query_builder.js
View file @
99c5f7d5
...
...
@@ -11,11 +11,11 @@ function (queryDef) {
ElasticQueryBuilder
.
prototype
.
getRangeFilter
=
function
()
{
var
filter
=
{};
filter
[
this
.
timeField
]
=
{
"gte"
:
"$timeFrom"
,
"lte"
:
"$timeTo"
};
if
(
this
.
esVersion
>=
2
)
{
f
ilter
[
this
.
timeField
][
"format"
]
=
"epoch_millis"
;
}
filter
[
this
.
timeField
]
=
{
gte
:
"$timeFrom"
,
lte
:
"$timeTo"
,
f
ormat
:
"epoch_millis"
,
}
;
return
filter
;
};
...
...
@@ -59,15 +59,12 @@ function (queryDef) {
esAgg
.
field
=
this
.
timeField
;
esAgg
.
min_doc_count
=
settings
.
min_doc_count
||
0
;
esAgg
.
extended_bounds
=
{
min
:
"$timeFrom"
,
max
:
"$timeTo"
};
esAgg
.
format
=
"epoch_millis"
;
if
(
esAgg
.
interval
===
'auto'
)
{
esAgg
.
interval
=
"$interval"
;
}
if
(
this
.
esVersion
>=
2
)
{
esAgg
.
format
=
"epoch_millis"
;
}
return
esAgg
;
};
...
...
@@ -108,14 +105,13 @@ function (queryDef) {
return
;
}
var
i
,
filter
,
condition
,
must
;
must
=
query
.
query
.
bool
.
must
;
var
i
,
filter
,
condition
;
for
(
i
=
0
;
i
<
adhocFilters
.
length
;
i
++
)
{
filter
=
adhocFilters
[
i
];
condition
=
{};
condition
[
filter
.
key
]
=
filter
.
value
;
must
.
push
({
"term"
:
condition
});
query
.
query
.
bool
.
must
.
push
({
"term"
:
condition
});
}
};
...
...
public/app/plugins/datasource/elasticsearch/specs/query_builder_specs.ts
View file @
99c5f7d5
...
...
@@ -50,39 +50,6 @@ describe('ElasticQueryBuilder', function() {
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'
,
esVersion
:
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'
,
esVersion
:
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
()
{
var
query
=
builder
.
build
({
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