Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cloudwatch: get_metric_statistics unexpected error #152

Closed
phyber opened this issue Jul 14, 2021 · 2 comments · Fixed by #168
Closed

cloudwatch: get_metric_statistics unexpected error #152

phyber opened this issue Jul 14, 2021 · 2 comments · Fixed by #168
Assignees
Labels
bug This issue is a bug.

Comments

@phyber
Copy link

phyber commented Jul 14, 2021

Bug Report

Version

├── aws-sdk-cloudwatch v0.0.11-alpha (https://github.com/awslabs/aws-sdk-rust?tag=v0.0.11-alpha#6780fde3)
│   ├── aws-auth v0.1.0 (https://github.com/awslabs/aws-sdk-rust?tag=v0.0.11-alpha#6780fde3)
│   │   ├── smithy-http v0.0.1 (https://github.com/awslabs/aws-sdk-rust?tag=v0.0.11-alpha#6780fde3)
│   │   │   ├── smithy-types v0.0.1 (https://github.com/awslabs/aws-sdk-rust?tag=v0.0.11-alpha#6780fde3)
│   ├── aws-endpoint v0.1.0 (https://github.com/awslabs/aws-sdk-rust?tag=v0.0.11-alpha#6780fde3)
│   │   ├── aws-types v0.1.0 (https://github.com/awslabs/aws-sdk-rust?tag=v0.0.11-alpha#6780fde3)
│   │   └── smithy-http v0.0.1 (https://github.com/awslabs/aws-sdk-rust?tag=v0.0.11-alpha#6780fde3) (*)
│   ├── aws-http v0.1.0 (https://github.com/awslabs/aws-sdk-rust?tag=v0.0.11-alpha#6780fde3)
│   │   ├── aws-types v0.1.0 (https://github.com/awslabs/aws-sdk-rust?tag=v0.0.11-alpha#6780fde3) (*)
│   │   ├── smithy-http v0.0.1 (https://github.com/awslabs/aws-sdk-rust?tag=v0.0.11-alpha#6780fde3) (*)
│   │   ├── smithy-types v0.0.1 (https://github.com/awslabs/aws-sdk-rust?tag=v0.0.11-alpha#6780fde3) (*)
│   ├── aws-hyper v0.1.0 (https://github.com/awslabs/aws-sdk-rust?tag=v0.0.11-alpha#6780fde3)
│   │   ├── aws-auth v0.1.0 (https://github.com/awslabs/aws-sdk-rust?tag=v0.0.11-alpha#6780fde3) (*)
│   │   ├── aws-endpoint v0.1.0 (https://github.com/awslabs/aws-sdk-rust?tag=v0.0.11-alpha#6780fde3) (*)
│   │   ├── aws-http v0.1.0 (https://github.com/awslabs/aws-sdk-rust?tag=v0.0.11-alpha#6780fde3) (*)
│   │   ├── aws-sig-auth v0.1.0 (https://github.com/awslabs/aws-sdk-rust?tag=v0.0.11-alpha#6780fde3)
│   │   │   ├── aws-auth v0.1.0 (https://github.com/awslabs/aws-sdk-rust?tag=v0.0.11-alpha#6780fde3) (*)
│   │   │   ├── aws-types v0.1.0 (https://github.com/awslabs/aws-sdk-rust?tag=v0.0.11-alpha#6780fde3) (*)
│   │   │   ├── smithy-http v0.0.1 (https://github.com/awslabs/aws-sdk-rust?tag=v0.0.11-alpha#6780fde3) (*)
│   │   ├── protocol-test-helpers v0.1.0 (https://github.com/awslabs/aws-sdk-rust?tag=v0.0.11-alpha#6780fde3)
│   │   ├── smithy-client v0.1.0 (https://github.com/awslabs/aws-sdk-rust?tag=v0.0.11-alpha#6780fde3)
│   │   │   ├── protocol-test-helpers v0.1.0 (https://github.com/awslabs/aws-sdk-rust?tag=v0.0.11-alpha#6780fde3) (*)
│   │   │   ├── smithy-http v0.0.1 (https://github.com/awslabs/aws-sdk-rust?tag=v0.0.11-alpha#6780fde3) (*)
│   │   │   ├── smithy-http-tower v0.1.0 (https://github.com/awslabs/aws-sdk-rust?tag=v0.0.11-alpha#6780fde3)
│   │   │   │   ├── smithy-http v0.0.1 (https://github.com/awslabs/aws-sdk-rust?tag=v0.0.11-alpha#6780fde3) (*)
│   │   │   ├── smithy-types v0.0.1 (https://github.com/awslabs/aws-sdk-rust?tag=v0.0.11-alpha#6780fde3) (*)
│   │   ├── smithy-http v0.0.1 (https://github.com/awslabs/aws-sdk-rust?tag=v0.0.11-alpha#6780fde3) (*)
│   │   ├── smithy-http-tower v0.1.0 (https://github.com/awslabs/aws-sdk-rust?tag=v0.0.11-alpha#6780fde3) (*)
│   │   ├── smithy-types v0.0.1 (https://github.com/awslabs/aws-sdk-rust?tag=v0.0.11-alpha#6780fde3) (*)
│   ├── aws-sig-auth v0.1.0 (https://github.com/awslabs/aws-sdk-rust?tag=v0.0.11-alpha#6780fde3) (*)
│   ├── aws-types v0.1.0 (https://github.com/awslabs/aws-sdk-rust?tag=v0.0.11-alpha#6780fde3) (*)
│   ├── smithy-http v0.0.1 (https://github.com/awslabs/aws-sdk-rust?tag=v0.0.11-alpha#6780fde3) (*)
│   ├── smithy-query v0.1.0 (https://github.com/awslabs/aws-sdk-rust?tag=v0.0.11-alpha#6780fde3)
│   │   ├── smithy-types v0.0.1 (https://github.com/awslabs/aws-sdk-rust?tag=v0.0.11-alpha#6780fde3) (*)
│   ├── smithy-types v0.0.1 (https://github.com/awslabs/aws-sdk-rust?tag=v0.0.11-alpha#6780fde3) (*)
│   └── smithy-xml v0.1.0 (https://github.com/awslabs/aws-sdk-rust?tag=v0.0.11-alpha#6780fde3)

Platform

FreeBSD and Linux

AWS Services

CloudWatch

Description

When using get_metric_statistics, I receive an unexpected error:

Error { code: "MalformedInput", message: "timestamp must follow ISO8601", request_id: "5a0f4195-dfb7-45d9-b5e8-a2c453aa4ddb" }

Given that the user doesn't supply ISO8601 timestamps and instead provides Instant to the various methods of this function, it appears to be an issue in the SDK. Tracing smithy_http_tower we can see the request that gets sent:

# Line breaks added to make the SdkBody inner slightly easier to read
TRACE smithy_http_tower::dispatch       > request=Request {
  method: POST,
  uri: https://monitoring.eu-west-1.amazonaws.com/,
  version: HTTP/1.1,
  headers: {
    "content-type": "application/x-www-form-urlencoded",
    "content-length": "407",
    "host": "monitoring.eu-west-1.amazonaws.com",
    "user-agent": "aws-sdk-rust/0.1.0 os/linux lang/rust/1.53.0",
    "x-amz-user-agent": "aws-sdk-rust/0.1.0 api/cloudwatch/0.0.11-alpha os/linux lang/rust/1.53.0",
    "authorization": Sensitive,
    "x-amz-date": "20210714T100434Z",
    "x-amz-security-token": Sensitive
  },
  body: SdkBody {
    inner: Once(
      Some(
        b"Action=GetMetricStatistics&Version=2010-08-01&Namespace=AWS%2FS3&MetricName=BucketSizeBytes&Dimensions.member.1.Name=BucketName&Dimensions.member.1.Value=a-valid-s3-bucket&Dimensions.member.2.Name=StorageType&Dimensions.member.2.Value=StandardStorage&StartTime=2021-07-12T10%3A04%3A34.86317681Z&EndTime=2021-07-14T10%3A04%3A34.86317681Z&Period=86400&Statistics.member.1=Average&Unit=Bytes"
      )
    ),
    retryable: true
  }
}

The following code should replicate the issue when run against (in this case) S3 bucket metrics:

use anyhow::Result;
use aws_sdk_cloudwatch::Client;
use aws_sdk_cloudwatch::model::{
    Dimension,
    StandardUnit,
    Statistic,
};
use chrono::prelude::*;
use chrono::Duration;

#[tokio::main]
async fn main() -> Result<()> {
    pretty_env_logger::init();

    let client = Client::from_env();

    // Prepare some variables used in the query
    let bucket_name        = "a-valid-s3-bucket";
    let now: DateTime<Utc> = Utc::now();
    let one_day            = Duration::days(1);
    let period             = one_day.num_seconds() as i32;
    let start_time         = (now - (one_day * 2)).into();
    let storage_type       = "StandardStorage";

    let dimensions = vec![
        Dimension::builder()
            .name("BucketName")
            .value(bucket_name.to_owned())
            .build(),
        Dimension::builder()
            .name("StorageType")
            .value(storage_type.to_owned())
            .build(),
    ];

    let _resp = client.get_metric_statistics()
        .end_time(now.into())
        .metric_name("BucketSizeBytes")
        .namespace("AWS/S3")
        .period(period)
        .set_dimensions(Some(dimensions))
        .start_time(start_time)
        .statistics(Statistic::Average)
        .unit(StandardUnit::Bytes)
        .send()
        .await?;

    Ok(())
}
@rcoh rcoh added the bug This issue is a bug. label Jul 14, 2021
@rcoh
Copy link
Contributor

rcoh commented Jul 14, 2021

it seems like the extremely precise timestamp is probably the problem: 2021-07-14T10%3A04%3A34.86317681Z

@phyber
Copy link
Author

phyber commented Jul 14, 2021

That was my thought too. The CloudWatch API documentation doesn't mention allowing such precise timestamps.

@jdisanti jdisanti added this to Researching in SDK for Rust Public Roadmap Jul 21, 2021
@jdisanti jdisanti self-assigned this Jul 21, 2021
@jdisanti jdisanti moved this from Researching to We're Working On It in SDK for Rust Public Roadmap Jul 21, 2021
@jdisanti jdisanti moved this from We're Working On It to Coming Soon (slated for inclusion in next release) in SDK for Rust Public Roadmap Jul 21, 2021
@rcoh rcoh closed this as completed in #168 Jul 28, 2021
SDK for Rust Public Roadmap automation moved this from Coming Soon (slated for inclusion in next release) to Just Shipped Jul 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug.
Projects
No open projects
Development

Successfully merging a pull request may close this issue.

3 participants