diff --git a/README.md b/README.md index 473ac1b..2edcc29 100644 --- a/README.md +++ b/README.md @@ -35,9 +35,9 @@ Follow the instructions below to send logs stored on AWS S3 to Logentries. ![Create Function](https://raw.githubusercontent.com/logentries/le_lambda/master/doc/step4.png) 5. Edit code: - * Edit the contents of ```le_lambda.py``` + * Edit the contents of ```le_config.py``` * Replace values of ```log_token``` and ```debug_token``` with tokens obtained earlier. - * Create a .ZIP file, containing the updated ```le_lambda.py``` and ```le_certs.pem``` + * Create a .ZIP file, containing the updated ```le_config.py```, ```le_lambda.py``` and ```le_certs.pem``` * Choose "Upload a .ZIP file" in AWS Lambda and upload the archive created in previous step ![Create Function](https://raw.githubusercontent.com/logentries/le_lambda/master/doc/step5.png) diff --git a/le_config.py b/le_config.py new file mode 100644 index 0000000..1c63760 --- /dev/null +++ b/le_config.py @@ -0,0 +1,15 @@ +# Logentries tokens +# This token is used to associate log files in AWS S3 to a log in your Logentries account. +log_token = "YOUR_LOG_TOKEN" + +# You can supply an optional token to log activity to a log on Logentries and any errors from this script. +# This is optional, it is recommended you use one log file/token for all your Lambda scripts. If you do not +# wish to use this, just leave the value blank. +debug_token = "YOUR_DEBUG_TOKEN" + +# Log to generic activity from this script to our support logging system for Lambda scripts +# this is optional, but helps us improve our service nad can be hand for us helping you debug any issues +# just remove this token if you wish (leave variable in place) +lambda_token = "0ae0162e-855a-4b54-9ae3-bd103006bfc0" + +username = "YOUR_USERNAME" diff --git a/le_lambda.py b/le_lambda.py index ae0a5e1..a82ec0a 100644 --- a/le_lambda.py +++ b/le_lambda.py @@ -4,26 +4,12 @@ import datetime import re import csv +from le_config import * print('Loading function') s3 = boto3.client('s3') -# This token is used to associate log files in AWS S3 to a log in your Logentries account. -log_token = "YOUR_LOG_TOKEN" - -# You can supply an optional token to log activity to a log on Logentries and any errors from this script. -# This is optional, it is recommended you use one log file/token for all your Lambda scripts. If you do not -# wish to use this, just leave the value blank. -debug_token = "YOUR_DEBUG_TOKEN" - -# Log to generic activity from this script to our support logging system for Lambda scripts -# this is optional, but helps us improve our service nad can be hand for us helping you debug any issues -# just remove this token if you wish (leave variable in place) -lambda_token = "0ae0162e-855a-4b54-9ae3-bd103006bfc0" - -username = "YOUR_USERNAME" - def lambda_handler(event, context): host = 'data.logentries.com' @@ -102,6 +88,6 @@ def validate_uuid(uuid_string): def validate_elb_log(key): - regex = re.compile('^\d+_\w+_\w{2}-\w{4,9}-[12]_.*._\d{8}T\d{4}Z_\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3}_.*.log$', re.I) + regex = re.compile('\d+_\w+_\w{2}-\w{4,9}-[12]_.*._\d{8}T\d{4}Z_\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3}_.*.log$', re.I) match = regex.match(key) return bool(match)