Last active
October 11, 2015 09:28
-
-
Save RWJMurphy/3838441 to your computer and use it in GitHub Desktop.
Syncing and splunking Amazon S3 logs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
^[[nspaces:s3_bucket_owner]]\s++[[nspaces:vhost]]\s++[[sbstring:req_time]]\s++[[nspaces:clientip]]\s++[[nspaces:user]]\s++[[nspaces:s3_request_id]]\s++[[nspaces:s3_operation]]\s++[[nspaces:s3_key]]\s++[[access-request]]\s++[[nspaces:status]]\s++[[nspaces:s3_error_code]]\s++[[nspaces:bytes]]\s++[[nspaces:s3_object_size]]\s++[[nspaces:s3_total_time]]\s++[[nspaces:s3_turnaround_time]]\s++"(?[[bc_domain:referer_]]?+[^"]*+)"\s++[[qstring:useragent]]\s++[[nspaces:s3_version_id]][[all:other]] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# snippet from /opt/splunk/etc/apps/search/local/inputs.conf | |
[monitor:///var/log/s3] | |
disabled = false | |
followTail = 0 | |
host = | |
host_segment = 4 | |
sourcetype = access_s3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
LOG_BUCKET=logs # replace this with the name of your log bucket | |
LOG_DIR=/var/log/s3 | |
S3CMD=/usr/bin/s3cmd | |
tmpdir=$(mktemp -d) | |
$S3CMD sync --skip-existing --delete-removed s3://$LOG_BUCKET/ $LOG_DIR/ &> $tmpdir/s3cmd.log | |
if [[ $? -ne 0 ]] | |
then | |
cat $tmpdir/s3cmd.log | |
fi | |
rm -rf $tmpdir |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment