How to query cloudwatch logs using boto3 in python

后端 未结 3 1018
粉色の甜心
粉色の甜心 2021-02-08 05:03

I have a lambda function that writes metrics to Cloudwatch. While, it writes metrics, It generates some logs in a log-group.

INFO:: username: simran+test@abc.co         


        
3条回答
  •  有刺的猬
    2021-02-08 05:38

    I used awslogs. if you install it, you can do. --watch will tail the new logs.

    awslogs get /aws/lambda/log-group-1 --start="5h ago" --watch
    

    You can install it using

    pip install awslogs
    

    to filter you can do:

    awslogs get /aws/lambda/log-group-1  --filter-pattern '"ClinicID=7667"' --start "5h ago" --timestamp
    

    It supports multiple filter patterns as well.

    awslogs get /aws/lambda/log-group-1  --filter-pattern '"ClinicID=7667"' --filter-pattern '" username=simran+test@abc.com"' --start "5h ago" --timestamp
    

    References:

    awslogs

    awslogs . PyPI

提交回复
热议问题