AWS CloudWatch日志的订阅过滤器以淘汰Lambda报告消息

时间:2018-09-04 13:21:47

标签: amazon-web-services aws-lambda amazon-kinesis-firehose amazon-cloudwatchlogs

我正在使用订阅筛选器将日志从特定日志组获取到Firehose,最终将其放入Elasticsearch。该日志组中的日志来自Java Lambda。所有START RequestId ...END RequestId ...REPORT RequestId ...消息也都以Elasticsearch结尾。

是否可以具有订阅筛选器,以使这些消息不会到达firehose,而只有来自Lambda函数的实际日志消息才到达firehose。或者,使用“转换Lambda”处理它们是实现此目的的唯一方法吗?

1 个答案:

答案 0 :(得分:0)

是的,有可能。这有点神秘,但这是可以解决问题的过滤模式:

[a != "START" && a != "END" && a != "REPORT" && a != "RequestId:", ...]

根据以下条件进行测试:

START RequestId: 9538d388-c156-4680-b9d0-ba98c73742c7 Version: $LATEST
2019-02-06T20:30:49.096Z    9538d388-c156-4680-b9d0-ba98c73742c7    Hello World
END RequestId: 9538d388-c156-4680-b9d0-ba98c73742c7
REPORT RequestId: 9538d388-c156-4680-b9d0-ba98c73742c7  Duration: 24.45 ms  Billed Duration: 100 ms Memory Size: 128 MB Max Memory Used: 47 MB  
RequestId: 9538d388-c156-4680-b9d0-ba98c73742c7 Process exited before completing request

仅此一项将匹配:

2019-02-06T20:30:49.096Z    9538d388-c156-4680-b9d0-ba98c73742c7    Hello World