Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change LogDNA storage method #13

Merged
merged 3 commits into from
Dec 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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