Skip to content

Commit

Permalink
Merge pull request #13 from scriptingislife/build
Browse files Browse the repository at this point in the history
Change LogDNA storage method
  • Loading branch information
scriptingislife authored Dec 12, 2021
2 parents e444ee3 + 533d507 commit fe051cd
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/lambda_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ def lambda_handler(event, context):
if db_data['title'] == '':
db_data['title'] = 'No title given'

db_data['net-requests'] = glimpse.get_network_history()

# Don't need if db_data['numscans'] is set to 0 when
# the DB GET doesn't exist
#if exists:
Expand Down
16 changes: 14 additions & 2 deletions src/logging_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ def get_env():

return log_env

def get_parameter():
paramter_name = 'LogDNAIngestionKey'
region_name = "us-east-1"

ssm_client = boto3.client('ssm', region_name=region_name)
response = ssm_client.get_parameter(Name=paramter_name)
return response['Parameters']['Value']

def get_secret():

secret_name = 'LogDNAIngestionKey' # os.environ['LOGGING_KEY']
Expand Down Expand Up @@ -87,7 +95,10 @@ def get_secret():
def log_msg(message):
log_env = get_env()

logdna = get_secret()
try:
logdna = get_parameter()
except:
return

logdata = {
"lines": [
Expand All @@ -103,7 +114,8 @@ def log_msg(message):
submission = requests.post('https://logs.logdna.com/logs/ingest?hostname=GLIMPSE&now={}'.format(int(time.time())), json=logdata, headers=h_data, auth=HTTPBasicAuth(logdna, ''))

if submission.status_code != 200: # or submission.json['status'] != "ok":
raise ValueError('Got status {}'.format(submission.status_code))
print('Got status {}'.format(submission.status_code))
#raise ValueError('Got status {}'.format(submission.status_code))



Expand Down

0 comments on commit fe051cd

Please sign in to comment.