Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[7.x] EMT-287: update schema with elastic agent id (#62252) #62361

Merged
merged 1 commit into from
Apr 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions x-pack/plugins/endpoint/common/generate_data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@ const OTHER_EVENT_CATEGORIES: EventInfo[] = [
];

interface HostInfo {
elastic: {
agent: {
id: string;
};
};
agent: {
version: string;
id: string;
Expand Down Expand Up @@ -116,6 +121,11 @@ export class EndpointDocGenerator {
version: this.randomVersion(),
id: this.seededUUIDv4(),
},
elastic: {
agent: {
id: this.seededUUIDv4(),
},
},
host: {
id: this.seededUUIDv4(),
hostname: this.randomHostname(),
Expand Down
5 changes: 5 additions & 0 deletions x-pack/plugins/endpoint/common/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,11 @@ export type HostMetadata = Immutable<{
event: {
created: number;
};
elastic: {
agent: {
id: string;
};
};
endpoint: {
policy: {
id: string;
Expand Down
20 changes: 20 additions & 0 deletions x-pack/plugins/endpoint/server/test_data/all_metadata_data.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@
"event" : {
"created" : "2020-01-23T21:56:55.336Z"
},
"elastic": {
"agent": {
"id": "56a75650-3c8a-4e4f-ac17-6dd729c650e2"
}
},
"endpoint" : {
"policy" : {
"id" : "C2A9093E-E289-4C0A-AA44-8C32A414FA7A"
Expand Down Expand Up @@ -71,6 +76,11 @@
"event" : {
"created" : "2020-01-23T21:56:55.336Z"
},
"elastic": {
"agent": {
"id": "56a75650-3c8a-4e4f-ac17-6dd729c650e2"
}
},
"endpoint" : {
"policy" : {
"id" : "C2A9093E-E289-4C0A-AA44-8C32A414FA7A"
Expand Down Expand Up @@ -111,6 +121,11 @@
"event" : {
"created" : "2020-01-23T21:56:55.336Z"
},
"elastic": {
"agent": {
"id": "c2d84d8f-d355-40de-8b54-5d318d4d1312"
}
},
"endpoint" : {
"policy" : {
"id" : "C2A9093E-E289-4C0A-AA44-8C32A414FA7A"
Expand Down Expand Up @@ -159,6 +174,11 @@
"event" : {
"created" : "2020-01-23T21:56:55.336Z"
},
"elastic": {
"agent": {
"id": "c2d84d8f-d355-40de-8b54-5d318d4d1312"
}
},
"endpoint" : {
"policy" : {
"id" : "C2A9093E-E289-4C0A-AA44-8C32A414FA7A"
Expand Down
21 changes: 21 additions & 0 deletions x-pack/test/api_integration/apis/endpoint/metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,27 @@ export default function({ getService }: FtrProviderContext) {
expect(body.request_page_index).to.eql(0);
});

it('metadata api should return the endpoint based on the elastic agent id', async () => {
const targetEndpointId = 'fc0ff548-feba-41b6-8367-65e8790d0eaf';
const targetElasticAgentId = '023fa40c-411d-4188-a941-4147bfadd095';
const { body } = await supertest
.post('/api/endpoint/metadata')
.set('kbn-xsrf', 'xxx')
.send({
filter: `elastic.agent.id:${targetElasticAgentId}`,
})
.expect(200);
expect(body.total).to.eql(1);
const resultHostId: string = body.hosts[0].host.id;
const resultElasticAgentId: string = body.hosts[0].elastic.agent.id;
expect(resultHostId).to.eql(targetEndpointId);
expect(resultElasticAgentId).to.eql(targetElasticAgentId);
expect(body.hosts[0].event.created).to.eql(1579881969541);
expect(body.hosts.length).to.eql(1);
expect(body.request_page_size).to.eql(10);
expect(body.request_page_index).to.eql(0);
});

it('metadata api should return all hosts when filter is empty string', async () => {
const { body } = await supertest
.post('/api/endpoint/metadata')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@
"version": "6.6.1",
"name" : "Elastic Endpoint"
},
"elastic": {
"agent": {
"id": "11488bae-880b-4e7b-8d28-aac2aa9de816"
}
},
"endpoint": {
"policy": {
"id": "C2A9093E-E289-4C0A-AA44-8C32A414FA7A"
Expand Down Expand Up @@ -54,6 +59,11 @@
"version": "6.0.0",
"name" : "Elastic Endpoint"
},
"elastic": {
"agent": {
"id": "92ac1ce0-e1f7-409e-8af6-f17e97b1fc71"
}
},
"endpoint": {
"policy": {
"id": "C2A9093E-E289-4C0A-AA44-8C32A414FA7A"
Expand Down Expand Up @@ -97,6 +107,11 @@
"version": "6.8.0",
"name" : "Elastic Endpoint"
},
"elastic": {
"agent": {
"id": "023fa40c-411d-4188-a941-4147bfadd095"
}
},
"endpoint": {
"policy": {
"id": "00000000-0000-0000-0000-000000000000"
Expand Down Expand Up @@ -138,6 +153,11 @@
"version": "6.6.1",
"name" : "Elastic Endpoint"
},
"elastic": {
"agent": {
"id": "11488bae-880b-4e7b-8d28-aac2aa9de816"
}
},
"endpoint": {
"policy": {
"id": "C2A9093E-E289-4C0A-AA44-8C32A414FA7A"
Expand Down Expand Up @@ -182,6 +202,11 @@
"version": "6.0.0",
"name" : "Elastic Endpoint"
},
"elastic": {
"agent": {
"id": "92ac1ce0-e1f7-409e-8af6-f17e97b1fc71"
}
},
"endpoint": {
"policy": {
"id": "C2A9093E-E289-4C0A-AA44-8C32A414FA7A"
Expand Down Expand Up @@ -224,6 +249,11 @@
"version": "6.8.0",
"name" : "Elastic Endpoint"
},
"elastic": {
"agent": {
"id": "023fa40c-411d-4188-a941-4147bfadd095"
}
},
"endpoint": {
"policy": {
"id": "00000000-0000-0000-0000-000000000000"
Expand Down Expand Up @@ -266,6 +296,11 @@
"version": "6.6.1",
"name" : "Elastic Endpoint"
},
"elastic": {
"agent": {
"id": "11488bae-880b-4e7b-8d28-aac2aa9de816"
}
},
"endpoint": {
"policy": {
"id": "00000000-0000-0000-0000-000000000000"
Expand Down Expand Up @@ -309,6 +344,11 @@
"version": "6.0.0",
"name" : "Elastic Endpoint"
},
"elastic": {
"agent": {
"id": "92ac1ce0-e1f7-409e-8af6-f17e97b1fc71"
}
},
"endpoint": {
"policy": {
"id": "C2A9093E-E289-4C0A-AA44-8C32A414FA7A"
Expand Down Expand Up @@ -351,6 +391,11 @@
"version": "6.8.0",
"name" : "Elastic Endpoint"
},
"elastic": {
"agent": {
"id": "023fa40c-411d-4188-a941-4147bfadd095"
}
},
"endpoint": {
"policy": {
"id": "00000000-0000-0000-0000-000000000000"
Expand Down Expand Up @@ -379,4 +424,4 @@
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,23 @@
"@timestamp": {
"type": "long"
},
"elastic": {
"properties": {
"agent": {
"properties": {
"id": {
"fields": {
"keyword": {
"ignore_above": 256,
"type": "keyword"
}
},
"type": "text"
}
}
}
}
},
"agent": {
"properties": {
"id": {
Expand Down Expand Up @@ -153,4 +170,4 @@
}
}
}
}
}