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
ada9bfca
Commit
ada9bfca
authored
Nov 22, 2015
by
Mauro Stettler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
keep track of elastic search version and generate query according to version
parent
1fa8b745
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
32 additions
and
2 deletions
+32
-2
public/app/features/org/datasourceEditCtrl.js
+6
-0
public/app/plugins/datasource/elasticsearch/datasource.js
+3
-1
public/app/plugins/datasource/elasticsearch/partials/config.html
+12
-1
public/app/plugins/datasource/elasticsearch/query_builder.js
+11
-0
No files found.
public/app/features/org/datasourceEditCtrl.js
View file @
ada9bfca
...
...
@@ -24,6 +24,12 @@ function (angular, _, config) {
{
name
:
'Yearly'
,
value
:
'Yearly'
,
example
:
'[logstash-]YYYY'
},
];
$scope
.
elasticsearchVersions
=
[
{
name
:
'0.x'
,
value
:
0
},
{
name
:
'1.x'
,
value
:
1
},
{
name
:
'2.x'
,
value
:
2
},
];
$scope
.
init
=
function
()
{
$scope
.
isNew
=
true
;
$scope
.
datasources
=
[];
...
...
public/app/plugins/datasource/elasticsearch/datasource.js
View file @
ada9bfca
...
...
@@ -23,9 +23,11 @@ function (angular, _, moment, kbn, ElasticQueryBuilder, IndexPattern, ElasticRes
this
.
name
=
datasource
.
name
;
this
.
index
=
datasource
.
index
;
this
.
timeField
=
datasource
.
jsonData
.
timeField
;
this
.
elasticsearchVersion
=
datasource
.
jsonData
.
elasticsearchVersion
;
this
.
indexPattern
=
new
IndexPattern
(
datasource
.
index
,
datasource
.
jsonData
.
interval
);
this
.
queryBuilder
=
new
ElasticQueryBuilder
({
timeField
:
this
.
timeField
timeField
:
this
.
timeField
,
elasticsearchVersion
:
this
.
elasticsearchVersion
});
}
...
...
public/app/plugins/datasource/elasticsearch/partials/config.html
View file @
ada9bfca
...
...
@@ -20,7 +20,7 @@
</ul>
<div
class=
"clearfix"
></div>
</div>
<div
class=
"tight-form
last
"
>
<div
class=
"tight-form"
>
<ul
class=
"tight-form-list"
>
<li
class=
"tight-form-item"
style=
"width: 144px"
>
Time field name
...
...
@@ -31,3 +31,14 @@
</ul>
<div
class=
"clearfix"
></div>
</div>
<div
class=
"tight-form last"
>
<ul
class=
"tight-form-list"
>
<li
class=
"tight-form-item"
style=
"width: 144px"
>
Elasticsearch version
</li>
<li>
<select
class=
"input-medium tight-form-input"
ng-model=
"current.jsonData.elasticsearchVersion"
ng-options=
"f.value as f.name for f in elasticsearchVersions"
></select>
</li>
</ul>
<div
class=
"clearfix"
></div>
</div>
public/app/plugins/datasource/elasticsearch/query_builder.js
View file @
ada9bfca
...
...
@@ -6,11 +6,18 @@ function (angular) {
function
ElasticQueryBuilder
(
options
)
{
this
.
timeField
=
options
.
timeField
;
this
.
elasticsearchVersion
=
options
.
elasticsearchVersion
;
}
ElasticQueryBuilder
.
prototype
.
getRangeFilter
=
function
()
{
var
filter
=
{};
filter
[
this
.
timeField
]
=
{
"gte"
:
"$timeFrom"
,
"lte"
:
"$timeTo"
};
// elastic search versions above 2.0 require the time format to be specified
if
(
this
.
elasticsearchVersion
>=
2
)
{
filter
[
this
.
timeField
][
"format"
]
=
"epoch_millis"
;
}
return
filter
;
};
...
...
@@ -129,6 +136,10 @@ function (angular) {
"min_doc_count"
:
0
,
"extended_bounds"
:
{
"min"
:
"$timeFrom"
,
"max"
:
"$timeTo"
}
};
// elastic search versions above 2.0 require the time format to be specified
if
(
this
.
elasticsearchVersion
>=
2
)
{
esAgg
[
"date_histogram"
][
"format"
]
=
"epoch_millis"
;
}
break
;
}
case
'filters'
:
{
...
...
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