Skip to content

Commit

Permalink
[APM] Fixes support for APM data streams in Security and Timelines UIs (
Browse files Browse the repository at this point in the history
elastic#105334)

* addes support for apm data streams (traces-apm*) to timelines

* [APM] Adds support for apm data streams (traces-apm*) to security solution (elastic#94702)

* fix unit tests

* reverting prepackaged_rules changes to be bumped later
# Conflicts:
#	x-pack/plugins/timelines/server/search_strategy/index_fields/index.test.ts
  • Loading branch information
ogupte committed Jul 14, 2021
1 parent 2dacdae commit be2ef68
Show file tree
Hide file tree
Showing 55 changed files with 171 additions and 21 deletions.
1 change: 1 addition & 0 deletions x-pack/plugins/security_solution/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ export const APP_EVENT_FILTERS_PATH = `${APP_PATH}${EVENT_FILTERS_PATH}`;
/** The comma-delimited list of Elasticsearch indices from which the SIEM app collects events */
export const DEFAULT_INDEX_PATTERN = [
'apm-*-transaction*',
'traces-apm*',
'auditbeat-*',
'endgame-*',
'filebeat-*',
Expand Down
1 change: 1 addition & 0 deletions x-pack/plugins/security_solution/cypress/objects/rule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ export interface MachineLearningRule {

export const getIndexPatterns = (): string[] => [
'apm-*-transaction*',
'traces-apm*',
'auditbeat-*',
'endgame-*',
'filebeat-*',
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,7 @@ export const mockAlertDetailsData = [
field: 'signal.rule.index',
values: [
'apm-*-transaction*',
'traces-apm*',
'auditbeat-*',
'endgame-*',
'filebeat-*',
Expand All @@ -415,6 +416,7 @@ export const mockAlertDetailsData = [
],
originalValue: [
'apm-*-transaction*',
'traces-apm*',
'auditbeat-*',
'endgame-*',
'filebeat-*',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const mockOptions = [
{ label: 'filebeat-*', value: 'filebeat-*' },
{ label: 'logs-*', value: 'logs-*' },
{ label: 'packetbeat-*', value: 'packetbeat-*' },
{ label: 'traces-apm*', value: 'traces-apm*' },
{ label: 'winlogbeat-*', value: 'winlogbeat-*' },
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ describe('Sourcerer selectors', () => {
'filebeat-*',
'logs-*',
'packetbeat-*',
'traces-apm*',
'winlogbeat-*',
'-*elastic-cloud-logs-*',
]);
Expand All @@ -42,6 +43,7 @@ describe('Sourcerer selectors', () => {
'endgame-*',
'filebeat-*',
'packetbeat-*',
'traces-apm*',
'winlogbeat-*',
]);
});
Expand All @@ -64,6 +66,7 @@ describe('Sourcerer selectors', () => {
'filebeat-*',
'logs-endpoint.event-*',
'packetbeat-*',
'traces-apm*',
'winlogbeat-*',
]);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ export const alertsMock: AlertSearchResponse<unknown, unknown> = {
immutable: false,
index: [
'apm-*-transaction*',
'traces-apm*',
'auditbeat-*',
'endgame-*',
'filebeat-*',
Expand Down Expand Up @@ -414,6 +415,7 @@ export const alertsMock: AlertSearchResponse<unknown, unknown> = {
immutable: false,
index: [
'apm-*-transaction*',
'traces-apm*',
'auditbeat-*',
'endgame-*',
'filebeat-*',
Expand Down Expand Up @@ -619,6 +621,7 @@ export const alertsMock: AlertSearchResponse<unknown, unknown> = {
immutable: false,
index: [
'apm-*-transaction*',
'traces-apm*',
'auditbeat-*',
'endgame-*',
'filebeat-*',
Expand Down Expand Up @@ -822,6 +825,7 @@ export const alertsMock: AlertSearchResponse<unknown, unknown> = {
immutable: false,
index: [
'apm-*-transaction*',
'traces-apm*',
'auditbeat-*',
'endgame-*',
'filebeat-*',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export const savedRuleMock: Rule = {
id: '12345678987654321',
index: [
'apm-*-transaction*',
'traces-apm*',
'auditbeat-*',
'endgame-*',
'filebeat-*',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ describe('useRule', () => {
immutable: false,
index: [
'apm-*-transaction*',
'traces-apm*',
'auditbeat-*',
'endgame-*',
'filebeat-*',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ const testRule: Rule = {
immutable: false,
index: [
'apm-*-transaction*',
'traces-apm*',
'auditbeat-*',
'endgame-*',
'filebeat-*',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ describe('useRuleWithFallback', () => {
"immutable": false,
"index": Array [
"apm-*-transaction*",
"traces-apm*",
"auditbeat-*",
"endgame-*",
"filebeat-*",
Expand Down Expand Up @@ -125,6 +126,7 @@ describe('useRuleWithFallback', () => {
"immutable": false,
"index": Array [
"apm-*-transaction*",
"traces-apm*",
"auditbeat-*",
"endgame-*",
"filebeat-*",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export const mockIndexPatternIds: IndexPatternMapping[] = [

export const mockAPMIndexPatternIds: IndexPatternMapping[] = [
{ title: 'apm-*', id: '8c7323ac-97ad-4b53-ac0a-40f8f691a918' },
{ title: 'traces-apm*,logs-apm*,metrics-apm*,apm-*', id: '8c7323ac-97ad-4b53-ac0a-40f8f691a918' },
];

export const mockSourceLayer = {
Expand Down Expand Up @@ -183,6 +184,11 @@ export const mockClientLayer = {
joins: [],
};

const mockApmDataStreamClientLayer = {
...mockClientLayer,
label: 'traces-apm*,logs-apm*,metrics-apm*,apm-* | Client Point',
};

export const mockServerLayer = {
sourceDescriptor: {
id: 'uuid.v4()',
Expand Down Expand Up @@ -238,6 +244,11 @@ export const mockServerLayer = {
query: { query: '', language: 'kuery' },
};

const mockApmDataStreamServerLayer = {
...mockServerLayer,
label: 'traces-apm*,logs-apm*,metrics-apm*,apm-* | Server Point',
};

export const mockLineLayer = {
sourceDescriptor: {
type: 'ES_PEW_PEW',
Expand Down Expand Up @@ -365,6 +376,10 @@ export const mockClientServerLineLayer = {
type: 'VECTOR',
query: { query: '', language: 'kuery' },
};
const mockApmDataStreamClientServerLineLayer = {
...mockClientServerLineLayer,
label: 'traces-apm*,logs-apm*,metrics-apm*,apm-* | Line',
};

export const mockLayerList = [
{
Expand Down Expand Up @@ -421,6 +436,9 @@ export const mockLayerListMixed = [
mockClientServerLineLayer,
mockServerLayer,
mockClientLayer,
mockApmDataStreamClientServerLineLayer,
mockApmDataStreamServerLayer,
mockApmDataStreamClientLayer,
];

export const mockAPMIndexPattern: IndexPatternSavedObject = {
Expand Down Expand Up @@ -468,6 +486,15 @@ export const mockAPMTransactionIndexPattern: IndexPatternSavedObject = {
},
};

export const mockAPMTracesDataStreamIndexPattern: IndexPatternSavedObject = {
id: 'traces-apm*',
type: 'index-pattern',
_version: 'abc',
attributes: {
title: 'traces-apm*',
},
};

export const mockGlobIndexPattern: IndexPatternSavedObject = {
id: '*',
type: 'index-pattern',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
mockAPMIndexPattern,
mockAPMRegexIndexPattern,
mockAPMTransactionIndexPattern,
mockAPMTracesDataStreamIndexPattern,
mockAuditbeatIndexPattern,
mockCCSGlobIndexPattern,
mockCommaFilebeatAuditbeatCCSGlobIndexPattern,
Expand Down Expand Up @@ -69,6 +70,7 @@ describe('embedded_map_helpers', () => {
describe('findMatchingIndexPatterns', () => {
const siemDefaultIndices = [
'apm-*-transaction*',
'traces-apm*',
'auditbeat-*',
'endgame-*',
'filebeat-*',
Expand Down Expand Up @@ -102,11 +104,16 @@ describe('embedded_map_helpers', () => {

test('finds exact glob-matched index patterns ', () => {
const matchingIndexPatterns = findMatchingIndexPatterns({
kibanaIndexPatterns: [mockAPMTransactionIndexPattern, mockFilebeatIndexPattern],
kibanaIndexPatterns: [
mockAPMTransactionIndexPattern,
mockAPMTracesDataStreamIndexPattern,
mockFilebeatIndexPattern,
],
siemDefaultIndices,
});
expect(matchingIndexPatterns).toEqual([
mockAPMTransactionIndexPattern,
mockAPMTracesDataStreamIndexPattern,
mockFilebeatIndexPattern,
]);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,21 @@ export const SUM_OF_DESTINATION_BYTES = 'sum_of_destination.bytes';
export const SUM_OF_CLIENT_BYTES = 'sum_of_client.bytes';
export const SUM_OF_SERVER_BYTES = 'sum_of_server.bytes';

const APM_LAYER_FIELD_MAPPING = {
source: {
metricField: 'client.bytes',
geoField: 'client.geo.location',
tooltipProperties: Object.keys(clientFieldMappings),
label: i18n.CLIENT_LAYER,
},
destination: {
metricField: 'server.bytes',
geoField: 'server.geo.location',
tooltipProperties: Object.keys(serverFieldMappings),
label: i18n.SERVER_LAYER,
},
};

// Mapping to fields for creating specific layers for a given index pattern
// e.g. The apm-* index pattern needs layers for client/server instead of source/destination
export const lmc: LayerMappingCollection = {
Expand All @@ -78,20 +93,8 @@ export const lmc: LayerMappingCollection = {
label: i18n.DESTINATION_LAYER,
},
},
'apm-*': {
source: {
metricField: 'client.bytes',
geoField: 'client.geo.location',
tooltipProperties: Object.keys(clientFieldMappings),
label: i18n.CLIENT_LAYER,
},
destination: {
metricField: 'server.bytes',
geoField: 'server.geo.location',
tooltipProperties: Object.keys(serverFieldMappings),
label: i18n.SERVER_LAYER,
},
},
'apm-*': APM_LAYER_FIELD_MAPPING,
'traces-apm*,logs-apm*,metrics-apm*,apm-*': APM_LAYER_FIELD_MAPPING,
};

/**
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
".lists*",
".items*",
"apm-*-transaction*",
"traces-apm*",
"auditbeat-*",
"endgame-*",
"filebeat-*",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
{
"names": [
"apm-*-transaction*",
"traces-apm*",
"auditbeat-*",
"endgame-*",
"filebeat-*",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
{
"names": [
"apm-*-transaction*",
"traces-apm*",
"auditbeat-*",
"endgame-*",
"filebeat-*",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
{
"names": [
"apm-*-transaction*",
"traces-apm*",
"auditbeat-*",
"endgame-*",
"filebeat-*",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
{
"names": [
"apm-*-transaction*",
"traces-apm*",
"auditbeat-*",
"endgame-*",
"filebeat-*",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
{
"names": [
"apm-*-transaction*",
"traces-apm*",
"auditbeat-*",
"endgame-*",
"filebeat-*",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
".lists*",
".items*",
"apm-*-transaction*",
"traces-apm*",
"auditbeat-*",
"endgame-*",
"filebeat-*",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"from": "now-360s",
"index": [
"apm-*-transaction*",
"traces-apm*",
"auditbeat-*",
"endgame-*",
"filebeat-*",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"enabled": false,
"index": [
"apm-*-transaction*",
"traces-apm*",
"auditbeat-*",
"endgame-*",
"filebeat-*",
Expand Down
Loading

0 comments on commit be2ef68

Please sign in to comment.