Skip to content

Commit

Permalink
update LogDNA storage method
Browse files Browse the repository at this point in the history
  • Loading branch information
Nathaniel committed Dec 12, 2021
1 parent e444ee3 commit 7535791
Showing 1 changed file with 14 additions and 2 deletions.
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 7535791

Please sign in to comment.