From 123c71739e83cdfa0faa7605bcb79377643a2374 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20St=C3=BCrmer?= Date: Thu, 14 Feb 2019 15:08:58 +0100 Subject: [PATCH] Add kafka log message test --- .../builtin_rules/filebeat_kafka.test.ts | 60 +++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 x-pack/plugins/infra/server/lib/domains/log_entries_domain/builtin_rules/filebeat_kafka.test.ts diff --git a/x-pack/plugins/infra/server/lib/domains/log_entries_domain/builtin_rules/filebeat_kafka.test.ts b/x-pack/plugins/infra/server/lib/domains/log_entries_domain/builtin_rules/filebeat_kafka.test.ts new file mode 100644 index 000000000000000..0959091c4df5032 --- /dev/null +++ b/x-pack/plugins/infra/server/lib/domains/log_entries_domain/builtin_rules/filebeat_kafka.test.ts @@ -0,0 +1,60 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { builtinRules } from '.'; +import { compileFormattingRules } from '../message'; + +const { format } = compileFormattingRules(builtinRules); + +describe('Filebeat Rules', () => { + describe('in ECS format', () => { + test('kafka log', () => { + const flattenedDocument = { + '@timestamp': '2017-08-04T10:48:21.063Z', + 'ecs.version': '1.0.0-beta2', + 'event.dataset': 'kafka.log', + 'event.module': 'kafka', + 'fileset.name': 'log', + 'input.type': 'log', + 'kafka.log.class': 'kafka.controller.KafkaController', + 'kafka.log.component': 'Controller 0', + 'log.level': 'INFO', + 'log.offset': 131, + message: '0 successfully elected as the controller', + 'service.type': 'kafka', + }; + + expect(format(flattenedDocument)).toMatchInlineSnapshot(` +Array [ + Object { + "constant": "[", + }, + Object { + "field": "event.dataset", + "highlights": Array [], + "value": "kafka.log", + }, + Object { + "constant": "][", + }, + Object { + "field": "log.level", + "highlights": Array [], + "value": "INFO", + }, + Object { + "constant": "] ", + }, + Object { + "field": "message", + "highlights": Array [], + "value": "0 successfully elected as the controller", + }, +] +`); + }); + }); +});