How to build monitoring dashboard that will monitor the status of AWS Health Dashboard, where we want to monitor the status of the Transcribe service in the Ohio region.

1

Dear AWS experts,

I am trying to build a monitoring dashboard that will monitor the status of AWS Health Dashboard, where we want to monitor the status of the Transcribe service in the Ohio region.

I am using the lambda function to monitor the AWS Health Dashboard. When I run the lambda function, I get the following response:

"errorMessage": "An error occurred (SubscriptionRequiredException) when calling the DescribeEvents operation: "

Lambda Function:

import boto3

def lambda_handler(event, context):
    health = boto3.client('health')
    response = health.describe_events()
    status = response['events'][0]['statusCode']
    
    s3 = boto3.client('s3')
    s3.put_object(Bucket='status_m', Key='health-dashboard-status.txt', Body=status)

The region is set to us-east-2 Ohio.

Function log:

START RequestId: d359f1e0-a14f-49c9-ba53-5234917f6e2f Version: $LATEST
[WARNING]	2023-05-08T11:27:48.662Z	d359f1e0-a14f-49c9-ba53-5234917f6e2f	Client is configured with the deprecated endpoint: us-east-2
[ERROR] ClientError: An error occurred (SubscriptionRequiredException) when calling the DescribeEvents operation: 

Note: The role associated with the lambda function has a custom policy called AWSHealthReadOnlyAccess that looks like the below:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": "health:DescribeEvents",
            "Resource": "*"
        }
    ]
}

I am not sure what I am missing here. I appreciate your help in advance.

Kind Regards

3 Answers
0

Programmatic access to AWS Health API requires the calling account to have a Business, Enterprise On-Ramp, or Enterprise Support plan. Accessing AWS Health is free through the AWS Health Dashboard and through Amazon EventBridge. You can use the latter to monitor events for Transcribe by configuring an EventBridge rule that catches events for Amazon Transcribe and then triggering your lambda. If you want to go down the programmatic access route, I'd recommending looking into AWS Health Aware, which also requires Business or Enterprise support, but will have some good examples for for you to follow (see github project), which supports pushing events to a number of channels that you can configure.

AWS
iddv
answered a year ago
  • Just a note, AWS Health Aware also uses the Health API (and the related Business or Enterprise Support plan enabled on each account)

  • That is correct, I just mentioned it because it might serve as a good example. I've updated my answer to clarify.

-1

Hi,

The event bridge rule is created like the one in the doc you shared. Event Source: AWS events or EventBridge partner events Event pattern: Event source -> AWS service >> Health >>> Specific health event Select Target: I believe I should select the Lambda function that I shared in the question.

Can you please explain with a bit more clarity when you say-

  1. configuring an EventBridge rule that catches events for Amazon Transcribe and
  2. then trigger your lambda.

Thanks in advance


For your reference: Screenshot for the CloudWatch metrics when the event bridge rule is set for the Transcribe service with a lambda function. Enter image description here

answered a year ago
  • You added an answer to your own question, if you want to follow up on a question I will probably be better to add a comment to my question :) (1) When you configure the rule you can select the service you are interested from a drop down list. You can follow the guide I linked, the provided example is for catching EC2 events, but it will work exactly the same for Transcribe. (2) After you have configured the rule, any AWS Health event posted for Amazon Transcribe that reaches your account invoke the target that you have configured in the rule. It looks like you want to write the output to S3, so you can do that by invoking your Lambda function when an event is received. The guide I linked also has an example of the payload.

  • Hi iddv, based on the suggestion (1) when I configure the even bridge rule, I can select the service I am interested in from a drop-down list. The service in my case is Transcribe - Done (2) After I have configured the rule, any AWS Health event posted for Amazon Transcribe that reaches my account invokes the target that I have configured in the rule - Done (3) I want to write the output to S3, so I can do that by invoking my Lambda function when an event is received - Done.

    Lambda function looks like this:

    import json
    import boto3
    
    def lambda_handler(event, context):
        s3 = boto3.client('s3')
        bucket_name = 's3bucket'
        key = 'aws-health-events/{}.json'.format(context.aws_request_id)
        
        event_data = json.loads(event['detail'])
        # Extract relevant information from the AWS Health event
        event_description = event_data['eventDescription'][0]['latestDescription']
        event_status_code = event_data['statusCode']
        event_start_time = event_data['startTime']
        event_end_time = event_data['endTime']
        
        # Upload the event information to S3
        s3.put_object(Body=event_description, Bucket=bucket_name, Key=key)
        
        return {
            'statusCode': 200,
            'body': json.dumps('AWS Health event successfully processed')
        }
    

    Observations:

    1. I can see some runtime metrics that lambda sends. But I'm unsure how to read it. Please refer the screenshot I've attached for your reference in the post above.
    2. I Can't see any file in the S3 bucket
  • The metrics that you've posted seems to indicate that your function was invoked successfully once. There are a couple of things that you can do to debug this, such as (1) verify that you've deployed the latest version of your function, (2) make sure to test your function with a valid sample event, (3) add some debug logging to your code to verify that your code is doing what you expect it to do and (4) verify that your function has the correct permissions. Once you have it working with a sample event, you can log a request with AWS Support through the console to send a test event to your account, that will test your function end to end with a real AWS Health Event!

-1

Thanks for the quick reply :) I am not looking to fix this programmatically. I will try your recommendation to go with EventBridge now.

answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions