I am using the CloudWatch agent to catch tomcat logs, which are all errors. The agent publishes the log streams to a log group, and what I want is to get these log errors and send them to an MS Teams channel using anything like SNS, Lambda, ...
My only issue is that I could do all of the above except for that I can't get the error message, for example:
org.hibernate.exception.SQLGrammarException: could not extract ResultSet...
I am using the following python code to get this done, which I picked from AWS documentation.
#!/usr/bin/python3.7
import urllib3
import json
http = urllib3.PoolManager()
url = "https://outlook.office.com/webhook/xxxxxxxxx"
msg = {
"text": event['Records'][0]['Sns']['Message']
}
encoded_msg = json.dumps(msg).encode('utf-8')
resp = http.request('POST', url, body = encoded_msg)
print({
# "message": event['Records'][0]['Sns']['Message'],
"message": " ** Payload ** " ,
"status_code": resp.status,
"response": resp.data
})
Can you guys help me, please?
Thanks.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…