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
9daa3997
Commit
9daa3997
authored
Sep 04, 2015
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(elasticsearch): time field selector now works, #1034
parent
83930ec9
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
38 additions
and
34 deletions
+38
-34
public/app/plugins/datasource/elasticsearch/partials/query.editor.html
+4
-1
public/app/plugins/datasource/elasticsearch/queryBuilder.js
+7
-13
public/app/plugins/datasource/elasticsearch/queryCtrl.js
+13
-1
public/app/plugins/datasource/graphite/partials/query.editor.html
+13
-19
public/test/specs/elasticsearch-querybuilder-specs.js
+1
-0
No files found.
public/app/plugins/datasource/elasticsearch/partials/query.editor.html
View file @
9daa3997
...
...
@@ -5,6 +5,9 @@
<i
class=
"fa fa-warning"
></i>
</a>
</li>
<li
class=
"tight-form-item small"
ng-show=
"target.datasource"
>
<em>
{{target.datasource}}
</em>
</li>
<li
class=
"tight-form-item"
>
<div
class=
"dropdown"
>
<a
class=
"pointer dropdown-toggle"
data-toggle=
"dropdown"
tabindex=
"1"
>
...
...
@@ -48,7 +51,7 @@
Time field
</li>
<li>
<metric-segment
segment=
"timeSegment"
get-alt-segments=
"get
Fields()"
on-value-changed=
"timestamp
Changed()"
></metric-segment>
<metric-segment
segment=
"timeSegment"
get-alt-segments=
"get
TimeFields()"
on-value-changed=
"timeField
Changed()"
></metric-segment>
</li>
</ul>
...
...
public/app/plugins/datasource/elasticsearch/queryBuilder.js
View file @
9daa3997
...
...
@@ -6,6 +6,12 @@ function (angular) {
function
ElasticQueryBuilder
()
{
}
ElasticQueryBuilder
.
prototype
.
getRangeFilter
=
function
(
timeField
)
{
var
filter
=
{};
filter
[
timeField
]
=
{
"gte"
:
"$timeFrom"
,
"lte"
:
"$timeTo"
};
return
filter
;
};
ElasticQueryBuilder
.
prototype
.
build
=
function
(
target
)
{
if
(
target
.
rawQuery
)
{
return
angular
.
fromJson
(
target
.
rawQuery
);
...
...
@@ -23,19 +29,7 @@ function (angular) {
},
"filter"
:
{
"bool"
:
{
"must"
:
[
{
"range"
:
{
"@timestamp"
:
{
"gte"
:
"$timeFrom"
,
"lte"
:
"$timeTo"
}
}
}
],
"must_not"
:
[
]
"must"
:
[{
"range"
:
this
.
getRangeFilter
(
target
.
timeField
)}]
}
}
}
...
...
public/app/plugins/datasource/elasticsearch/queryCtrl.js
View file @
9daa3997
...
...
@@ -143,7 +143,8 @@ function (angular, _, ElasticQueryBuilder) {
};
$scope
.
getGroupByFields
=
function
(
segment
)
{
return
$scope
.
datasource
.
metricFindQuery
(
'fields()'
).
then
(
$scope
.
transformToSegments
(
false
))
return
$scope
.
datasource
.
metricFindQuery
(
'fields()'
)
.
then
(
$scope
.
transformToSegments
(
false
))
.
then
(
function
(
results
)
{
if
(
segment
.
type
!==
'plus-button'
)
{
results
.
splice
(
0
,
0
,
angular
.
copy
(
$scope
.
removeGroupBySegment
));
...
...
@@ -153,6 +154,17 @@ function (angular, _, ElasticQueryBuilder) {
.
then
(
null
,
$scope
.
handleQueryError
);
};
$scope
.
getTimeFields
=
function
()
{
return
$scope
.
datasource
.
metricFindQuery
(
'fields()'
)
.
then
(
$scope
.
transformToSegments
(
false
))
.
then
(
null
,
$scope
.
handleQueryError
);
};
$scope
.
timeFieldChanged
=
function
()
{
$scope
.
target
.
timeField
=
$scope
.
timeSegment
.
value
;
$scope
.
queryUpdated
();
};
$scope
.
groupByChanged
=
function
(
segment
,
index
)
{
if
(
segment
.
value
===
$scope
.
removeGroupBySegment
.
value
)
{
$scope
.
target
.
groupByFields
.
splice
(
index
,
1
);
...
...
public/app/plugins/datasource/graphite/partials/query.editor.html
View file @
9daa3997
...
...
@@ -49,24 +49,18 @@
</li>
</ul>
<input
type=
"text"
class=
"tight-form-clear-input span10"
ng-model=
"target.target"
give-focus=
"target.textEditor"
spellcheck=
'false'
ng-model-onblur
ng-change=
"get_data()"
ng-show=
"target.textEditor"
/>
<input
type=
"text"
class=
"tight-form-clear-input span10"
ng-model=
"target.target"
give-focus=
"target.textEditor"
spellcheck=
'false'
ng-model-onblur
ng-change=
"get_data()"
ng-show=
"target.textEditor"
></input>
<ul
class=
"tight-form-list"
role=
"menu"
ng-hide=
"target.textEditor"
>
<li
ng-repeat=
"segment in segments"
role=
"menuitem"
>
<metric-segment
segment=
"segment"
get-alt-segments=
"getAltSegments($index)"
on-value-changed=
"segmentValueChanged(segment, $index)"
></metric-segment>
</li>
<li
ng-repeat=
"func in functions"
>
<span
graphite-func-editor
class=
"tight-form-item tight-form-func"
>
</span>
</li>
<li
class=
"dropdown"
graphite-add-func
>
</li>
</ul>
<div
class=
"clearfix"
></div>
</div>
<ul
class=
"tight-form-list"
role=
"menu"
ng-hide=
"target.textEditor"
>
<li
ng-repeat=
"segment in segments"
role=
"menuitem"
>
<metric-segment
segment=
"segment"
get-alt-segments=
"getAltSegments($index)"
on-value-changed=
"segmentValueChanged(segment, $index)"
></metric-segment>
</li>
<li
ng-repeat=
"func in functions"
>
<span
graphite-func-editor
class=
"tight-form-item tight-form-func"
>
</span>
</li>
<li
class=
"dropdown"
graphite-add-func
>
</li>
</ul>
<div
class=
"clearfix"
></div>
</div>
public/test/specs/elasticsearch-querybuilder-specs.js
View file @
9daa3997
...
...
@@ -9,6 +9,7 @@ define([
var
builder
=
new
ElasticQueryBuilder
();
var
query
=
builder
.
build
({
timeField
:
'@timestamp'
,
select
:
[{
agg
:
'Count'
}],
groupByFields
:
[],
});
...
...
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