-
I'm (very) new to Rust, and I'm having trouble sending log events to CloudWatchLogs. I'm trying to construct an "event" to feed to put_log_events() but I don't know enough about Rust to make it happen. I can't seem to find where Here's the code that I have right now, but it doesn't work: let region_provider = RegionProviderChain::default_provider().or_else("us-east-1");
let config = aws_config::from_env().region(region_provider).load().await;
let client = Client::new(&config);
let event = client.InputLogEvent {
timestamp: 123,
message: String::from("this is a test message"),
};
let resp = client.put_log_events()
.log_group_name("test_name")
.log_stream_name("test_stream")
.log_events(event)
.send().await?; |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
Just to provide an answer for future me; I found out how the "builder" pattern works. This code will create an "event" which you can feed to the "put_log_events" call: let time = SystemTime::now().duration_since(UNIX_EPOCH).unwrap();
let event = InputLogEvent::builder()
.timestamp(time.as_micros().try_into().unwrap())
.message(String::from("this is a test message"))
.build(); |
Beta Was this translation helpful? Give feedback.
-
For anyone that's interested in the |
Beta Was this translation helpful? Give feedback.
-
Hello! Reopening this discussion to make it searchable. |
Beta Was this translation helpful? Give feedback.
Just to provide an answer for future me; I found out how the "builder" pattern works.
This code will create an "event" which you can feed to the "put_log_events" call: