
Cara terbaik untuk ekor AWS CloudWatch log dari terminal Anda.
Penulis - Luca Grulla - https://www.lucagrulla.com
Local atau UTC (default).2d1h20m untuk menunjukkan 2 hari, 1 jam dan 20 menit yang lalu.13:10 untuk menunjukkan 13:10 hari ini.2018-10-20T8:53 .cw tail my-auth-service my-web .--grep ) yang kuat dan grepv ( --grepv ).--query )echo my-group | cw tail dan cat groups.txt | cw tail .cw tail -f my-stream >> myfile.txt .--no-color bendera untuk menonaktifkan jika diperlukan.--profile dan --region . brew tap lucagrulla/tap
brew install cwbrew tap lucagrulla/tap
brew install cw Unduh .deb atau .rpm dari halaman rilis dan instal dengan dpkg -i dan rpm -i masing -masing.
Catatan : Jika Anda meningkatkan ke 3.3.0 Harap perhatikan perintah Alias baru. Ini diperlukan untuk mematuhi aturan rilis baru Snapcraft.
snap install cw-sh
sudo snap connect cw-sh:dot-aws-config-credentials
sudo snap alias cw-sh.cw cw cw berjalan dengan kurungan yang ketat; Koneksi antarmuka dot-aws-config-credentials diperlukan untuk memiliki akses ke .aws/config dan file .aws/credentials
scoop bucket add cw https://github.com/lucagrulla/cw-scoop-bucket.git
scoop install cwgo get github.com/lucagrulla/cw--profile=profile-name mengesampingkan profil AWS yang digunakan untuk koneksi.--region=aws-region mengesampingkan wilayah AWS target.--no-color menonaktifkan output berwarna.--endpoint URL titik akhir target AWS. Secara default CW akan menggunakan titik akhir AWS default.--no-version-check mengabaikan cek jika versi modul yang lebih baru tersedia. cw ls Daftar Semua Grup Log/Log Streams Dalam suatu grup
Usage: cw ls <command>
show an entity
Flags:
-h, --help Show context-sensitive help.
--endpoint=URL The target AWS endpoint url. By default cw will use the default aws endpoints. NOTE: v4.0.0
dropped the flag short version.
--profile=PROFILE The target AWS profile. By default cw will use the default profile defined in the
.aws/credentials file. NOTE: v4.0.0 dropped the flag short version.
--region=REGION The target AWS region. By default cw will use the default region defined in the
.aws/credentials file. NOTE: v4.0.0 dropped the flag short version.
--no-color Disable coloured output.NOTE: v4.0.0 dropped the flag short version.
--version Print version information and quit
--no-version-check Ignore checks if a newer version of the module is available.
Commands:
ls groups
Show all groups.
ls streams <group>
Show all streams in a given log group.
cw: error: expected one of "groups", "streams" ekor cw tail grup log/aliran log tertentu
Usage: cw tail <groupName[:logStreamPrefix]> ...
Tail log groups/streams.
Arguments:
<groupName[:logStreamPrefix]> ... The log group and stream name, with group:prefix syntax. Stream name can be just the prefix. If no stream name is specified all stream names in the given
group will be tailed. Multiple group/stream tuple can be passed. e.g. cw tail group1:prefix1 group2:prefix2 group3:prefix3.
Flags:
-h, --help Show context-sensitive help.
--endpoint=URL The target AWS endpoint url. By default cw will use the default aws endpoints. NOTE: v4.0.0 dropped the flag short version.
--profile=PROFILE The target AWS profile. By default cw will use the default profile defined in the .aws/credentials file. NOTE: v4.0.0 dropped the flag short version.
--region=REGION The target AWS region. By default cw will use the default region defined in the .aws/credentials file. NOTE: v4.0.0 dropped the flag short version.
--no-color Disable coloured output.NOTE: v4.0.0 dropped the flag short version.
--version Print version information and quit
--no-version-check Ignore checks if a newer version of the module is available.
-f, --follow Don't stop when the end of streams is reached, but rather wait for additional data to be appended.
-t, --timestamp Print the event timestamp.
-i, --event-id Print the event Id.
-s, --stream-name Print the log stream name this event belongs to.
-n, --group-name Print the log group name this event belongs to.
-r, --retry Keep trying to open a log group/log stream if it is inaccessible.
-b, --start="2021-04-11T08:21:52" The UTC start time. Passed as either date/time or human-friendly format. The human-friendly format accepts the number of days, hours and minutes prior to
the present. Denote days with 'd', hours with 'h' and minutes with 'm' i.e. 80m, 4h30m, 2d4h. If just time is used (format: hh[:mm]) it is expanded to
today at the given time. Full available date/time format: 2017-02-27[T09[:00[:00]].
-e, --end=STRING The UTC end time. Passed as either date/time or human-friendly format. The human-friendly format accepts the number of days, hours and minutes prior to the
present. Denote days with 'd', hours with 'h' and minutes with 'm' i.e. 80m, 4h30m, 2d4h. If just time is used (format: hh[:mm]) it is expanded to today at
the given time. Full available date/time format: 2017-02-27[T09[:00[:00]].
-l, --local Treat date and time in Local timezone.
-g, --grep=STRING Pattern to filter logs by. See http://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/FilterAndPatternSyntax.html for syntax.
-v, --grepv=STRING Equivalent of grep --invert-match. Invert match pattern to filter logs by.
-q, --query=STRING Equivalent of the --query flag in AWS CLI. Takes a JMESPath expression to filter JSON logs by. If the query fails (e.g. the log message was not JSON) then the original line is returned. Daftar grup log yang tersedia
cw ls groupsdaftar aliran log dalam grup log yang diberikan
cw ls streams my-log-groupekor dan ikuti grup kayu/aliran yang diberikan
cw tail -f my-log-groupcw tail -f my-log-group:my-log-stream-prefixcw tail -f my-log-group:my-log-stream-prefix my-log-group2cw tail -f my-log-group:my-log-stream-prefix -b2017-01-01T08:10:10 -e2017-01-01T08:05:00cw tail -f my-log-group:my-log-stream-prefix -b7d mulai dari 7 hari yang lalu.cw tail -f my-log-group:my-log-stream-prefix -b3h mulai dari 3 jam yang lalu.cw tail -f my-log-group:my-log-stream-prefix -b100m mulai dari 100 menit yang lalu.cw tail -f my-log-group:my-log-stream-prefix -b2h30m akan mulai dari 2 jam dan 30 menit yang lalu.cw tail -f my-log-group -b9:00 -e9:01Query Json Log Menggunakan Sintaks JMespath
cw tail -f my-log-group --query "machines[?state=='running'].name" Waktu dan tanggal diperlakukan sebagai UTC secara default. Gunakan bendera --local jika Anda lebih suka menggunakan zona lokal.
cw menggunakan profil kredensial default (disimpan di ./aws/credentials) untuk otentikasi dan konfigurasi bersama (.Aws/config) untuk mengidentifikasi wilayah AWS target. Profil dan wilayah dapat diterbangkan melalui profile dan bendera global region .
AWS SSO didukung jika Anda:
default atau profil bernama alternatif) yang mencakup berbagai properti SSOsso_start_url , sso_account_id , sso_role_name , dllaws sso login Jika Anda mendapatkan pesan kesalahan yang termasuk ...failed to sign request: failed to retrieve credentials: the SSO session has expired or is invalid... maka Anda harus memperbarui sesi SSO Anda melalui aws sso login (dan tentukan profil yang disebutkan, jika perlu).
cw di belakang proxy Harap gunakan variabel lingkungan HTTP_PROXY seperti yang dipersyaratkan oleh AWS CLI: https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-proxy.html
Baca di sini