Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8104021
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T23:43:05+00:00 2026-06-05T23:43:05+00:00

I’m having a little trouble using AmazonCloudWatch to fetch CPU Utilization. When I try

  • 0

I’m having a little trouble using AmazonCloudWatch to fetch CPU Utilization. When I try to use AmazonCloudWatch.GetMetricStatistics(), I get this for an exception message:

Exception of type ‘Amazon.CloudWatch.AmazonCloudWatchException’ was thrown.

And this for an inner exception:

{“The remote server returned an error: (400) Bad Request.”}

Here is the code I’m using to make the call:

public static String getCPUStats(String Endpoint, String InstanceID) 
    {
        try
        {
            AmazonCloudWatchConfig cloudConfig = new AmazonCloudWatchConfig();
            cloudConfig.ServiceURL = Endpoint;

            string AWSAccessKey = Sql.ToString(appConfig["AWSAccessKey"]);
            string AWSSecretKey = Sql.ToString(appConfig["AWSSecretKey"]);

            AmazonCloudWatch client = AWSClientFactory.CreateAmazonCloudWatchClient(AWSAccessKey, AWSSecretKey, cloudConfig);

            GetMetricStatisticsRequest request = new GetMetricStatisticsRequest();
            request.Dimensions.Add(new Dimension { Name = "InstanceId", Value = InstanceID });
            request.StartTime = DateTime.UtcNow.AddMinutes(-5);
            request.EndTime = DateTime.UtcNow;
            request.Namespace = "AWS/EC2";
            request.Statistics.Add("Maximum");
            request.Statistics.Add("Average");
            request.MetricName = "CPUUtilization";
            request.Period = 60;

            GetMetricStatisticsResponse r = client.GetMetricStatistics(request);

            if (r.GetMetricStatisticsResult.Datapoints.Count > 0)
            {
                Datapoint dataPoint = r.GetMetricStatisticsResult.Datapoints[0];
                return "CPU maximum load: " + dataPoint.Maximum;

            }

            return "No data available.";
        }
        catch (Exception ex)
        {
            return ex.Message;
        }
    }

Some side notes – the access key, secret access key, and endpoint work fine for creating an AmazonEC2Client, so I’m pretty sure the problem isn’t there.

I’ve done quite a bit of googling and poring over the documentation, but haven’t been successful in solving this. Any ideas? Thanks so much!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T23:43:06+00:00Added an answer on June 5, 2026 at 11:43 pm

    Unfortunately, we weren’t able to figure this one out – we ended up deciding to use Microsoft Azure instead of Amazon Web Services 🙁

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I'm having trouble keeping the paragraph square between the quote marks. In firefox the
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
this is what i have right now Drawing an RSS feed into the php,
I am reading a book about Javascript and jQuery and using one of the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.