Kompira Pigeon & AWS CloudWatch
完了Dear Support,
I want to ask if how do I connect Kompira Pigeon and AWS CloudWatch. I want to be notified via Call when there is an alarm or trigger on my CloudWatch.
-
正式なコメント
Thank you for your question.
I recommend that you use AWS Lambda to invoke Pigeon API. You can setup CloudWatch to call Lambda function when event is occured. Please refer to the following URL link.
Using AWS Lambda with Amazon CloudWatch Events
There is some web article about how to send HTTP POST request by Lambda function. For example,
HTTP post request from node.js in AWS Lambda
We are publishing the tutorial of Pigeon on Kompira cloud blog. The tutorial is Japanese only but you may find sample of setting and requesting on it.
Regards.
コメントアクション -
Dear Fritz,
I tried to wrote sample of Lambda function. Maybe It works, but I did not check it yet because we don't have test environment which ready to use.
Please read it as a reference.
Sample to invoke Kompira Pigeon by AWS Lambda
Regards.
-
Dear Honda san,
Thank you very much for your code. It really helps a lot. I tried to test it and it was successful on Lambda.
But, I haven't received any call on my phone and there were no results on the kompira console. I was wondering what seems to be the problem.
Also, I found out there is an authorization error/permission denied on lambda output.
-
Dear Fritz,
I created AWS account and tried to run Lambda function. It works and succeeded to invoke call.
(I'm sorry to find a mistake which occurs syntax error. I fixed it just now.)Maybe there is an error in the X-Authorization header (line 11). Please check the following,
- Is X-Authorization header specified ?
- Is it starts with "Token " ?
-
Dear Honda san,
Good day.
Again thank you for your help.
For the call message (guidance contents), I want it to include my Cloudwatch alarm name and status because I'm planning to monitor many alarms. How do I set parameter for this in lambda and on my guidance template?
Best regards,
Fritz
-
Dear Fritz,
As far as I searched, there're two ways to invoke Lambda function from CloudWatch. And there's difference in accessibility to Alarm's information.
Which way are you using?
- Trigger CloudWatch Events by Lambda directly.
- Trigger CloudWatch Logs by Lambda directly.
- Invoke Lambda function via SNS by CloudWatch Alarm's action.
- Other.
-
Dear Fritz,
Thank you for your reply.
I found alarm data is written at "event.Records[n].Sns.Message" with JSON format. You have to parse it when you read name or status of alarm, but It's difficult. So I wrote new sample to do it.
Lambda function sample to invoke Kompira Pigeon when CloudWatch alarm's action received via SNS.
Regards.
-
Dear Fritz,
I'm sorry I found some mistake in my code. Please use latest one. But I think your error is unrelated to my mistake.
The code wrote on the assumption that it is triggered by SNS. Please trigger it from CloudWatch alarm to test it, or use test event which matches the spec of SNS message like this,
{
"Records": [
{
"Sns": {
"Message": "{\"AlarmName\":\"Test Alarm\",\"NewStateValue\":\"ALARM\"}"
}
}
]
}
サインインしてコメントを残してください。
コメント
15件のコメント