mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
fix(Elasticsearch): fix for alias patterns that refers to term that is numeric zero, fixes #7323
This commit is contained in:
@@ -21,6 +21,7 @@
|
||||
* **Dashboard**: Avoid duplicate data in dashboard json for panels with alerts [#7256](https://github.com/grafana/grafana/pull/7256)
|
||||
* **Alertlist**: Only show scrollbar when required [#7269](https://github.com/grafana/grafana/issues/7269)
|
||||
* **SMTP**: Set LocalName to hostname [#7223](https://github.com/grafana/grafana/issues/7223)
|
||||
* **Elasticsearch**: Fix for alias patterns for terms that had numeric zero, fixes [#7323](https://github.com/grafana/grafana/issues/7323)
|
||||
|
||||
# 4.1.2 (unreleased)
|
||||
|
||||
|
||||
@@ -166,7 +166,7 @@ function (_, queryDef) {
|
||||
for (var nameIndex in esAgg.buckets) {
|
||||
bucket = esAgg.buckets[nameIndex];
|
||||
props = _.clone(props);
|
||||
if (bucket.key) {
|
||||
if (bucket.key !== void 0) {
|
||||
props[aggDef.field] = bucket.key;
|
||||
} else {
|
||||
props["filter"] = nameIndex;
|
||||
@@ -199,7 +199,7 @@ function (_, queryDef) {
|
||||
var group = g1 || g2;
|
||||
|
||||
if (group.indexOf('term ') === 0) { return series.props[group.substring(5)]; }
|
||||
if (series.props[group]) { return series.props[group]; }
|
||||
if (series.props[group] !== void 0) { return series.props[group]; }
|
||||
if (group === 'metric') { return metricName; }
|
||||
if (group === 'field') { return series.field; }
|
||||
|
||||
|
||||
@@ -302,7 +302,7 @@ describe('ElasticResponse', function() {
|
||||
targets = [{
|
||||
refId: 'A',
|
||||
metrics: [{type: 'count', id: '1'}],
|
||||
alias: '{{term @host}} {{metric}} and!',
|
||||
alias: '{{term @host}} {{metric}} and {{not_exist}} {{@host}}',
|
||||
bucketAggs: [
|
||||
{type: 'terms', field: '@host', id: '2'},
|
||||
{type: 'date_histogram', field: '@timestamp', id: '3'}
|
||||
@@ -333,6 +333,16 @@ describe('ElasticResponse', function() {
|
||||
doc_count: 10,
|
||||
key: 'server2',
|
||||
},
|
||||
{
|
||||
"3": {
|
||||
buckets: [
|
||||
{doc_count: 2, key: 1000},
|
||||
{doc_count: 8, key: 2000}
|
||||
]
|
||||
},
|
||||
doc_count: 10,
|
||||
key: 0,
|
||||
},
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -343,10 +353,11 @@ describe('ElasticResponse', function() {
|
||||
});
|
||||
|
||||
it('should return 2 series', function() {
|
||||
expect(result.data.length).to.be(2);
|
||||
expect(result.data.length).to.be(3);
|
||||
expect(result.data[0].datapoints.length).to.be(2);
|
||||
expect(result.data[0].target).to.be('server1 Count and!');
|
||||
expect(result.data[1].target).to.be('server2 Count and!');
|
||||
expect(result.data[0].target).to.be('server1 Count and {{not_exist}} server1');
|
||||
expect(result.data[1].target).to.be('server2 Count and {{not_exist}} server2');
|
||||
expect(result.data[2].target).to.be('0 Count and {{not_exist}} 0');
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user