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 hashes)

Uploaded Source

Built Distribution

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

Uploaded Python 3

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