简体   繁体   English

如何匹配 aws cloudwatch 日志中的多个模式以触发 lambda

[英]how to match multiple patterns in aws cloudwatch log to trigger a lambda

I'm trying to set a cloudwatch event to trigger a lambda function, I wan to trigger it when the message in the logs is either 'Process exited before completing request' or 'Error Runtime exited with error signal killed'.我正在尝试设置一个 cloudwatch 事件来触发 lambda 函数,我想在日志中的消息是“完成请求之前退出进程”或“错误运行时退出,错误信号被杀死”时触发它。

Specifying one is easy, and it works fine (using a serverless.yml file)指定一个很容易,而且工作正常(使用 serverless.yml 文件)

      - cloudwatchLog:
      logGroup: '/aws/lambda/hello'
      filter: 'Error Runtime exited with error signal killed'

but I need the event to trigger for both messages, what is the right syntax to use an OR filter?但我需要为两条消息触发事件,使用OR过滤器的正确语法是什么?

     - cloudwatchLog:
      logGroup: '/aws/lambda/hello'
      filter: 'Process exited before completing request' OR 'Error Runtime exited' with error signal killed' 

I've tried with '[Process exited before completing request, Error Runtime exited]' but that doesn't work, aws docummendation specifies how to match one word or another but not complete sentences like this ones我已经尝试过'[Process exited before completing request, Error Runtime exited]'但这不起作用,aws 文档指定如何匹配一个或另一个单词但不完整的句子像这样

this works:这有效:

- cloudwatchLog:
  logGroup: '/aws/lambda/hello'
  filter: '[(message="*Process exited before completing*") || (message="*signal: killed*") || (message="*Runtime.ExitError*")]' 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM