Kompira Pigeon & AWS CloudWatch

完了

コメント

15件のコメント

  • 正式なコメント
    Kompiraサポートチーム

    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.

    Pigeon チュートリアル

    Regards.

    コメントアクション Permalink
  • Fritz Palenzuela

    Thank you for your reply.

     

    I know how to connect cloudwatch and lambda. I also know how to setup Pigeon. My only problem is that I don't know how to setup : lambda function using node.js to connect to pigeon.

    Can you teach me about it. Thank you very much for your help.

    0
    コメントアクション Permalink
  • Kompiraサポートチーム

    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.

    1
    コメントアクション Permalink
  • Fritz Palenzuela

    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.

    0
    コメントアクション Permalink
  • Kompiraサポートチーム

    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 " ?

    1
    コメントアクション Permalink
  • Fritz Palenzuela

    本田さん

    支援 いただき ありがとう ございます。

    I've modified the code and it works successfully.
    You are a legend! お世話になりました。

    I'm sorry for disturbing but it saves time and really helps us a lot.

    Best regards,
    Fritz

    0
    コメントアクション Permalink
  • Kompiraサポートチーム

    Dear Fritz

    I'm glad that I could help you out. Well, I will close this question.

    Best regards.

    1
    コメントアクション Permalink
  • Fritz Palenzuela

    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

    0
    コメントアクション Permalink
  • Kompiraサポートチーム

    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?

    1. Trigger CloudWatch Events by Lambda directly.
    2. Trigger CloudWatch Logs by Lambda directly.
    3. Invoke Lambda function via SNS by CloudWatch Alarm's action.
    4. Other.
    0
    コメントアクション Permalink
  • Fritz Palenzuela

    Dear Honda san,

    Thank you.

    I am using 3. First I create a Cloudwatch alarm then send an alert to SNS which is connected to a Lambda Function.

    Best Regards,

    Fritz

     

    0
    コメントアクション Permalink
  • Kompiraサポートチーム

    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.

    0
    コメントアクション Permalink
  • Fritz Palenzuela

    Dear Honda san,

    Thanks a lot for your help.

    I tried and test your code but I received an error. Please see below image. 

    Best regards,

    Fritz

    0
    コメントアクション Permalink
  • Kompiraサポートチーム

    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\"}"
          }
        }
      ]
    }

    0
    コメントアクション Permalink
  • Fritz Palenzuela

    Dear Honda san,

    Thank you very much. I also found out some code errors. 

    Also, I use {{alarmName}} & {{alarmState}} since "alert" name doesn't work on my guidance.

    Your code was very helpful to us. Again, thank you!

    0
    コメントアクション Permalink
  • Kompiraサポートチーム

    Dear Fritz,

    I'm glad to hear that!
    Please contact us if there is anything.

    Best Regards,

    Takahiro Honda

    0
    コメントアクション Permalink

サインインしてコメントを残してください。