Skip to content

Commit

Permalink
[Ingest Manager] Adjust dataset aggs to use datastream fields instead (
Browse files Browse the repository at this point in the history
…#74342) (#74356)

Elastic Agent and Elasticsearch are switching over from using dataset.* to datastream.*. This adjust the aggregation on the dataset page to get the datastreams.

For this to work properly, the most recent version of Elasticsearch 7.9 must be used and is pending updates on all the packages to ship also the datastream fields, see elastic/integrations#213
  • Loading branch information
skh authored Aug 5, 2020
1 parent 13c68af commit c724824
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ export const getListHandler: RequestHandler = async (context, request, response)
must: [
{
exists: {
field: 'dataset.namespace',
field: 'data_stream.namespace',
},
},
{
exists: {
field: 'dataset.name',
field: 'data_stream.dataset',
},
},
],
Expand All @@ -54,19 +54,19 @@ export const getListHandler: RequestHandler = async (context, request, response)
aggs: {
dataset: {
terms: {
field: 'dataset.name',
field: 'data_stream.dataset',
size: 1,
},
},
namespace: {
terms: {
field: 'dataset.namespace',
field: 'data_stream.namespace',
size: 1,
},
},
type: {
terms: {
field: 'dataset.type',
field: 'data_stream.type',
size: 1,
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -393,14 +393,14 @@ const updateExistingIndex = async ({
// are added in https://github.com/elastic/kibana/issues/66551. namespace value we will continue
// to skip updating and assume the value in the index mapping is correct
delete mappings.properties.stream;
delete mappings.properties.dataset;
delete mappings.properties.data_stream;

// get the dataset values from the index template to compose data stream name
// get the data_stream values from the index template to compose data stream name
const indexMappings = await getIndexMappings(indexName, callCluster);
const dataset = indexMappings[indexName].mappings.properties.dataset.properties;
if (!dataset.type.value || !dataset.name.value || !dataset.namespace.value)
throw new Error(`dataset values are missing from the index template ${indexName}`);
const dataStreamName = `${dataset.type.value}-${dataset.name.value}-${dataset.namespace.value}`;
const dataStream = indexMappings[indexName].mappings.properties.data_stream.properties;
if (!dataStream.type.value || !dataStream.dataset.value || !dataStream.namespace.value)
throw new Error(`data_stream values are missing from the index template ${indexName}`);
const dataStreamName = `${dataStream.type.value}-${dataStream.dataset.value}-${dataStream.namespace.value}`;

// try to update the mappings first
try {
Expand Down

0 comments on commit c724824

Please sign in to comment.