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
b97e7845
Commit
b97e7845
authored
Jan 04, 2017
by
Vaibhav Tandon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Moving average support for all models along with additional settings associated with each model
parent
65057212
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
79 additions
and
3 deletions
+79
-3
public/app/plugins/datasource/elasticsearch/metric_agg.js
+26
-0
public/app/plugins/datasource/elasticsearch/partials/metric_agg.html
+12
-2
public/app/plugins/datasource/elasticsearch/query_def.js
+41
-1
No files found.
public/app/plugins/datasource/elasticsearch/metric_agg.js
View file @
b97e7845
...
...
@@ -29,6 +29,7 @@ function (angular, _, queryDef) {
$scope
.
metricAggTypes
=
queryDef
.
getMetricAggTypes
(
$scope
.
esVersion
);
$scope
.
extendedStats
=
queryDef
.
extendedStats
;
$scope
.
pipelineAggOptions
=
[];
$scope
.
modelSettingsValues
=
{};
$scope
.
init
=
function
()
{
$scope
.
agg
=
metricAggs
[
$scope
.
index
];
...
...
@@ -95,6 +96,12 @@ function (angular, _, queryDef) {
$scope
.
settingsLinkText
=
'Stats: '
+
stats
.
join
(
', '
);
break
;
}
case
'moving_avg'
:
{
$scope
.
movingAvgModelTypes
=
queryDef
.
movingAvgModelOptions
;
$scope
.
modelSettings
=
queryDef
.
getMovingAvgSettings
(
$scope
.
agg
.
settings
.
model
,
true
);
$scope
.
updateMovingAvgModelSettings
();
break
;
}
case
'raw_document'
:
{
$scope
.
target
.
metrics
=
[
$scope
.
agg
];
$scope
.
target
.
bucketAggs
=
[];
...
...
@@ -127,6 +134,25 @@ function (angular, _, queryDef) {
$scope
.
onChange
();
};
$scope
.
updateMovingAvgModelSettings
=
function
()
{
var
modelSettingsKeys
=
[];
var
modelSettings
=
queryDef
.
getMovingAvgSettings
(
$scope
.
agg
.
settings
.
model
,
false
);
for
(
var
i
=
0
;
i
<
modelSettings
.
length
;
i
++
)
{
modelSettingsKeys
.
push
(
modelSettings
[
i
].
value
);
}
for
(
var
key
in
$scope
.
agg
.
settings
.
settings
)
{
if
((
$scope
.
agg
.
settings
.
settings
[
key
]
===
null
)
||
(
modelSettingsKeys
.
indexOf
(
key
)
===
-
1
))
{
delete
$scope
.
agg
.
settings
.
settings
[
key
];
}
}
};
$scope
.
onChangeClearInternal
=
function
()
{
delete
$scope
.
agg
.
settings
.
minimize
;
$scope
.
onChange
();
};
$scope
.
onTypeChange
=
function
()
{
$scope
.
agg
.
settings
=
{};
$scope
.
agg
.
meta
=
{};
...
...
public/app/plugins/datasource/elasticsearch/partials/metric_agg.html
View file @
b97e7845
...
...
@@ -50,14 +50,24 @@
<div
class=
"gf-form offset-width-7"
ng-if=
"agg.type === 'moving_avg'"
>
<label
class=
"gf-form-label width-10"
>
Model
</label>
<input
type=
"text"
class=
"gf-form-input max-width-12"
ng-change=
"onChangeInternal()"
ng-model=
"agg.settings.model"
blur=
"onChange()"
spellcheck=
'false'
>
</div>
<metric-segment-model
property=
"agg.settings.model"
options=
"movingAvgModelTypes"
on-change=
"onChangeClearInternal()"
custom=
"false"
css-class=
"width-12"
></metric-segment-model
>
</div>
<div
class=
"gf-form offset-width-7"
ng-if=
"agg.type === 'moving_avg'"
>
<label
class=
"gf-form-label width-10"
>
Predict
</label>
<input
type=
"number"
class=
"gf-form-input max-width-12"
ng-model=
"agg.settings.predict"
ng-blur=
"onChangeInternal()"
spellcheck=
'false'
>
</div>
<div
class=
"gf-form offset-width-7"
ng-if=
"agg.type === 'moving_avg'"
ng-repeat=
"setting in modelSettings"
>
<label
class=
"gf-form-label width-10"
>
{{setting.text}}
</label>
<input
type=
"number"
class=
"gf-form-input max-width-12"
ng-model=
"agg.settings.settings[setting.value]"
ng-blur=
"onChangeInternal()"
spellcheck=
'false'
>
</div>
<gf-form-switch
ng-if=
"agg.type === 'moving_avg' && agg.settings.model == 'holt_winters'"
class=
"gf-form offset-width-7"
label=
"Pad"
label-class=
"width-10"
checked=
"agg.settings.settings.pad"
on-change=
"onChangeInternal()"
></gf-form-switch>
<gf-form-switch
ng-if=
"agg.type === 'moving_avg' && (agg.settings.model == 'ewma' || agg.settings.model == 'holt_winters' || agg.settings.model == 'holt')"
class=
"gf-form offset-width-7"
label=
"Minimize"
label-class=
"width-10"
checked=
"agg.settings.minimize"
on-change=
"onChangeInternal()"
></gf-form-switch>
<div
class=
"gf-form offset-width-7"
ng-if=
"agg.type === 'percentiles'"
>
<label
class=
"gf-form-label width-10"
>
Percentiles
</label>
<input
type=
"text"
class=
"gf-form-input max-width-12"
ng-model=
"agg.settings.percents"
array-join
ng-blur=
"onChange()"
></input>
...
...
public/app/plugins/datasource/elasticsearch/query_def.js
View file @
b97e7845
...
...
@@ -69,17 +69,44 @@ function (_) {
{
text
:
'1d'
,
value
:
'1d'
},
],
movingAvgModelOptions
:
[
{
text
:
'Simple'
,
value
:
'simple'
},
{
text
:
'Linear'
,
value
:
'linear'
},
{
text
:
'Exponentially Weighted'
,
value
:
'ewma'
},
{
text
:
'Holt Linear'
,
value
:
'holt'
},
{
text
:
'Holt Winters'
,
value
:
'holt_winters'
},
],
pipelineOptions
:
{
'moving_avg'
:
[
{
text
:
'window'
,
default
:
5
},
{
text
:
'model'
,
default
:
'simple'
},
{
text
:
'predict'
,
default
:
0
}
{
text
:
'minimize'
,
default
:
false
},
{
text
:
'predict'
,
default
:
undefined
}
],
'derivative'
:
[
{
text
:
'unit'
,
default
:
undefined
},
]
},
movingAvgModelSettings
:
{
'simple'
:
[],
'linear'
:
[],
'ewma'
:
[
{
text
:
"Alpha"
,
value
:
"alpha"
,
default
:
undefined
}],
'holt'
:
[
{
text
:
"Alpha"
,
value
:
"alpha"
,
default
:
undefined
},
{
text
:
"Beta"
,
value
:
"beta"
,
default
:
undefined
},
],
'holt_winters'
:
[
{
text
:
"Alpha"
,
value
:
"alpha"
,
default
:
undefined
},
{
text
:
"Beta"
,
value
:
"beta"
,
default
:
undefined
},
{
text
:
"Gamma"
,
value
:
"gamma"
,
default
:
undefined
},
{
text
:
"Period"
,
value
:
"period"
,
default
:
undefined
},
{
text
:
"Pad"
,
value
:
"pad"
,
default
:
undefined
,
isCheckbox
:
true
},
],
},
getMetricAggTypes
:
function
(
esVersion
)
{
return
_
.
filter
(
this
.
metricAggTypes
,
function
(
f
)
{
if
(
f
.
minVersion
)
{
...
...
@@ -119,6 +146,19 @@ function (_) {
return
result
;
},
getMovingAvgSettings
:
function
(
model
,
filtered
)
{
var
filteredResult
=
[];
if
(
filtered
)
{
_
.
each
(
this
.
movingAvgModelSettings
[
model
],
function
(
setting
)
{
if
(
!
(
setting
.
isCheckbox
))
{
filteredResult
.
push
(
setting
);
}
});
return
filteredResult
;
}
return
this
.
movingAvgModelSettings
[
model
];
},
getOrderByOptions
:
function
(
target
)
{
var
self
=
this
;
var
metricRefs
=
[];
...
...
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