fix name without a category or if field end with .text (#78655)

This commit is contained in:
Xavier Mouligneau 2020-09-28 15:38:16 -04:00 committed by GitHub
parent 3f4e9f4bc1
commit 9017d50ffe
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 109 additions and 38 deletions

View file

@ -136,6 +136,29 @@ describe('Index Fields', () => {
readFromDocValues: false,
esTypes: [],
},
{
aggregatable: true,
category: 'agent',
esTypes: [],
indexes: ['auditbeat'],
name: 'agent.user.name',
readFromDocValues: false,
searchable: true,
type: 'string',
},
{
aggregatable: true,
category: 'client',
description:
'Unique number allocated to the autonomous system. The autonomous system number (ASN) uniquely identifies each network on the Internet.',
esTypes: [],
example: 15169,
indexes: ['auditbeat'],
name: 'client.as.number.text',
readFromDocValues: false,
searchable: true,
type: 'string',
},
])
);
});
@ -149,6 +172,7 @@ describe('Index Fields', () => {
);
expect(fields).toEqual([
{
category: 'base',
description: 'Each document has an _id that uniquely identifies it',
example: 'Y-6TfmcB0WOhS6qyMv3s',
name: '_id',
@ -156,11 +180,11 @@ describe('Index Fields', () => {
searchable: true,
aggregatable: false,
readFromDocValues: false,
category: 'base',
indexes: ['auditbeat'],
esTypes: [],
indexes: ['auditbeat'],
},
{
category: 'base',
description:
'An index is like a database in a relational database. It has a mapping which defines multiple types. An index is a logical namespace which maps to one or more primary shards and can have zero or more replica shards.',
example: 'auditbeat-8.0.0-2019.02.19-000001',
@ -169,11 +193,11 @@ describe('Index Fields', () => {
searchable: true,
aggregatable: true,
readFromDocValues: false,
category: 'base',
indexes: ['auditbeat'],
esTypes: [],
indexes: ['auditbeat'],
},
{
category: 'base',
description:
'Date/time when the event originated. This is the date/time extracted from the event, typically representing when the event was generated by the source. If the event source has no original timestamp, this value is typically populated by the first time the event was received by the pipeline. Required field for all events.',
example: '2016-05-23T08:05:34.853Z',
@ -181,12 +205,12 @@ describe('Index Fields', () => {
type: 'date',
searchable: true,
aggregatable: true,
category: 'base',
indexes: ['auditbeat'],
readFromDocValues: true,
esTypes: [],
indexes: ['auditbeat'],
},
{
category: 'agent',
description:
'Ephemeral identifier of this agent (if one exists). This id normally changes across restarts, but `agent.id` does not.',
example: '8a4f500f',
@ -194,12 +218,12 @@ describe('Index Fields', () => {
type: 'string',
searchable: true,
aggregatable: true,
category: 'agent',
indexes: ['auditbeat'],
readFromDocValues: false,
esTypes: [],
indexes: ['auditbeat'],
},
{
category: 'agent',
description:
'Custom name of the agent. This is a name that can be given to an agent. This can be helpful if for example two Filebeat instances are running on the same host but a human readable separation is needed on which Filebeat instance data is coming from. If no name is given, the name is often left empty.',
example: 'foo',
@ -207,12 +231,12 @@ describe('Index Fields', () => {
type: 'string',
searchable: true,
aggregatable: true,
category: 'agent',
indexes: ['auditbeat'],
readFromDocValues: false,
esTypes: [],
indexes: ['auditbeat'],
},
{
category: 'agent',
description:
'Type of the agent. The agent type stays always the same and should be given by the agent used. In case of Filebeat the agent would always be Filebeat also if two Filebeat instances are run on the same machine.',
example: 'filebeat',
@ -220,36 +244,59 @@ describe('Index Fields', () => {
type: 'string',
searchable: true,
aggregatable: true,
category: 'agent',
indexes: ['auditbeat'],
readFromDocValues: false,
esTypes: [],
indexes: ['auditbeat'],
},
{
category: 'agent',
description: 'Version of the agent.',
example: '6.0.0-rc2',
name: 'agent.version',
type: 'string',
searchable: true,
aggregatable: true,
category: 'agent',
indexes: ['auditbeat'],
readFromDocValues: false,
esTypes: [],
indexes: ['auditbeat'],
},
{
category: 'agent',
name: 'agent.user.name',
searchable: true,
type: 'string',
aggregatable: true,
readFromDocValues: false,
esTypes: [],
indexes: ['auditbeat'],
},
{
category: 'client',
description:
'Unique number allocated to the autonomous system. The autonomous system number (ASN) uniquely identifies each network on the Internet.',
example: 15169,
name: 'client.as.number.text',
type: 'string',
searchable: true,
aggregatable: true,
readFromDocValues: false,
esTypes: [],
indexes: ['auditbeat'],
},
{
category: 'base',
description: 'Each document has an _id that uniquely identifies it',
example: 'Y-6TfmcB0WOhS6qyMv3s',
name: '_id',
type: 'string',
searchable: true,
aggregatable: false,
category: 'base',
indexes: ['filebeat'],
readFromDocValues: false,
esTypes: [],
indexes: ['filebeat'],
},
{
category: 'base',
description:
'An index is like a database in a relational database. It has a mapping which defines multiple types. An index is a logical namespace which maps to one or more primary shards and can have zero or more replica shards.',
example: 'auditbeat-8.0.0-2019.02.19-000001',
@ -257,12 +304,12 @@ describe('Index Fields', () => {
type: 'string',
searchable: true,
aggregatable: true,
category: 'base',
indexes: ['filebeat'],
readFromDocValues: false,
esTypes: [],
indexes: ['filebeat'],
},
{
category: 'base',
description:
'Date/time when the event originated. This is the date/time extracted from the event, typically representing when the event was generated by the source. If the event source has no original timestamp, this value is typically populated by the first time the event was received by the pipeline. Required field for all events.',
example: '2016-05-23T08:05:34.853Z',
@ -270,24 +317,24 @@ describe('Index Fields', () => {
type: 'date',
searchable: true,
aggregatable: true,
category: 'base',
indexes: ['filebeat'],
readFromDocValues: true,
esTypes: [],
indexes: ['filebeat'],
},
{
category: 'agent',
description:
'Deprecated - use agent.name or agent.id to identify an agent. Hostname of the agent. ',
name: 'agent.hostname',
searchable: true,
type: 'string',
searchable: true,
aggregatable: true,
category: 'agent',
indexes: ['filebeat'],
readFromDocValues: false,
esTypes: [],
indexes: ['filebeat'],
},
{
category: 'agent',
description:
'Custom name of the agent. This is a name that can be given to an agent. This can be helpful if for example two Filebeat instances are running on the same host but a human readable separation is needed on which Filebeat instance data is coming from. If no name is given, the name is often left empty.',
example: 'foo',
@ -295,36 +342,36 @@ describe('Index Fields', () => {
type: 'string',
searchable: true,
aggregatable: true,
category: 'agent',
indexes: ['filebeat'],
readFromDocValues: false,
esTypes: [],
indexes: ['filebeat'],
},
{
category: 'agent',
description: 'Version of the agent.',
example: '6.0.0-rc2',
name: 'agent.version',
type: 'string',
searchable: true,
aggregatable: true,
category: 'agent',
indexes: ['filebeat'],
readFromDocValues: false,
esTypes: [],
indexes: ['filebeat'],
},
{
category: 'base',
description: 'Each document has an _id that uniquely identifies it',
example: 'Y-6TfmcB0WOhS6qyMv3s',
name: '_id',
type: 'string',
searchable: true,
aggregatable: false,
category: 'base',
indexes: ['packetbeat'],
readFromDocValues: false,
esTypes: [],
indexes: ['packetbeat'],
},
{
category: 'base',
description:
'An index is like a database in a relational database. It has a mapping which defines multiple types. An index is a logical namespace which maps to one or more primary shards and can have zero or more replica shards.',
example: 'auditbeat-8.0.0-2019.02.19-000001',
@ -332,12 +379,12 @@ describe('Index Fields', () => {
type: 'string',
searchable: true,
aggregatable: true,
category: 'base',
indexes: ['packetbeat'],
readFromDocValues: false,
esTypes: [],
indexes: ['packetbeat'],
},
{
category: 'base',
description:
'Date/time when the event originated. This is the date/time extracted from the event, typically representing when the event was generated by the source. If the event source has no original timestamp, this value is typically populated by the first time the event was received by the pipeline. Required field for all events.',
example: '2016-05-23T08:05:34.853Z',
@ -345,12 +392,12 @@ describe('Index Fields', () => {
type: 'date',
searchable: true,
aggregatable: true,
category: 'base',
indexes: ['packetbeat'],
readFromDocValues: true,
esTypes: [],
indexes: ['packetbeat'],
},
{
category: 'agent',
description:
'Unique identifier of this agent (if one exists). Example: For Beats this would be beat.id.',
example: '8a4f500d',
@ -358,12 +405,12 @@ describe('Index Fields', () => {
type: 'string',
searchable: true,
aggregatable: true,
category: 'agent',
indexes: ['packetbeat'],
readFromDocValues: false,
esTypes: [],
indexes: ['packetbeat'],
},
{
category: 'agent',
description:
'Type of the agent. The agent type stays always the same and should be given by the agent used. In case of Filebeat the agent would always be Filebeat also if two Filebeat instances are run on the same machine.',
example: 'filebeat',
@ -371,10 +418,9 @@ describe('Index Fields', () => {
type: 'string',
searchable: true,
aggregatable: true,
category: 'agent',
indexes: ['packetbeat'],
readFromDocValues: false,
esTypes: [],
indexes: ['packetbeat'],
},
]);
});

View file

@ -121,8 +121,17 @@ export const createFieldItem = (
indexesAliasIdx: number
): IndexField => {
const alias = indexesAlias[indexesAliasIdx];
const splitIndexName = index.name.split('.');
const indexName =
splitIndexName[splitIndexName.length - 1] === 'text'
? splitIndexName.slice(0, splitIndexName.length - 1).join('.')
: index.name;
const beatIndex = fieldsBeat[indexName] ?? {};
if (isEmpty(beatIndex.category)) {
beatIndex.category = splitIndexName[0];
}
return {
...(fieldsBeat[index.name] ?? {}),
...beatIndex,
...index,
indexes: [alias],
};

View file

@ -48,6 +48,22 @@ export const mockAuditbeatIndexField: FieldDescriptor[] = [
readFromDocValues: false,
esTypes: [],
},
{
name: 'agent.user.name',
searchable: true,
type: 'string',
aggregatable: true,
readFromDocValues: false,
esTypes: [],
},
{
name: 'client.as.number.text',
searchable: true,
type: 'string',
aggregatable: true,
readFromDocValues: false,
esTypes: [],
},
];
export const mockFilebeatIndexField: FieldDescriptor[] = [