Empty datapoints when querying CloudWatch metrics for DocumentDB elastic cluster

0

Hi,

I am trying to get CloudWatch metrics for my DocumentDB elastic cluster using the AWS CLI, but I always get empty datapoints. I have tried different versions of the commands, by replacing the dimension name by DBInstanceIdentifier || DBClusterIdentifier, or namespace to be AWS/DocDB-Elastic || AWS/DocDB such as:

aws cloudwatch get-metric-statistics \
    --namespace AWS/DocDB-Elastic \
    --metric-name PrimaryInstanceCPUUtilization  \
    --period 360 \
    --statistics Average \
    --start-time "$(date -u -d '1 hour ago' +'%Y-%m-%dT%H:%M:%SZ')" \
    --end-time "$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \
    --dimensions Name=DBInstanceIdentifier,Value=docdb-elastic-sharding-id

or

aws cloudwatch get-metric-statistics \
    --namespace AWS/DocDB \
    --metric-name CPUUtilization  \
    --period 360 \
    --statistics Average \
    --start-time "$(date -u -d '1 hour ago' +'%Y-%m-%dT%H:%M:%SZ')" \
    --end-time "$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \
    --dimensions Name=DBClusterIdentifier,Value=docdb-elastic-sharding-id

I also tried with a Java Program:

final AmazonCloudWatch cw = AmazonCloudWatchClientBuilder.standard()
                .withCredentials(DefaultAWSCredentialsProviderChain.getInstance())
                .build();
        final String metricName = "PrimaryInstanceCPUUtilization";
        final String namespace = "AWS/DocDB-Elastic";
        final String dimensionName = "DBClusterIdentifier";
        final String dimensionValue = "docdb-elastic-sharding-id";
        final int period = 60;
        final Date startTime = new Date(new Date().getTime() - 3600 * 1000); // 1 hour ago
        final Date endTime = new Date();

        GetMetricStatisticsRequest request = new GetMetricStatisticsRequest()
                .withMetricName(metricName)
                .withNamespace(namespace)
                .withDimensions(new Dimension().withName(dimensionName).withValue(dimensionValue))
                .withStartTime(startTime)
                .withEndTime(endTime)
                .withPeriod(period)
                .withStatistics("Average");
        GetMetricStatisticsResult result = cw.getMetricStatistics(request);

        System.out.println(result);

However, the output is always something like this:

{
    "Label": "PrimaryInstanceCPUUtilization",
    "Datapoints": []
}

I have checked on the monitoring tab for this metric on the AWS DocumentDB console, and it shows data there. So I am wondering why I can't get the same data using the CLI. Is there something wrong with my commands or parameters? How can I fix this issue?

Any help or guidance would be greatly appreciated. Thank you in advance! 😊

2 Antworten
0
Akzeptierte Antwort

Hello.

Try running the command with the dimensions "ClusterName", "ClusterId", and "ShardId".

aws cloudwatch get-metric-statistics \
    --namespace AWS/DocDB-Elastic \
    --metric-name PrimaryInstanceCPUUtilization \
    --period 360 \
    --start-time "$(date -u -d '1 hour ago' +'%Y-%m-%dT%H:%M:%SZ')" \
    --end-time "$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \
    --statistics Average --dimensions Name=ClusterName,Value=test Name=ClusterId,Value=cdbeaxxxxxxxxxxx Name=ShardId,Value=d618xxxxxxxxxxxxxxx

The metrics show that the dimensions are as follows, which must also be specified in the command options.
cw

profile picture
EXPERTE
beantwortet vor 8 Monaten
  • Thank you Riku, it works. Yay!!!

        "Label": "PrimaryInstanceCPUUtilization",
        "Datapoints": [
            {
                "Timestamp": "2023-09-21T15:12:00+00:00",
                "Average": 7.508333333333333,
                "Unit": "Percent"
            },
            {
                "Timestamp": "2023-09-21T14:54:00+00:00",
                "Average": 7.473611111111111,
                "Unit": "Percent"
            },
            {
                "Timestamp": "2023-09-21T15:00:00+00:00",
                "Average": 7.713888888888889,
                "Unit": "Percent"
            },
    
0

Hi, I ran the following for Sagemaker endpoint, it gave me empty data point. Can you please help ?

aws cloudwatch get-metric-statistics
--namespace AWS/SageMaker
--metric-name CPUUtilization
--period 720
--start-time "$(date -u -d '1 week ago' '+%Y-%m-%dT%H:%M:%S')"
--end-time "$(date -u '+%Y-%m-%dT%H:%M:%S')"
--statistics Average --dimensions Name=EndpointName,Value=mysagemakerendpointname Name=VariantName,Value=CPUUtilization

Output:- { "Label": "CPUUtilization", "Datapoints": [] }

Sanjaya
beantwortet vor 3 Monaten

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen