Skip to main content

A Python library for advanced filtering and matching of AWS JSON logs, designed to simplify log parsing and enhance filtering capabilities.

Project description

AWS JSON Term Matcher

aws_json_term_matcher is a Python package designed to parse and evaluate filter expressions, such as those found in AWS CloudWatch log filters. This tool uses Lark for PEG parsing and supports logical operations like AND, OR, and parentheses for grouping.

Features

  • Parses logical expressions from JSON filters
  • Supports && (AND), || (OR), and parentheses for nested expressions
  • Extensible to include evaluation and tree reduction (future updates)

Installation

Clone the repository and install the requirements:

pip install aws-json-term-matcher

What does this tool do?

This tool provides enhanced JSON term matching for logs, giving you more flexibility and functionality when working with CloudWatch Logs. It allows you to use more sophisticated filters to search through JSON log events, making your log filtering more efficient.

The key improvement is the ability to filter logs with patterns similar to those used in AWS CloudWatch Logs but with more powerful Python-based features.

Example

from aws_json_term_matcher.matcher import match

# Example log
log = {
    "eventType": "UpdateTrail",
    "bandwidth": 80,
    "latency": 45,
    "number": [0.001, 1000],
    "sourceIPAddress": "123.123.1.1",
    "resources": [
        "arn:aws:states:us-east-1:111222333444:execution:OrderProcessorWorkflow:d57d4769-72fd",
        "arn:aws:states:us-east-1:111222333444:stateMachine:OrderProcessorWorkflow"
    ]
}

# Example filter
filter_str = '{ $.bandwidth > 75 }'


# Apply filter to log
if match(log, filter_str):
    print("Log matches the filter!")
else:
    print("Log does not match.")

In this example, the tool filters a log based on bandwidth and latency values, similar to how AWS CloudWatch Logs filters JSON log events.

Documentation

For more information about the original JSON term matching feature in AWS CloudWatch Logs, check out the official AWS documentation.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aws_json_term_matcher-0.1.2.tar.gz (5.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

aws_json_term_matcher-0.1.2-py3-none-any.whl (5.6 kB view details)

Uploaded Python 3

File details

Details for the file aws_json_term_matcher-0.1.2.tar.gz.

File metadata

  • Download URL: aws_json_term_matcher-0.1.2.tar.gz
  • Upload date:
  • Size: 5.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for aws_json_term_matcher-0.1.2.tar.gz
Algorithm Hash digest
SHA256 b28c5420cda4b0ce18efd8017156fcf1c35e03f8bf5d64826d7ab7152b720a8f
MD5 9d8f0fd371af4f4cdd6ace3dd15e8d0c
BLAKE2b-256 592fc3e7adf5d40099d28841b077998f9ffb5b2af56571b8171f4442de9b91c8

See more details on using hashes here.

File details

Details for the file aws_json_term_matcher-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for aws_json_term_matcher-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 da89dc33300f301220663271e055703e8546e40ee48ed2cb3ae3ddc32b081559
MD5 4d54b9282f55d058b05eab53d7ebce4c
BLAKE2b-256 4c8dfe2885ad9b477abae84105ff6f383f61e4410456ee02d3b936f96ee854f1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page