Skip to content

Commit

Permalink
[data views] Time series counter fields are not aggregatable (elastic…
Browse files Browse the repository at this point in the history
…#150954)

## Summary

Part of elastic/elasticsearch#93539

Currently, field caps reports time series counter fields as aggregatable
as they support several aggs. Unfortunately, they don't support ALL aggs
so its possible create an unsupported agg in Kibana which results in an
ES error. In order to prevent this, the data view field list will report
all time series counter fields as non-aggregatable until support for
specific aggs can be provided throughout Kibana.

To test - Create a TSDS with a time series counter field and verify that
its not aggregatable in data view management. Also check other apps to
make sure the field isn't available for aggregations.
https://www.elastic.co/guide/en/elasticsearch/reference/master/set-up-tsds.html

### Checklist

Delete any items that are not applicable to this PR.

- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
  • Loading branch information
mattkime authored and justinkambic committed Feb 23, 2023
1 parent f0e1ed6 commit 57a84ca
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,15 @@
"searchable": true,
"aggregatable": true
}
},
"hits": {
"int": {
"type": "integer",
"metadata_field": false,
"searchable": true,
"aggregatable": true,
"time_series_metric": "counter"
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ describe('index_patterns/field_capabilities/field_caps_response', () => {
describe('conflicts', () => {
it('returns a field for each in response, no filtering', () => {
const fields = readFieldCapsResponse(esResponse);
expect(fields).toHaveLength(24);
expect(fields).toHaveLength(25);
});

it(
Expand Down Expand Up @@ -164,6 +164,11 @@ describe('index_patterns/field_capabilities/field_caps_response', () => {
const child = fields.find((f) => f.name === 'object_parent.child');
expect(child).not.toHaveProperty('subType');
});
it('reports time series metrics counter as aggregatable: false', () => {
const fields = readFieldCapsResponse(esResponse);
const counter = fields.find((f) => f.name === 'hits');
expect(counter).toHaveProperty('aggregatable', false);
});
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,17 @@ export function readFieldCapsResponse(
);
});

const isAggregatable = types.some((type) => {
return (
!!capsByType[type].aggregatable ||
(!!capsByType[type].non_aggregatable_indices &&
capsByType[type].non_aggregatable_indices!.length > 0)
);
});

const timeSeriesMetricProp = uniq(types.map((t) => capsByType[t].time_series_metric));
const isTimeSeriesCounter = !!timeSeriesMetricProp.find((item) => item === 'counter');

const isAggregatable =
types.some((type) => {
return (
!!capsByType[type].aggregatable ||
(!!capsByType[type].non_aggregatable_indices &&
capsByType[type].non_aggregatable_indices!.length > 0)
);
}) && !isTimeSeriesCounter;

// If there are multiple types but they all resolve to the same kibana type
// ignore the conflict and carry on (my wayward son)
Expand Down

0 comments on commit 57a84ca

Please sign in to comment.