Code Monkey home page Code Monkey logo

pyinsights's Introduction

PyInsights

PyPI - Python Version PyPI GitHub

A CLI tool To query CloudWatch Logs Insights.

usage1

usage2

ToC

Usage

Write Configuration

Write configuration to pyinsights.yml like:

version: '1.0'
log_group_name:
  - '/ecs/sample'
query_string: 'field @message | filter @message like /ERROR/'
duration: '30m'
limit: 10

I wrote examples, so see examples folder.

Execute command

pyinsights -c pyinsights.yml -p aws_profile -r region

Configuration

version

Type Required
string true

Choose configuration version from ['1.0']

log_group_name

Type Required
array true

Target log group names to query

query_string

Type Required
string or array true

Specify CloudWatch Logs Insights query commands. Please see CloudWatch Logs Insights Query Syntax.

โš ๏ธ If query_string type is array, Unix-style pipe | is not required. Execute in order from the top.

ex)

query_string:
  - 'field @message'
  - 'fileter @message like /WARN/'

Equal to

query_string: 'field @message | fileter @message like /WARN/'

duration

Type Required
string or object true

type: string

Specify weeks, days, hours, minutes or seconds unit.

weeks = w
days = d
hours = h
minutes = m
seconds = s

ex)

duration: 10h

type: object

Specify start_time and end_time. The format must be YYYY-MM-DD HH:MM:SS.

ex)

duration:
  start_time: '2020-01-01 00:00:00'
  end_time: '2020-01-01 01:00:00'

limit

Type Required
integer false

The number of log to fetch. Of course, you can specify limit in query_string.

CLI Options

Option Required Description
-c, --config true Specify yaml configuration by absolute or relative path
-f, --format false Choose from json or table
-p, --profile false AWS profile name
-r, --region false AWS region
-q, --quiet false Suppress progress message
-o, --output false Specify the filename to output the query result
-v, --version false Show version

Environment Variable

If profile and region options are not specified, AWS Credentials must be set as environment variables.

  • AWS_ACCESS_KEY_ID
  • AWS_SECRET_ACCESS_KEY
  • AWS_DEFAULT_REGION

Please see Environment Variable Configuration for the detail.

pyinsights's People

Contributors

homoluctus avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.