Skip to content

Commit

Permalink
Add external config, fix object key matching
Browse files Browse the repository at this point in the history
  • Loading branch information
omgapuppy committed Feb 9, 2016
1 parent 06f3151 commit 0c42444
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 18 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
15 changes: 15 additions & 0 deletions le_config.py
Original file line number Diff line number Diff line change
@@ -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"
18 changes: 2 additions & 16 deletions le_lambda.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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)

0 comments on commit 0c42444

Please sign in to comment.