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
8e18f2c5
Commit
8e18f2c5
authored
Dec 09, 2015
by
carl bergquist
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor es pipeline aggregation variables to match ES
parent
0644bfe2
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
70 additions
and
36 deletions
+70
-36
public/app/plugins/datasource/elasticsearch/elastic_response.js
+5
-1
public/app/plugins/datasource/elasticsearch/metric_agg.js
+3
-3
public/app/plugins/datasource/elasticsearch/partials/metricAgg.html
+1
-1
public/app/plugins/datasource/elasticsearch/query_builder.js
+2
-2
public/app/plugins/datasource/elasticsearch/query_def.js
+11
-1
public/app/plugins/datasource/elasticsearch/specs/query_builder_specs.ts
+3
-3
public/app/plugins/datasource/elasticsearch/specs/query_def_specs.ts
+45
-25
No files found.
public/app/plugins/datasource/elasticsearch/elastic_response.js
View file @
8e18f2c5
...
...
@@ -199,7 +199,11 @@ function (_, queryDef) {
if
(
series
.
field
&&
series
.
metric
===
'moving_avg'
)
{
var
appliedAgg
=
_
.
findWhere
(
target
.
metrics
,
{
id
:
series
.
field
});
metricName
+=
' '
+
queryDef
.
describeMetric
(
appliedAgg
);
if
(
appliedAgg
)
{
metricName
+=
' '
+
queryDef
.
describeMetric
(
appliedAgg
);
}
else
{
metricName
=
'Unset'
;
}
}
else
if
(
series
.
field
)
{
metricName
+=
' '
+
series
.
field
;
}
...
...
public/app/plugins/datasource/elasticsearch/metric_agg.js
View file @
8e18f2c5
...
...
@@ -22,7 +22,7 @@ function (angular, _, queryDef) {
};
$scope
.
updateMavgOptions
=
function
()
{
$scope
.
mavgOptions
=
queryDef
.
getMovingAverage
Source
Options
(
$scope
.
target
);
$scope
.
mavgOptions
=
queryDef
.
getMovingAverageOptions
(
$scope
.
target
);
};
$rootScope
.
onAppEvent
(
'elastic-query-updated'
,
function
()
{
...
...
@@ -43,9 +43,9 @@ function (angular, _, queryDef) {
switch
(
$scope
.
agg
.
type
)
{
case
'moving_avg'
:
{
$scope
.
agg
.
mavgSource
=
$scope
.
agg
.
mavgSource
||
'Metric to apply moving average'
;
$scope
.
agg
.
pipelineAgg
=
$scope
.
agg
.
pipelineAgg
||
'Metric to apply moving average'
;
$scope
.
settingsLinkText
=
'Moving average options'
;
$scope
.
agg
.
field
=
$scope
.
agg
.
mavgSource
;
$scope
.
agg
.
field
=
$scope
.
agg
.
pipelineAgg
;
break
;
}
case
'percentiles'
:
{
...
...
public/app/plugins/datasource/elasticsearch/partials/metricAgg.html
View file @
8e18f2c5
...
...
@@ -33,7 +33,7 @@
Based on
</li>
<li>
<metric-segment-model
property=
"agg.
mavgSource
"
options=
"mavgOptions"
on-change=
"onChangeInternal()"
css-class=
"last"
></metric-segment-model>
<metric-segment-model
property=
"agg.
pipelineAgg
"
options=
"mavgOptions"
on-change=
"onChangeInternal()"
css-class=
"last"
></metric-segment-model>
</li>
</ul>
<div
class=
"clearfix"
></div>
...
...
public/app/plugins/datasource/elasticsearch/query_builder.js
View file @
8e18f2c5
...
...
@@ -171,8 +171,8 @@ function () {
var
metricAgg
=
null
;
if
(
metric
.
type
===
'moving_avg'
)
{
if
(
metric
.
mavgSource
&&
/^
\d
*$/
.
test
(
metric
.
mavgSource
))
{
metricAgg
=
{
buckets_path
:
metric
.
mavgSource
};
if
(
metric
.
pipelineAgg
&&
/^
\d
*$/
.
test
(
metric
.
pipelineAgg
))
{
metricAgg
=
{
buckets_path
:
metric
.
pipelineAgg
};
}
else
{
continue
;
}
...
...
public/app/plugins/datasource/elasticsearch/query_def.js
View file @
8e18f2c5
...
...
@@ -67,7 +67,17 @@ function (_) {
{
text
:
'1d'
,
value
:
'1d'
},
],
getMovingAverageSourceOptions
:
function
(
targets
)
{
pipelineAggs
:
[
'moving_avg'
],
isPipelineAgg
:
function
(
metric
)
{
if
(
metric
.
type
)
{
return
this
.
pipelineAggs
.
indexOf
(
metric
.
type
)
>
-
1
;
}
return
false
;
},
getMovingAverageOptions
:
function
(
targets
)
{
var
self
=
this
;
var
result
=
[];
_
.
each
(
targets
.
metrics
,
function
(
metric
)
{
...
...
public/app/plugins/datasource/elasticsearch/specs/query_builder_specs.ts
View file @
8e18f2c5
...
...
@@ -167,7 +167,7 @@ describe('ElasticQueryBuilder', function() {
id
:
'2'
,
type
:
'moving_avg'
,
field
:
'3'
,
mavgSource
:
'3'
pipelineAgg
:
'3'
}
],
bucketAggs
:
[
...
...
@@ -194,13 +194,13 @@ describe('ElasticQueryBuilder', function() {
id
:
'2'
,
type
:
'moving_avg'
,
field
:
'3'
,
mavgSource
:
'3'
pipelineAgg
:
'3'
},
{
id
:
'4'
,
type
:
'moving_avg'
,
field
:
'3'
,
mavgSource
:
'Metric to apply moving average'
pipelineAgg
:
'Metric to apply moving average'
}
],
bucketAggs
:
[
...
...
public/app/plugins/datasource/elasticsearch/specs/query_def_specs.ts
View file @
8e18f2c5
...
...
@@ -8,41 +8,61 @@ declare var QueryDef: any;
describe
(
'ElasticQueryDef'
,
function
()
{
describe
(
'with zero targets'
,
function
()
{
var
response
=
QueryDef
.
getMovingAverageSourceOptions
([]);
describe
(
'getMovingAverageOptions'
,
function
()
{
describe
(
'with zero targets'
,
function
()
{
var
response
=
QueryDef
.
getMovingAverageOptions
([]);
it
(
'should return zero'
,
function
()
{
expect
(
response
.
length
).
to
.
be
(
0
);
it
(
'should return zero'
,
function
()
{
expect
(
response
.
length
).
to
.
be
(
0
);
});
});
});
describe
(
'with count and sum targets'
,
function
()
{
var
targets
=
{
metrics
:
[
{
type
:
'count'
,
field
:
'@value'
},
{
type
:
'sum'
,
field
:
'@value'
}
]
};
describe
(
'with count and sum targets'
,
function
()
{
var
targets
=
{
metrics
:
[
{
type
:
'count'
,
field
:
'@value'
},
{
type
:
'sum'
,
field
:
'@value'
}
]
};
var
response
=
QueryDef
.
getMovingAverageSourc
eOptions
(
targets
);
var
response
=
QueryDef
.
getMovingAverag
eOptions
(
targets
);
it
(
'should return zero'
,
function
()
{
expect
(
response
.
length
).
to
.
be
(
2
);
it
(
'should return zero'
,
function
()
{
expect
(
response
.
length
).
to
.
be
(
2
);
});
});
describe
(
'with count and moving average targets'
,
function
()
{
var
targets
=
{
metrics
:
[
{
type
:
'count'
,
field
:
'@value'
},
{
type
:
'moving_avg'
,
field
:
'@value'
}
]
};
var
response
=
QueryDef
.
getMovingAverageOptions
(
targets
);
it
(
'should return zero'
,
function
()
{
expect
(
response
.
length
).
to
.
be
(
1
);
});
});
});
describe
(
'with count and moving average targets'
,
function
()
{
var
targets
=
{
metrics
:
[
{
type
:
'count'
,
field
:
'@value'
},
{
type
:
'moving_avg'
,
field
:
'@value'
}
]
};
describe
(
'isPipelineMetric'
,
function
()
{
describe
(
'moving_avg'
,
function
()
{
var
result
=
QueryDef
.
isPipelineAgg
({
type
:
'moving_avg'
});
it
(
'is pipe line metric'
,
function
()
{
expect
(
result
).
to
.
be
(
true
);
});
});
var
response
=
QueryDef
.
getMovingAverageSourceOptions
(
targets
);
describe
(
'count'
,
function
()
{
var
result
=
QueryDef
.
isPipelineAgg
({
type
:
'count'
});
it
(
'should return zero'
,
function
()
{
expect
(
response
.
length
).
to
.
be
(
1
);
it
(
'is not pipe line metric'
,
function
()
{
expect
(
result
).
to
.
be
(
false
);
});
});
});
});
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