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
dd7a1393
Commit
dd7a1393
authored
Dec 08, 2015
by
Carl Bergquist
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adds null check for response parser
parent
8ad10149
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
34 additions
and
47 deletions
+34
-47
public/app/plugins/datasource/elasticsearch/elastic_response.js
+6
-2
public/app/plugins/datasource/elasticsearch/metric_agg.js
+6
-12
public/app/plugins/datasource/elasticsearch/partials/metricAgg.html
+1
-1
public/app/plugins/datasource/elasticsearch/query_builder.js
+16
-24
public/app/plugins/datasource/elasticsearch/query_def.js
+1
-1
public/app/plugins/datasource/elasticsearch/specs/query_builder_specs.ts
+4
-7
No files found.
public/app/plugins/datasource/elasticsearch/elastic_response.js
View file @
dd7a1393
...
...
@@ -76,8 +76,12 @@ function (_, queryDef) {
newSeries
=
{
datapoints
:
[],
metric
:
metric
.
type
,
field
:
metric
.
field
,
props
:
props
};
for
(
i
=
0
;
i
<
esAgg
.
buckets
.
length
;
i
++
)
{
bucket
=
esAgg
.
buckets
[
i
];
value
=
bucket
[
metric
.
id
].
value
;
newSeries
.
datapoints
.
push
([
value
,
bucket
.
key
]);
value
=
bucket
[
metric
.
id
];
if
(
value
!==
undefined
)
{
newSeries
.
datapoints
.
push
([
value
.
value
,
bucket
.
key
]);
}
}
seriesList
.
push
(
newSeries
);
break
;
...
...
public/app/plugins/datasource/elasticsearch/metric_agg.js
View file @
dd7a1393
...
...
@@ -35,6 +35,10 @@ function (angular, _, queryDef) {
}
switch
(
$scope
.
agg
.
type
)
{
case
'moving_avg'
:
{
$scope
.
agg
.
aggregation
=
$scope
.
agg
.
aggregation
||
'sum'
;
break
;
}
case
'percentiles'
:
{
$scope
.
agg
.
settings
.
percents
=
$scope
.
agg
.
settings
.
percents
||
[
25
,
50
,
75
,
95
,
99
];
$scope
.
settingsLinkText
=
'values: '
+
$scope
.
agg
.
settings
.
percents
.
join
(
','
);
...
...
@@ -79,19 +83,9 @@ function (angular, _, queryDef) {
};
$scope
.
getMetrics
=
function
()
{
console
.
log
(
$scope
.
target
.
metrics
);
var
mets
=
_
.
filter
(
$scope
.
target
.
metrics
,
function
(
x
)
{
return
x
.
type
!==
'moving_avg'
;
});
mets
=
_
.
map
(
mets
,
function
(
m
)
{
return
{
text
:
m
.
type
,
type
:
m
.
id
};
});
console
.
log
(
mets
);
var
aggs
=
[{
text
:
'Sum'
,
type
:
'sum'
},
{
text
:
'Average'
,
type
:
'avg'
}];
return
$q
.
when
(
met
s
)
return
$q
.
when
(
agg
s
)
.
then
(
uiSegmentSrv
.
transformToSegments
(
false
));
};
...
...
public/app/plugins/datasource/elasticsearch/partials/metricAgg.html
View file @
dd7a1393
...
...
@@ -10,7 +10,7 @@
<metric-segment-model
property=
"agg.field"
get-options=
"getFieldsInternal()"
on-change=
"onChange()"
css-class=
"tight-form-item-xxlarge"
></metric-segment-model>
</li>
<li
ng-if=
"aggDef.requiresBucketsPath"
>
<metric-segment-model
property=
"agg.
field
"
get-options=
"getMetrics()"
on-change=
"onChange()"
css-class=
"tight-form-item-xxlarge"
></metric-segment-model>
<metric-segment-model
property=
"agg.
aggregation
"
get-options=
"getMetrics()"
on-change=
"onChange()"
css-class=
"tight-form-item-xxlarge"
></metric-segment-model>
</li>
<li
class=
"tight-form-item last"
ng-if=
"settingsLinkText"
>
<a
ng-click=
"toggleOptions()"
>
{{settingsLinkText}}
</a>
...
...
public/app/plugins/datasource/elasticsearch/query_builder.js
View file @
dd7a1393
...
...
@@ -167,36 +167,28 @@ function () {
continue
;
}
var
metricAgg
=
{
field
:
metric
.
field
};
var
aggField
=
{};
var
metricAgg
=
null
;
if
(
metric
.
type
===
'moving_avg'
)
{
var
subBucket
=
metric
.
id
+
"_mavg"
;
var
af
=
{};
af
[
metric
.
aggregation
]
=
{
field
:
metric
.
field
};
nestedAggs
.
aggs
[
subBucket
]
=
af
;
metricAgg
=
{
buckets_path
:
subBucket
};
}
else
{
metricAgg
=
{
field
:
metric
.
field
};
}
for
(
var
prop
in
metric
.
settings
)
{
if
(
metric
.
settings
.
hasOwnProperty
(
prop
)
&&
metric
.
settings
[
prop
]
!==
null
)
{
metricAgg
[
prop
]
=
metric
.
settings
[
prop
];
}
}
var
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
;
}
aggField
[
metric
.
type
]
=
metricAgg
;
nestedAggs
.
aggs
[
metric
.
id
]
=
aggField
;
}
return
query
;
...
...
public/app/plugins/datasource/elasticsearch/query_def.js
View file @
dd7a1393
...
...
@@ -13,7 +13,7 @@ function (_) {
{
text
:
"Min"
,
value
:
'min'
,
requiresField
:
true
},
{
text
:
"Extended Stats"
,
value
:
'extended_stats'
,
requiresField
:
true
},
{
text
:
"Percentiles"
,
value
:
'percentiles'
,
requiresField
:
true
},
{
text
:
"Moving Avg"
,
value
:
'moving_avg'
,
requiresField
:
fals
e
,
requiresBucketsPath
:
true
},
{
text
:
"Moving Avg"
,
value
:
'moving_avg'
,
requiresField
:
tru
e
,
requiresBucketsPath
:
true
},
{
text
:
"Unique Count"
,
value
:
"cardinality"
,
requiresField
:
true
},
{
text
:
"Raw Document"
,
value
:
"raw_document"
,
requiresField
:
false
}
],
...
...
public/app/plugins/datasource/elasticsearch/specs/query_builder_specs.ts
View file @
dd7a1393
...
...
@@ -159,14 +159,10 @@ describe('ElasticQueryBuilder', function() {
var
query
=
builder
.
build
({
metrics
:
[
{
id
:
'1'
,
type
:
'sum'
,
field
:
'@value'
,
},
{
id
:
'2'
,
type
:
'moving_avg'
,
field
:
'sum'
field
:
'@value'
,
aggregation
:
'sum'
}
],
bucketAggs
:
[
...
...
@@ -175,8 +171,9 @@ describe('ElasticQueryBuilder', function() {
});
var
firstLevel
=
query
.
aggs
[
"3"
];
console
.
log
(
JSON
.
stringify
(
query
));
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
"
);
expect
(
firstLevel
.
aggs
[
"2"
].
moving_avg
.
buckets_path
).
to
.
be
(
"
99
"
);
});
});
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