Skip to main content

Library to query CloudWatch Logs and create Pandas DataFrame from the results

Project description

CloudWatchLogs2Pandas

This file will become your README and also the index of your documentation.

Install

pip install CloudWatchLogs2Pandas

How to use

You need to build your query based on the documentations here:

query = 'fields @timestamp, @message | sort @timestamp desc | limit 5'
log_group = '/aws/apigateway/welcome'
cwq = CloudWatchQuery(query, log_group)

When executing the query against the log group, the default time range of of 14 days.

cwq.get_df()
<style scoped> .dataframe tbody tr th:only-of-type { vertical-align: middle; }
.dataframe tbody tr th {
    vertical-align: top;
}

.dataframe thead th {
    text-align: right;
}
</style>

In case you have no results, you can modify the time range. For example for Last Year you can use:

cwq.get_df(days_start=365)
<style scoped> .dataframe tbody tr th:only-of-type { vertical-align: middle; }
.dataframe tbody tr th {
    vertical-align: top;
}

.dataframe thead th {
    text-align: right;
}
</style>
timestamp message ptr
0 2021-12-20 11:03:13.568 Cloudwatch logs enabled for API Gateway CmAKKAokMzI3MTYzODM3MDU1Oi9hd3MvYXBpZ2F0ZXdheS...
1 2021-11-24 15:10:19.572 Cloudwatch logs enabled for API Gateway CmAKKAokMzI3MTYzODM3MDU1Oi9hd3MvYXBpZ2F0ZXdheS...
2 2021-11-01 15:57:57.790 Cloudwatch logs enabled for API Gateway CmAKKAokMzI3MTYzODM3MDU1Oi9hd3MvYXBpZ2F0ZXdheS...
3 2021-11-01 15:37:36.574 Cloudwatch logs enabled for API Gateway CmAKKAokMzI3MTYzODM3MDU1Oi9hd3MvYXBpZ2F0ZXdheS...
4 2021-10-30 23:10:28.807 Cloudwatch logs enabled for API Gateway CmAKKAokMzI3MTYzODM3MDU1Oi9hd3MvYXBpZ2F0ZXdheS...

Additional configurations

You can set the AWS region with:

cwq.set_region("us-west-2")

More complicated time range:

cwq.get_df(days_start=2, hours_start=4, hours_end=4)
<style scoped> .dataframe tbody tr th:only-of-type { vertical-align: middle; }
.dataframe tbody tr th {
    vertical-align: top;
}

.dataframe thead th {
    text-align: right;
}
</style>

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

CloudWatchLogs2Pandas-0.0.2.tar.gz (10.1 kB view details)

Uploaded Source

Built Distribution

CloudWatchLogs2Pandas-0.0.2-py3-none-any.whl (8.7 kB view details)

Uploaded Python 3

File details

Details for the file CloudWatchLogs2Pandas-0.0.2.tar.gz.

File metadata

  • Download URL: CloudWatchLogs2Pandas-0.0.2.tar.gz
  • Upload date:
  • Size: 10.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.8.5

File hashes

Hashes for CloudWatchLogs2Pandas-0.0.2.tar.gz
Algorithm Hash digest
SHA256 d5ebf359a8ab7794d45b626c0f2b3c7cb929105f88ac7ac1480c3501f504c911
MD5 4be994db73940c0a91b62e63abf31821
BLAKE2b-256 1a9d51dcd3196dee8b790b19583cf78964ebd103ae7c1128dab54e09b3e50b23

See more details on using hashes here.

File details

Details for the file CloudWatchLogs2Pandas-0.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for CloudWatchLogs2Pandas-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 3e201b66ddb4f5d0d55cff9728059b91427ca087f712374b28bd7cde3011e04b
MD5 d4bd651961165f50b3fbef546cea676d
BLAKE2b-256 160996e01e97ceb3c2f9cbaa2e7929d7fc3490a17d065d88ca9c663d41144e14

See more details on using hashes here.

Supported by

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