cw

授权协议 Apache-2.0 License
开发语言 SHELL
所属分类 应用工具、 终端/远程登录
软件类型 开源软件
地区 不详
投 递 者 昝阳嘉
操作系统 跨平台
开源组织
适用人群 未知
 软件概览

cw

cw - the best way to tail AWS CloudWatch Logs

The best way to tail AWS CloudWatch Logs from your terminal.

Author - Luca Grulla - https://www.lucagrulla.com

Features

  • No external dependencies
    • cw is a native executable targeting your OS. No pip, npm, rubygems.
  • Fast.
    • cw is written in golang and compiled against your architecture.
  • Flexible date and time parser.
    • Work with either Local timezone or UTC (default).
    • Flexible parsing.
      • Human friendly formats, i.e. 2d1h20m to indicate 2 days, 1 hour and 20 minutes ago.
      • a specific hour, i.e. 13:10 to indicate 13:10 of today.
      • a full timestamp 2018-10-20T8:53.
  • Multi log groups tailing
    • tail multiple log groups in parallel: cw tail my-auth-service my-web.
  • Powerful built-in grep (--grep) and grepv (--grepv).
  • JMESPath support for JSON queries (matching the AWS CLI --query flag)
  • Pipe operator supported
    • echo my-group | cw tail and cat groups.txt | cw tail.
  • Redirection operator >> supported
    • cw tail -f my-stream >> myfile.txt.
  • Coloured output
    • --no-color flag to disable if needed.
  • Flexible credentials control.
    • By default the AWS .aws/credentials and .aws/profile files are used. Overrides can be achieved with the --profile and --region flags.

Installation

Mac OSX

using Homebrew

brew tap lucagrulla/tap
brew install cw

Linux

using Linuxbrew

brew tap lucagrulla/tap
brew install cw

.deb/.rpm

Download the .deb or .rpm from the releases page and install with dpkg -i and rpm -i respectively.

using Snapcraft.io

Note: If you upgrade to 3.3.0 please note the new alias command. This is required to comply with snapcraft new release rules.

snap install cw-sh
sudo snap connect cw-sh:dot-aws-config-credentials
sudo snap alias cw-sh.cw cw

cw runs with strict confinement; the dot-aws-config-credentials interface connection is required to have access to .aws/config and .aws/credentials files

On Windows

using Scoop.sh

scoop bucket add cw https://github.com/lucagrulla/cw-scoop-bucket.git
scoop install cw

Go tools

go get github.com/lucagrulla/cw

Commands and options

Global flags

  • --profile=profile-name Override the AWS profile used for connection.
  • --region=aws-region Override the target AWS region.
  • --no-color Disable coloured output.
  • --endpoint The target AWS endpoint url. By default cw will use the default aws endpoints.

Commands

  • cw ls list all the log groups/log streams within a group

    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
    
    Commands:
      ls groups
        Show all groups.
    
      ls streams <group>
        how all streams in a given log group.
    
    cw: error: expected one of "groups",  "streams"
  • cw tail tail a given log group/log stream

    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
    
      -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.

Examples

  • list of the available log groups

    • cw ls groups
  • list of the log streams in a given log group

    • cw ls streams my-log-group
  • tail and follow given log groups/streams

    • cw tail -f my-log-group
    • cw tail -f my-log-group:my-log-stream-prefix
    • cw tail -f my-log-group:my-log-stream-prefix my-log-group2
    • cw tail -f my-log-group:my-log-stream-prefix -b2017-01-01T08:10:10 -e2017-01-01T08:05:00
    • cw tail -f my-log-group:my-log-stream-prefix -b7d to start from 7 days ago.
    • cw tail -f my-log-group:my-log-stream-prefix -b3h to start from 3 hours ago.
    • cw tail -f my-log-group:my-log-stream-prefix -b100m to start from 100 minutes ago.
    • cw tail -f my-log-group:my-log-stream-prefix -b2h30m to start from 2 hours and 30 minutes ago.
    • cw tail -f my-log-group -b9:00 -e9:01
  • query JSON logs using JMESPath syntax

    • cw tail -f my-log-group --query "machines[?state=='running'].name"

Time and Dates

Time and dates are treated as UTC by default.Use the --local flag if you prefer to use Local zone.

AWS credentials and configuration

cw uses the default credentials profile (stored in ./aws/credentials) for authentication and shared config (.aws/config) for identifying the target AWS region. Both profile and region are overridable via the profile and region global flags.

AWS SSO

As today (May 2020) AWS Go SDK is not supporting AWS SSO correctly.The best approach is to use one of these tools while the SDK is updated:https://github.com/benkehoe/aws-sso-credential-processhttps://github.com/victorskl/yawsso

Miscellaneous

Use cw behind a proxy

Please use HTTP_PROXY environment variable as required by AWS cli:https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-proxy.html

Breaking changes notes

Read here

  • linux 驱动 描述:cw2015驱动源码在实际项目中验证过,可以放心使用,驱动代码功能正常。 CW2015 驱动源码 #include <linux/module.h> #include <linux/i2c.h> #include <linux/power_supply.h> #include <linux/regmap.h> #include <linux/types.h> #includ

  • CW 通讯的优缺点 摩斯电码 (Morse Code) 是一种相当古老的通讯方法,早在有线电话发明前的有线电报时代即已存在。由于它有精简、低本成高效率的优点,所以在通讯科技昌明的今天,它仍然占有相当重要的地位。 CW 为 Continue Wave 的缩写,它并不是指连续发射的信号(那不成为干扰了吗?)而是指频率固定、振辐固定,有别于 FM 的频率、AM 的振辐随时间改变而改变。由于没有调制,所以

  • #include <iostream> #include <string> using namespace std; bool tt; double calculate(string a) // 计算除去()的式子 { double x[1001]; int y[1000]; // x存数字,y存运算符号 bool t = false; // 接来下的数字是否为小数点后 int t0 =

  • iambic(双桨)paddles(自动键) 一个触点(左键)用于点,另外一个触点(右键)用于划的电键被叫做"iambic paddles",两个触点也可以同时合上。将电键的左右键压在一起的时候,电键的电路控制部分产生iambic功能(交替点划)。 单桨自动键(single-paddle)也使用独立的触点用于点和划,但是没有能力产生同时合上触点的功能(iambic)。当单桨自动键用于电路控制部分,

  • 摘要: 物理层处理的起点是MAC层传下来的传输块TB,终点是生成基带OFDM信号。最后将OFDM信号变成射频信号通过天线发射出去。 物理层处理TB到CW的流程包括了: CRC -> 码块分割 -> 信道编码 -> 速率匹配(RM)-> 码块级联 码块级联之后就是码字 CW 然后是下面的MIMO、OFDM流程: 扰码 -> 调制 -> 层映射 -> 预编码 -> 资源映射 -> OFDM信号生成 -

 相关资料
  • 问题内容: 我正在尝试从命令行运行Websphere自由配置文件服务器。我正在按照这里告诉的步骤进行操作:https : //developer.ibm.com/wasdev/downloads/liberty-profile-using-non-eclipse- environments/ 我创建了名称为server1的服务器。 但是当提取完成后,我尝试使用以下命令启动服务器: 服务器抛出错误:

  • 问题内容: 有一个Spring全局方法记录如下异常: Veracode扫描说此日志记录已经并建议使用ESAPI记录器。有什么方法可以解决此漏洞而无需将记录器更改为ESAPI?这是我在代码中唯一遇到此问题的地方,我试图找出如何用最少的更改来解决它。也许ESAPI有一些我没有注意到的方法? PS Current logger是slf4j上的Log4j UPD: 最后,我使用了ESAPI记录器。我以为它

  • 有人能帮我开轮班路线吗? 我设置了一个带有边缘TLS终端的路由,对服务endpoint(https://openshift-pmi-dev.apps.vapidly.os.fyre.ibm.com)的呼叫导致: 来自pod的日志具有以下错误:我使用endpoint进行REST调用 默认Passthrough路由终止工作!,但这不允许我指定基于路径的路由。因此,尝试使用带有边缘TLS终止的路由我正在

  • 问题内容: 如何编写一个装饰器,将当前工作目录还原到调用装饰函数之前的目录?换句话说,如果在执行an的函数上使用装饰器,则调用该函数后cwd将不会更改。 问题答案: path.py模块(如果在python脚本中处理路径,则应使用该模块)具有上下文管理器: (版权来自Roberto Alsina的这篇博客文章)

  • 本文向大家介绍C++之CWnd窗口框架实例,包括了C++之CWnd窗口框架实例的使用技巧和注意事项,需要的朋友参考一下 本文实例讲述了CWnd窗口框架,分享给大家供大家参考。具体分析如下: .h头文件代码如下: .cpp源文件代码如下: 希望本文所述对大家的C++程序设计有所帮助。

  • 问题内容: 我使用的是 崇高的文本3 生成3126对 Ubuntu的灿烂 与 SublimeREPL 插件。 我使用 CTRL + SHIFT + P >> SublimeREPL 打开Python REPL :Python, 并使用 CTRL +,F 和everything将文件发送到REPL,只要我使用单个Python脚本文件即可。一旦我尝试将代码的某些部分移至另一个模块并将其导入主文件中,就

  • 构建问题我的android应用程序找不到依赖项,不确定是什么问题。它昨天工作,没有更改任何代码。 有人知道怎么解决这个问题吗?