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
07310643
Commit
07310643
authored
Dec 08, 2015
by
Carl Bergquist
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adds support for moving avg support in es queries
parent
e1944614
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
3 deletions
+46
-3
public/app/plugins/datasource/elasticsearch/query_builder.js
+22
-3
public/app/plugins/datasource/elasticsearch/specs/query_builder_specs.ts
+24
-0
No files found.
public/app/plugins/datasource/elasticsearch/query_builder.js
View file @
07310643
...
...
@@ -175,8 +175,28 @@ function () {
}
var
aggField
=
{};
aggField
[
metric
.
type
]
=
metricAgg
;
nestedAggs
.
aggs
[
metric
.
id
]
=
aggField
;
if
(
metric
.
type
===
'moving_avg'
)
{
var
pipeAgg
=
''
;
for
(
var
aggname
in
nestedAggs
.
aggs
)
{
var
agg
=
nestedAggs
.
aggs
[
aggname
];
for
(
prop
in
agg
)
{
if
(
agg
.
hasOwnProperty
(
prop
)
&&
agg
[
prop
]
!==
null
)
{
if
(
metric
.
field
===
prop
)
{
pipeAgg
=
aggname
;
break
;
}
}
}
}
if
(
pipeAgg
!==
''
)
{
aggField
[
metric
.
type
]
=
{
buckets_path
:
pipeAgg
};
nestedAggs
.
aggs
[
metric
.
id
]
=
aggField
;
}
}
else
{
aggField
[
metric
.
type
]
=
metricAgg
;
nestedAggs
.
aggs
[
metric
.
id
]
=
aggField
;
}
}
return
query
;
...
...
@@ -217,5 +237,4 @@ function () {
};
return
ElasticQueryBuilder
;
});
public/app/plugins/datasource/elasticsearch/specs/query_builder_specs.ts
View file @
07310643
...
...
@@ -155,4 +155,28 @@ describe('ElasticQueryBuilder', function() {
expect
(
query
.
size
).
to
.
be
(
500
);
});
it
(
'with moving average'
,
function
()
{
var
query
=
builder
.
build
({
metrics
:
[
{
id
:
'1'
,
type
:
'sum'
,
field
:
'@value'
,
},
{
id
:
'2'
,
type
:
'moving_avg'
,
field
:
'sum'
}
],
bucketAggs
:
[
{
type
:
'date_histogram'
,
field
:
'@timestamp'
,
id
:
'3'
}
],
});
var
firstLevel
=
query
.
aggs
[
"3"
];
expect
(
firstLevel
.
aggs
[
"2"
]).
not
.
to
.
be
(
undefined
);
expect
(
firstLevel
.
aggs
[
"2"
].
moving_avg
).
not
.
to
.
be
(
undefined
);
expect
(
firstLevel
.
aggs
[
"2"
].
moving_avg
.
buckets_path
).
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