GetMetricWidgetImage not able to retrieve image

0

I am trying to get Dashboard metric graphs using GetMetricWidgetImage API, Could not figure out how make it work.

Below is the postman screen

Enter image description here

已提問 1 年前檢視次數 387 次
2 個答案
1

Hi There

If you don't use one of the AWS SDKs, you can make CloudWatch API requests over HTTP using the POST request method. The POST method requires you to specify the operation in the header of the request and provide the data for the operation in JSON format in the body of the request. See https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/making-api-requests.html#CloudWatch-API-requests-using-post-method

You will need to construct the MetricWidget parameter in json format and pass it with your POST request. See https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_GetMetricWidgetImage.html

profile pictureAWS
專家
Matt-B
已回答 1 年前
0

@Matt-B

Below is the request I am using (redacted credentials) , able to see error message ( {"__type":"com.amazon.coral.service#UnknownOperationException"} ) when request is sent. Can you help to resolve this.

curl --location --request POST 'http://monitoring.us-east-1.amazonaws.com'
--header 'x-amz-target: GraniteServiceVersion20100801.MetricWidget'
--header 'Content-Encoding: amz-1.0'
--header 'X-Amz-Content-Sha256: beaead3198f7da1e70d03ab969765e0821b24fc913697e929e726aeaebf0eba3'
--header 'X-Amz-Date: 20230104T054615Z'
--header 'Authorization: AWS4-HMAC-SHA256 Credential=<redacted>/20230104/us-east-1/execute-api/aws4_request, SignedHeaders=content-encoding;host;x-amz-content-sha256;x-amz-date;x-amz-target, Signature=6d1c80d2b6c38895ee28dacae25d756387d2e37595d67a0ae5b5b08e34c679a8'
--header 'Content-Type: application/json'
--data-raw '{ "OutputFormat":"png", "MetricWidget":{ "width":600, "height":395, "metrics": [ [ "AWS/EC2", "CPUUtilization", "AutoScalingGroupName", "LoadTest-Clister-A", { "visible": false } ], [ "AWS/EC2", "CPUUtilization", "InstanceId", "i-0fff55f4e57f7289d" ], [ "AWS/EC2", "CPUUtilization", "InstanceId", "i-0c9c05fa7dc1a28f2" ], [ "AWS/EC2", "CPUUtilization", "InstanceId", "i-0349c01a4508abd6e" ], [ "AWS/EC2", "CPUUtilization", "InstanceId", "i-0d2eea8bd67634a75" ], [ "AWS/EC2", "CPUUtilization", "AutoScalingGroupName", "LoadTest-ML" ], [ "AWS/EC2", "CPUUtilization", "AutoScalingGroupName", "Loadtest-Monitoring" ], [ "AWS/EC2", "CPUUtilization", "AutoScalingGroupName", "platform-loadtest-clustera" ] ], "view": "timeSeries", "stacked": false, "region": "us-east-1", "title": "CPU Utilization", "stat": "Maximum", "period":300, "start":"-P30D", "end":"PT0H", "yAxis":{ "left":{ "min":0.1, "max":1 }, "right":{ "min":0 } }, "annotations":{ "horizontal":[ { "color":"#ff6961", "label":"Trouble threshold start", "fill":"above", "value":0.5 } ], "vertical":[ { "visible":true, "color":"#9467bd", "label":"Bug fix deployed", "value":"2018-08-28T15:25:26Z", "fill":"after" } ] } } } '

已回答 1 年前
  • You have: --header 'x-amz-target: GraniteServiceVersion20100801.MetricWidget'

    Usage is: GraniteServiceVersion20100801.API_Name

    API_Name should be GetMetricWidgetImage GraniteServiceVersion20100801.GetMetricData

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南