how to view aws log real time (like tail -f)

后端 未结 11 686
执笔经年
执笔经年 2021-01-31 01:13

I can view the log using the following command.

aws logs get-log-events --log-group-name groupName --log-stream-name streamName --limit 100

wha

11条回答
  •  萌比男神i
    2021-01-31 01:57

    You can use awslogs, a python package to tail aws logwatch logs.

    Install it with

    pip install awslogs
    

    List all the groups with

    awslogs groups        
    

    Then select a stream and watch it with

    awslogs get staging-cluster --watch
    

    You can also filter logs with matching patterns.

    # tail logs of a cluster
    awslogs get staging-cluster --watch
    
    # tail logs of a lambda function
    awslogs get /aws/lambda/some-service --watch
    
    # print all logs containg "error"
    awslogs get staging-cluster --watch --filter-pattern="error"
    
    # print all logs *not* containg "error"
    awslogs get staging-cluster --watch --filter-pattern="-error"
    

    See project readme for more information on using awslogs.

提交回复
热议问题