
터미널에서 AWS CloudWatch 로그를 꼬리는 가장 좋은 방법입니다.
저자 - Luca Grulla -https://www.lucagrulla.com
Local 타임 존 또는 UTC (기본값)로 작업하십시오.2d1h20m .13:10 오늘의 13:10을 나타냅니다.2018-10-20T8:53 .cw tail my-auth-service my-web .--grep ) 및 grepv ( --grepv ).--query 플래그 일치)echo my-group | cw tail 및 cat groups.txt | cw tail .cw tail -f my-stream >> myfile.txt .--no-color 플래그.--profile 및 --region 플래그로 재정의를 달성 할 수 있습니다. brew tap lucagrulla/tap
brew install cwbrew tap lucagrulla/tap
brew install cw 릴리스 페이지에서 .deb 또는 .rpm 다운로드하고 각각 dpkg -i 및 rpm -i 로 설치하십시오.
참고 : 3.3.0으로 업그레이드하면 새로운 별칭 명령에 유의하십시오. Snapcraft 새 릴리스 규칙을 준수해야합니다.
snap install cw-sh
sudo snap connect cw-sh:dot-aws-config-credentials
sudo snap alias cw-sh.cw cw cw 엄격한 감금으로 운영됩니다. dot-aws-config-credentials 인터페이스 연결은 .aws/config 및 .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 연결에 사용되는 AWS 프로파일을 재정의합니다.--region=aws-region 대상 AWS 영역을 무시합니다.--no-color 색상 출력을 비활성화합니다.--endpoint 포인트 대상 aws endpoint url. 기본적으로 CW는 기본 AWS 엔드 포인트를 사용합니다.--no-version-check 최신 버전의 모듈을 사용할 수 있는지 확인합니다. cw ls 그룹 내의 모든 로그 그룹/로그 스트림을 나열합니다.
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" cw tail 꼬리 주어진 로그 그룹/로그 스트림
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. 사용 가능한 로그 그룹 목록
cw ls groups주어진 로그 그룹의 로그 스트림 목록
cw ls streams my-log-group주어진 로그 그룹/스트림을 꼬리십시오
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 .cw tail -f my-log-group:my-log-stream-prefix -b3h .cw tail -f my-log-group:my-log-stream-prefix -b100m 100 분 전에 시작합니다.cw tail -f my-log-group:my-log-stream-prefix -b2h30m 2 시간 30 분 전부터 시작합니다.cw tail -f my-log-group -b9:00 -e9:01JMESPATH 구문을 사용하여 쿼리 JSON 로그
cw tail -f my-log-group --query "machines[?state=='running'].name" 시간과 날짜는 기본적으로 UTC로 취급됩니다. 로컬 존을 선호하는 경우 --local 플래그를 사용하십시오.
cw 대상 AWS 영역을 식별하기 위해 인증 및 공유 구성 (.aws/config)에 기본 자격 증명 프로파일 (./aws/credentials에 저장)을 사용합니다. 프로파일과 지역 모두 profile 및 region 글로벌 플래그를 통해 우선적입니다.
AWS SSO는 다음과 같은 경우 지원됩니다.
default 또는 대체 명명 프로파일)을 사용하십시오.sso_start_url , sso_account_id , sso_role_name 등aws sso login 통해 ...failed to sign request: failed to retrieve credentials: the SSO session has expired or is invalid... 그러면 aws sso login 통해 SSO 세션을 갱신해야합니다 (적절한 경우 명명 된 프로필을 지정).
cw 사용하십시오 AWS CLI : HTTP_PROXY 환경 변수를 사용하십시오 : https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-proxy.html
여기를 읽으십시오