Created
April 16, 2016 11:23
-
-
Save olegdulin/fd18906343d75142a487b9a9da9042e0 to your computer and use it in GitHub Desktop.
Write a "Hello World" into an AWS CloudWatch Logs service
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/local/bin/python3 | |
import boto3 | |
import time | |
logs = boto3.client('logs') | |
LOG_GROUP='TUTORIAL-DEV2' | |
LOG_STREAM='stream1' | |
logs.create_log_group(logGroupName=LOG_GROUP) | |
logs.create_log_stream(logGroupName=LOG_GROUP, logStreamName=LOG_STREAM) | |
timestamp = int(round(time.time() * 1000)) | |
response = logs.put_log_events( | |
logGroupName=LOG_GROUP, | |
logStreamName=LOG_STREAM, | |
logEvents=[ | |
{ | |
'timestamp': timestamp, | |
'message': time.strftime('%Y-%m-%d %H:%M:%S')+'\tHello world, here is our first log message!' | |
} | |
] | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi Geoff Singer,
This is fine but for logging one message we are making two API one to describe and get the token
and second one to actually log the request.
But when we do actually log the request using put_log_events() we get the token in that response only
Is there anyway we can use that token itself?