jorgebastida/awslogs là dự án mã nguồn mở trên GitHub với 5.0k sao, viết chủ yếu bằng Python. AWS CloudWatch logs for Humans™
Tóm tắt dựng từ metadata GitHub của chính dự án — chưa có bài review TopGit. Trang sẽ tự động cập nhật khi bài review đầy đủ được xuất bản.
VÌ SAO CHƯA CÓ REVIEW
TopGit viết bài đầy đủ cho repo có nhiều sao nhất và được yêu cầu nhiều nhất. Trang này là snapshot trong thời gian chờ — xem README gốc ở tab READ ME.
awslogs is a simple command line tool for querying groups, streams and events from Amazon CloudWatch <http://aws.amazon.com/cloudwatch/>_ logs.
One of the most powerful features is to query events from several streams and consume them (ordered) in pseudo-realtime using your favourite tools such as grep::
$ awslogs get /var/log/syslog ip-10-1.* --start='2h ago' | grep ERROR
Features
Aggregate logs from across streams.
Aggregate all streams in a group.
Aggregate streams matching a regular expression.
Colored output.
List existing groups
$ awslogs groups
List existing streams
$ awslogs streams /var/log/syslog
Watch logs as they are created
$ awslogs get /var/log/syslog ALL --watch
Human-friendly time filtering:
--start='23/1/2015 14:23'
--start='2h ago'
--start='2d ago'
--start='2w ago'
--start='2d ago' --end='1h ago'
Retrieve event metadata:
--timestamp Prints the creation timestamp of each event.
--ingestion-time Prints the ingestion time of each event.
Example
Running: awslogs get /var/logs/syslog ALL -s1d will return you events from any stream in the /var/logs/syslog group generated in the last day.
If you are on OSX El Capitan, use the following (Why? Check Donald Stufft's comment here <https://github.com/pypa/pip/issues/3165#issuecomment-145856429>_) ::
$ pip install awslogs --ignore-installed six
You can also install it with brew <https://brew.sh/>_::
$ brew install awslogs
Options
awslogs groups: List existing groups
awslogs streams GROUP: List existing streams within GROUP
awslogs get GROUP [STREAM_EXPRESSION]: Get logs matching STREAM_EXPRESSION in GROUP.
Expressions can be regular expressions or the wildcard ALL if you want any and don't want to type .*.
Note: You need to provide to all these options a valid AWS region using --aws-region or AWS_REGION env variable.
Time options
While querying for logs you can filter events by --start-s and --end-e date.
By minute:
--start='2m' Events generated two minutes ago.
--start='1 minute' Events generated one minute ago.
--start='5 minutes' Events generated five minutes ago.
By hours:
--start='2h' Events generated two hours ago.
--start='1 hour' Events generated one hour ago.
--start='5 hours' Events generated five hours ago.
By days:
--start='2d' Events generated two days ago.
--start='1 day' Events generated one day ago.
--start='5 days' Events generated five days ago.
By weeks:
--start='2w' Events generated two week ago.
--start='1 week' Events generated one weeks ago.
--start='5 weeks' Events generated five week ago.
Using specific dates:
--start='23/1/2015 12:00' Events generated after midday on the 23th of January 2015.
--start='1/1/2015' Events generated after midnight on the 1st of January 2015.
--start='Sat Oct 11 17:13:46 UTC 2003' You can use detailed dates too.
Note, for time parsing awslogs uses dateutil <https://dateutil.readthedocs.io/en/latest/>_.
All previous examples are applicable for --end-e too.
Filter options
You can use --filter-pattern if you want to only retrieve logs which match one CloudWatch Logs Filter pattern.
This is helpful if you know precisely what you are looking for, and don't want to download the entire stream.
For example, if you only want to download only the report events from a Lambda stream you can run::
$ awslogs get my_lambda_group --filter-pattern="[r=REPORT,...]"
Full documentation of how to write patterns: http://docs.aws.amazon.com/AmazonCloudWatch/latest/DeveloperGuide/FilterAndPatternSyntax.html
JSON logs
In a similar way than the aws-cli <http://docs.aws.amazon.com/cli/latest/userguide/controlling-output.html#controlling-output-filter>_ command, you can use --query to
filter each of your json log lines and extract certain fields::
$ awslogs get my_lambda_group --query=message
This will only display the message field for each of the json log lines.
Using third-party endpoints
If you use tools like localstack, fakes3 or other, consider to change boto3 endpoint using --aws-endpoint-url or AWS_REGION env variable.
AWS IAM Permissions
The required permissions to run awslogs are contained within the CloudWatchLogsReadOnlyAccess <https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/iam-identity-based-access-control-cwl.html>_ AWS managed permissions.
As of 2020-01-13, these are the permissions::
Although, the most straightforward thing to do might be use --aws-access-key-id and --aws-secret-access-key, this will eventually become a pain in the ass.
If you only have one AWS account, my personal recommendation would be to configure aws-cli <http://aws.amazon.com/cli/>_. awslogs will use those credentials if available. If you have multiple AWS profiles managed by aws-cli, just add --profile [PROFILE_NAME] at the end of every awslogs command to use those credentials, or set the AWS_PROFILE env variable.
If you don't want to setup aws-cli, I would recommend you to use envdir <https://pypi.python.org/pypi/envdir>_ in order to make AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY available to awslogs.
Trang TopGit này là một snapshot — tab "Readme" hiển thị nguyên văn README của repo (đã bỏ link, giữ ảnh). Repo GitHub ở github.com/jorgebastida/awslogs là nguồn chính thức.
jorgebastida/awslogs có phải mã nguồn mở không?
TopGit chưa ghi nhận license cho jorgebastida/awslogs. Phần lớn repo public trên GitHub là mã nguồn mở, nhưng điều khoản khác nhau từng repo — mở file LICENSE để xác nhận.
jorgebastida/awslogs là gì?
jorgebastida/awslogs (jorgebastida/awslogs) là dự án Python trên GitHub. Theo mô tả gốc: AWS CloudWatch logs for Humans™
Đọc đầy đủ README ở tab phía trên.
Vẫn đang phân vân về awslogs?
Một cú bấm sẽ gửi câu hỏi kèm trang này cho AI — xem AI nói gì về awslogs.