
La meilleure façon de rédiger des journaux CloudWatch AWS à partir de votre terminal.
Auteur - Luca Grulla - https://www.lucagrulla.com
Local ou UTC (par défaut).2d1h20m pour indiquer 2 jours, 1 heure et 20 minutes.13:10 pour indiquer 13:10 d'aujourd'hui.2018-10-20T8:53 .cw tail my-auth-service my-web .--grep ) et grepv ( --grepv ).--query )echo my-group | cw tail and cat groups.txt | cw tail .cw tail -f my-stream >> myfile.txt .--no-color pour désactiver si nécessaire.--profile et --region . brew tap lucagrulla/tap
brew install cwbrew tap lucagrulla/tap
brew install cw Téléchargez le .deb ou .rpm à partir de la page des versions et installez avec dpkg -i et rpm -i respectivement.
Remarque : Si vous passez à la mise à niveau vers 3.3.0, veuillez noter la nouvelle commande Alias. Ceci est nécessaire pour se conformer aux nouvelles règles de version Snapcraft.
snap install cw-sh
sudo snap connect cw-sh:dot-aws-config-credentials
sudo snap alias cw-sh.cw cw cw fonctionne avec un confinement strict; La connexion d'interface dot-aws-config-credentials est nécessaire pour avoir accès aux fichiers .aws/config and .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 remplacer le profil AWS utilisé pour la connexion.--region=aws-region Override la région AWS cible.--no-color désactiver la sortie colorée.--endpoint L'URL de point de terminaison Target AWS. Par défaut, CW utilisera les points de terminaison AWS par défaut.--no-version-check Ignore vérifie si une version plus récente du module est disponible. cw ls répertorie tous les groupes de journaux / flux de journaux au sein d'un groupe
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 Tail Un groupe de journaux / flux de journal donné
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. Liste des groupes de journaux disponibles
cw ls groupsListe des flux de journal dans un groupe de journaux donné
cw ls streams my-log-groupqueue et suivent des groupes de journaux / flux de journaux
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 pour commencer il y a 7 jours.cw tail -f my-log-group:my-log-stream-prefix -b3h pour commencer il y a 3 heures.cw tail -f my-log-group:my-log-stream-prefix -b100m pour commencer il y a 100 minutes.cw tail -f my-log-group:my-log-stream-prefix -b2h30m pour commencer à partir de 2 heures et 30 minutes.cw tail -f my-log-group -b9:00 -e9:01requêtes des journaux JSON à l'aide de la syntaxe JMESPATH
cw tail -f my-log-group --query "machines[?state=='running'].name" Le temps et les dates sont traités par défaut UTC. Utilisez l'indicateur --local si vous préférez utiliser la zone locale.
cw utilise le profil d'identification par défaut (stocké dans ./aws/credentials) pour l'authentification et la configuration partagée (.aws / config) pour identifier la région AWS cible. Le profil et la région sont remplacés via le profile et les drapeaux mondiaux region .
AWS SSO est pris en charge si vous:
default ou un autre profil nommé) qui inclut les différentes propriétés SSOsso_start_url , sso_account_id , sso_role_name , etc.aws sso login Si vous obtenez un message d'erreur qui inclut ...failed to sign request: failed to retrieve credentials: the SSO session has expired or is invalid... alors vous devez renouveler votre session SSO via aws sso login (et spécifier le profil nommé, le cas échéant).
cw derrière un proxy Veuillez utiliser la variable d'environnement HTTP_PROXY comme requis par AWS CLI: https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-proxy.html
Lire ici