
Лучший способ хвоста AWS Cloudwatch в журналах вашего терминала.
Автор - Лука Грулла - https://www.lucagrulla.com
Local часовым поясом или UTC (по умолчанию).2d1h20m , чтобы указать 2 дня, 1 час и 20 минут назад.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 флаг, чтобы отключить, если это необходимо.--region --profile brew tap lucagrulla/tap
brew install cwbrew tap lucagrulla/tap
brew install cw Загрузите .deb или .rpm со страницы релизов и установите с dpkg -i и rpm -i соответственно.
Примечание . Если вы обновите до 3.3.0, обратите внимание на новую команду псевдонима. Это необходимо для соответствия новым правилам выпуска Snapraft.
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 ЦЕЛЬНЫЙ URL-адрес ENDPOINT AWS. По умолчанию 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 начинается с 7 дней назад.cw tail -f my-log-group:my-log-stream-prefix -b3h начинается с 3 часа назад.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:01Запрос журнала JSON с использованием синтаксиса Jmespath
cw tail -f my-log-group --query "machines[?state=='running'].name" Время и даты рассматриваются как UTC по умолчанию. Используйте флаг --local флаг, если вы предпочитаете использовать локальную зону.
cw использует профиль учетных данных по умолчанию (сохраненный в ./aws/credentials) для аутентификации и общей конфигурации (.aws/config) для определения целевой области AWS. Как профиль, так и регион переопределяются через profile и глобальные флаги region .
AWS SSO поддерживается, если вы:
default или альтернативный именованный профиль), который включает в себя различные свойства SSOsso_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... тогда вы должны продлить свой сеанс SSO через aws sso login (и укажите именованный профиль, если это необходимо).
cw за прокси Пожалуйста, используйте переменную среды HTTP_PROXY , как требуется AWS CLI: https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-proxy.html
Читайте здесь