[−][src]Crate rusoto_logs
You can use Amazon CloudWatch Logs to monitor, store, and access your log files from Amazon EC2 instances, AWS CloudTrail, or other sources. You can then retrieve the associated log data from CloudWatch Logs using the CloudWatch console, CloudWatch Logs commands in the AWS CLI, CloudWatch Logs API, or CloudWatch Logs SDK.
You can use CloudWatch Logs to:
-
Monitor logs from EC2 instances in real-time: You can use CloudWatch Logs to monitor applications and systems using log data. For example, CloudWatch Logs can track the number of errors that occur in your application logs and send you a notification whenever the rate of errors exceeds a threshold that you specify. CloudWatch Logs uses your log data for monitoring; so, no code changes are required. For example, you can monitor application logs for specific literal terms (such as "NullReferenceException") or count the number of occurrences of a literal term at a particular position in log data (such as "404" status codes in an Apache access log). When the term you are searching for is found, CloudWatch Logs reports the data to a CloudWatch metric that you specify.
-
Monitor AWS CloudTrail logged events: You can create alarms in CloudWatch and receive notifications of particular API activity as captured by CloudTrail and use the notification to perform troubleshooting.
-
Archive log data: You can use CloudWatch Logs to store your log data in highly durable storage. You can change the log retention setting so that any log events older than this setting are automatically deleted. The CloudWatch Logs agent makes it easy to quickly send both rotated and non-rotated log data off of a host and into the log service. You can then access the raw log data when you need it.
If you're using the service, you're probably looking for CloudWatchLogsClient and CloudWatchLogs.
Examples
Put Log Events
The following code shows a simple example of using Rusoto's CloudWatchLogs API to send a single log event to the 'testing' log stream in the 'testing' log group.
extern crate chrono; extern crate rusoto_core; extern crate rusoto_logs; use chrono::{Utc}; use std::default::Default; use rusoto_core::Region; use rusoto_logs::{CloudWatchLogs, CloudWatchLogsClient, DescribeLogStreamsRequest, InputLogEvent, PutLogEventsRequest}; fn main() { const LOG_GROUP_NAME: &'static str = "testing"; const LOG_STREAM_NAME: &'static str = "testing"; let client = CloudWatchLogsClient::new(Region::UsEast2); let input_log_event = InputLogEvent { message: "Test log message".to_string(), timestamp: Utc::now().timestamp_millis(), // milliseconds epoch }; // We need the log stream to get the sequence token let mut desc_streams_req: DescribeLogStreamsRequest = Default::default(); desc_streams_req.log_group_name = LOG_GROUP_NAME.to_string(); let streams_resp = client.describe_log_streams(desc_streams_req).sync(); let log_streams = streams_resp.unwrap().log_streams.unwrap(); let stream = &log_streams .iter() .find(|s| s.log_stream_name == Some(LOG_STREAM_NAME.to_string())) .unwrap(); let sequence_token = stream.upload_sequence_token.clone(); let put_log_events_request = PutLogEventsRequest { log_events: vec![input_log_event], // > 1 must sort by timestamp ASC log_group_name: LOG_GROUP_NAME.to_string(), log_stream_name: LOG_STREAM_NAME.to_string(), sequence_token: sequence_token, }; let resp = client.put_log_events(put_log_events_request).sync(); println!("{:#?}", resp); }
Structs
Enums
AssociateKmsKeyError | Errors returned by AssociateKmsKey |
CancelExportTaskError | Errors returned by CancelExportTask |
CreateExportTaskError | Errors returned by CreateExportTask |
CreateLogGroupError | Errors returned by CreateLogGroup |
CreateLogStreamError | Errors returned by CreateLogStream |
DeleteDestinationError | Errors returned by DeleteDestination |
DeleteLogGroupError | Errors returned by DeleteLogGroup |
DeleteLogStreamError | Errors returned by DeleteLogStream |
DeleteMetricFilterError | Errors returned by DeleteMetricFilter |
DeleteResourcePolicyError | Errors returned by DeleteResourcePolicy |
DeleteRetentionPolicyError | Errors returned by DeleteRetentionPolicy |
DeleteSubscriptionFilterError | Errors returned by DeleteSubscriptionFilter |
DescribeDestinationsError | Errors returned by DescribeDestinations |
DescribeExportTasksError | Errors returned by DescribeExportTasks |
DescribeLogGroupsError | Errors returned by DescribeLogGroups |
DescribeLogStreamsError | Errors returned by DescribeLogStreams |
DescribeMetricFiltersError | Errors returned by DescribeMetricFilters |
DescribeQueriesError | Errors returned by DescribeQueries |
DescribeResourcePoliciesError | Errors returned by DescribeResourcePolicies |
DescribeSubscriptionFiltersError | Errors returned by DescribeSubscriptionFilters |
DisassociateKmsKeyError | Errors returned by DisassociateKmsKey |
FilterLogEventsError | Errors returned by FilterLogEvents |
GetLogEventsError | Errors returned by GetLogEvents |
GetLogGroupFieldsError | Errors returned by GetLogGroupFields |
GetLogRecordError | Errors returned by GetLogRecord |
GetQueryResultsError | Errors returned by GetQueryResults |
ListTagsLogGroupError | Errors returned by ListTagsLogGroup |
PutDestinationError | Errors returned by PutDestination |
PutDestinationPolicyError | Errors returned by PutDestinationPolicy |
PutLogEventsError | Errors returned by PutLogEvents |
PutMetricFilterError | Errors returned by PutMetricFilter |
PutResourcePolicyError | Errors returned by PutResourcePolicy |
PutRetentionPolicyError | Errors returned by PutRetentionPolicy |
PutSubscriptionFilterError | Errors returned by PutSubscriptionFilter |
StartQueryError | Errors returned by StartQuery |
StopQueryError | Errors returned by StopQuery |
TagLogGroupError | Errors returned by TagLogGroup |
TestMetricFilterError | Errors returned by TestMetricFilter |
UntagLogGroupError | Errors returned by UntagLogGroup |
Traits
CloudWatchLogs | Trait representing the capabilities of the Amazon CloudWatch Logs API. Amazon CloudWatch Logs clients implement this trait. |