-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add CLI examples for CloudWatch Logs-v2
- Loading branch information
1 parent
530df55
commit 216f71e
Showing
60 changed files
with
1,335 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
**To associate a KMS key with the log group** | ||
|
||
The following ``associate-kms-key`` example associates KMS key with log group named ``demo-log-group``. :: | ||
|
||
aws logs associate-kms-key \ | ||
--log-group-name demo-log-group \ | ||
--kms-key-id 1234abcd-12ab-34cd-56ef-1234567890ab | ||
|
||
This command produces no output. | ||
|
||
For more information, see `Encrypt log data in CloudWatch Logs using AWS Key Management Service <https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/encrypt-log-data-kms.html>`__ in the *Amazon CloudWatch Logs User Guide*. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
**To cancel an export task** | ||
|
||
The following ``cancel-export-task`` example cancels the export task with id ``a1b2c3d4-5678-90ab-cdef-example12345``. :: | ||
|
||
aws logs cancel-export-task \ | ||
--task-id a1b2c3d4-5678-90ab-cdef-example12345 | ||
|
||
This command produces no output. | ||
|
||
For more information, see `Exporting log data to Amazon S3 <https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/S3Export.html>`__ in the *Amazon CloudWatch Logs User Guide*. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
**To create a delivery** | ||
|
||
The following ``create-delivery`` example creates a delivery between a source and destination. :: | ||
|
||
aws logs create-delivery \ | ||
--delivery-source-name demo-delivery-source \ | ||
--delivery-destination-arn arn:aws:logs:us-east-1:123456789012:delivery-destination:demo-delivery-destination | ||
|
||
Output:: | ||
|
||
{ | ||
"delivery": { | ||
"id": "Example1abcde2eCK", | ||
"arn": "arn:aws:logs:us-east-1:123456789012:delivery:Example1abcde2eCK", | ||
"deliverySourceName": "demo-delivery-source", | ||
"deliveryDestinationArn": "arn:aws:logs:us-east-1:123456789012:delivery-destination:demo-delivery-destination", | ||
"deliveryDestinationType": "CWL", | ||
"recordFields": [ | ||
"event_timestamp", | ||
"resource_id", | ||
"log_level", | ||
"event_message" | ||
], | ||
"fieldDelimiter": "" | ||
} | ||
} | ||
|
||
For more information, see `Enable logging from AWS services <https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/AWS-logs-and-resource-policy.html>`__ in the *Amazon CloudWatch Logs User Guide*. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
**To create an export task ** | ||
The following ``create-export-task`` example creates an export task to export data from a log group named ``demo-log-group`` to an Amazon S3 bucket named ``amzn-s3-demo-bucket``. :: | ||
|
||
aws logs create-export-task \ | ||
--log-group-name demo-log-group \ | ||
--from 1715918400 \ | ||
--to 1715920200 \ | ||
--destination amzn-s3-demo-bucket | ||
|
||
Output:: | ||
|
||
{ | ||
"taskId": "a1b2c3d4-5678-90ab-cdef-example11111" | ||
} | ||
|
||
For more information, see `Exporting log data to Amazon S3 <https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/S3Export.html>`__ in the *Amazon CloudWatch Logs User Guide*. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
**To create an anomaly detector** | ||
|
||
The following ``create-log-anomaly-detector`` example creates an anomaly detector named ``demo_anomaly_detector``. :: | ||
|
||
aws logs create-log-anomaly-detector \ | ||
--log-group-arn-list arn:aws:logs:us-east-1:123456789012:log-group:demo-log-group \ | ||
--detector-name demo_anomaly_detector | ||
|
||
Output:: | ||
|
||
{ | ||
"anomalyDetectorArn": "arn:aws:logs:us-east-1:123456789012:anomaly-detector:a1b2c3d4-5678-90ab-cdef-example11111" | ||
} | ||
|
||
For more information, see `Log anomaly detection <https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/LogsAnomalyDetection.html>`__ in the *Amazon CloudWatch Logs User Guide*. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
**To delete a CloudWatch Logs account policy** | ||
|
||
The following ``delete-account-policy`` example deletes a CloudWatch Logs account policy. :: | ||
|
||
aws logs delete-account-policy \ | ||
--policy-name Example_Data_Protection_Policy \ | ||
--policy-type DATA_PROTECTION_POLICY | ||
|
||
This command produces no output. | ||
|
||
For more information, see `Help protect sensitive log data with masking <https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/mask-sensitive-log-data.html>`__ in the *Amazon CloudWatch Logs User Guide*. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
**To delete the data protection policy from the specified log group** | ||
|
||
The following ``delete-data-protection-policy`` example deletes the data protection policy from the log group named ``demo-log-group``. :: | ||
|
||
aws logs delete-data-protection-policy \ | ||
--log-group-identifier demo-log-group | ||
|
||
This command produces no output. | ||
|
||
For more information, see `Help protect sensitive log data with masking <https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/mask-sensitive-log-data.html>`__ in the *Amazon CloudWatch Logs User Guide*. |
10 changes: 10 additions & 0 deletions
10
awscli/examples/logs/delete-delivery-destination-policy.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
**To delete a delivery destination policy** | ||
|
||
The following ``delete-delivery-destination-policy`` example deletes the policy for delivery destination named ``demo-delivery-destination``. :: | ||
|
||
aws logs delete-delivery-destination-policy \ | ||
--delivery-destination-name demo-delivery-destination | ||
|
||
This command produces no output. | ||
|
||
For more information, see `Enable logging from AWS services <https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/AWS-logs-and-resource-policy.html>`__ in the *Amazon CloudWatch Logs User Guide*. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
**To delete a delivery destination** | ||
|
||
The following ``delete-delivery-destination`` example deletes a delivery destination named ``demo-delivery-destination``. :: | ||
|
||
aws logs delete-delivery-destination \ | ||
--name demo-delivery-destination | ||
|
||
This command produces no output. | ||
|
||
For more information, see `Enable logging from AWS services <https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/AWS-logs-and-resource-policy.html>`__ in the *Amazon CloudWatch Logs User Guide*. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
**To delete a delivery source** | ||
|
||
The following ``delete-delivery-source`` example deletes a delivery source named ``delete-delivery-source``. :: | ||
|
||
aws logs delete-delivery-source \ | ||
--name demo-delivery-source | ||
|
||
This command produces no output. | ||
|
||
For more information, see `Enable logging from AWS services <https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/AWS-logs-and-resource-policy.html>`__ in the *Amazon CloudWatch Logs User Guide*. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
**To delete a delivery** | ||
|
||
The following ``delete-delivery`` example deletes a delivery. :: | ||
|
||
aws logs delete-delivery \ | ||
--id Example1abcde2eCK | ||
|
||
This command produces no output. | ||
|
||
For more information, see `Enable logging from AWS services <https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/AWS-logs-and-resource-policy.html>`__ in the *Amazon CloudWatch Logs User Guide*. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
**To delete the specified destination** | ||
|
||
The following ``delete-destination`` example deletes the destination named ``demoDestination``, and disables all the subscription filters that publish to it. :: | ||
|
||
aws logs delete-destination \ | ||
--destination-name demoDestination | ||
|
||
This command produces no output. | ||
|
||
For more information, see `Cross-account cross-Region subscriptions <https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/CrossAccountSubscriptions.html>`__ in the *Amazon CloudWatch Logs User Guide*. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
**To delete an anomaly detector** | ||
|
||
The following ``delete-log-anomaly-detector`` example deletes an anomaly detector named ``demo_anomaly_detector``. :: | ||
|
||
aws logs delete-log-anomaly-detector \ | ||
--anomaly-detector-arn arn:aws:logs:us-east-1:123456789012:anomaly-detector:a1b2c3d4-5678-90ab-cdef-example11111 | ||
|
||
This command produces no output. | ||
|
||
For more information, see `Log anomaly detection <https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/LogsAnomalyDetection.html>`__ in the *Amazon CloudWatch Logs User Guide*. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
**To delete the specified metric filter** | ||
|
||
The following ``delete-metric-filter`` example deletes the metric filter named ``demoFilter``. :: | ||
|
||
aws logs delete-metric-filter \ | ||
--log-group-name demo-log-group \ | ||
--filter-name demoMetricFilter | ||
|
||
This command produces no output. | ||
|
||
For more information, see `Creating metrics from log events using filters <https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/MonitoringLogData.html>`__ in the *Amazon CloudWatch Logs User Guide*. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
**To delete a CloudWatch Logs Insights query definition** | ||
|
||
The following ``delete-query-definition`` example deletes a saved CloudWatch Logs Insights query definition. :: | ||
|
||
aws logs delete-query-definition \ | ||
--query-definition-id a1b2c3d4-5678-90ab-cdef-example11111 | ||
|
||
Output:: | ||
|
||
{ | ||
"success": true | ||
} | ||
|
||
For more information, see `Analyzing log data with CloudWatch Logs Insights <https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/AnalyzingLogData.html>`__ in the *Amazon CloudWatch Logs User Guide*. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
**To delete a resource policy from the account** | ||
|
||
The following ``delete-resource-policy`` example deletes the resource policy named ``demo-logs-policy`` from the account. :: | ||
|
||
aws logs delete-resource-policy \ | ||
--policy-name "demo-logs-policy" | ||
|
||
This command produces no output. | ||
|
||
For more information, see `Log anomaly detection <https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/LogsAnomalyDetection.html>`__ in the *Amazon CloudWatch Logs User Guide*. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
**To delete subscription filter** | ||
|
||
The following ``delete-subscription-filter`` example deletes the subscription filter named ``demo-subscription-filter``. :: | ||
|
||
aws logs delete-subscription-filter \ | ||
--log-group-name demo-log-group \ | ||
--filter-name demo-subscription-filter | ||
|
||
This command produces no output. | ||
|
||
For more information, see `Real-time processing of log data with subscriptions <https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/Subscriptions.html>`__ in the *Amazon CloudWatch User Guide*. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
**To return a list of all CloudWatch Logs account policies** | ||
|
||
The following ``describe-account-policies`` example returns a list of all CloudWatch Logs account policies in the account. :: | ||
|
||
aws logs describe-account-policies \ | ||
--policy-type DATA_PROTECTION_POLICY | ||
|
||
Output:: | ||
|
||
{ | ||
"accountPolicies": [ | ||
{ | ||
"policyName": "Example_Data_Protection_Policy", | ||
"policyDocument": "{\n\"Name\": \"ACCOUNT_DATA_PROTECTION_POLICY\",\n\"Description\": \"\",\n\"Version\": \"2021-06-01\",\n\"Statement\": [{\n\"Sid\": \"audit-policy\",\n\"DataIdentifier\": [\"arn:aws:dataprotection::aws:data-identifier/Address\", \"arn:aws:dataprotection::aws:data-identifier/CreditCardNumber\", \"arn:aws:dataprotection::aws:data-identifier/DriversLicense-US\", \"arn:aws:dataprotection::aws:data-identifier/EmailAddress\"],\n\"Operation\": {\n\"Audit\": {\n\"FindingsDestination\": {\n\"CloudWatchLogs\": {\n\"LogGroup\": \"AuditLogGroup\"\n}\n}\n}\n}\n}, {\n\"Sid\": \"redact-policy\",\n\"DataIdentifier\": [\"arn:aws:dataprotection::aws:data-identifier/Address\", \"arn:aws:dataprotection::aws:data-identifier/CreditCardNumber\", \"arn:aws:dataprotection::aws:data-identifier/DriversLicense-US\", \"arn:aws:dataprotection::aws:data-identifier/EmailAddress\"],\n\"Operation\": {\n\"Deidentify\": {\n\"MaskConfig\": {}\n}\n}\n}]\n}\n", | ||
"lastUpdatedTime": 1724944519097, | ||
"policyType": "DATA_PROTECTION_POLICY", | ||
"scope": "ALL", | ||
"accountId": "123456789012" | ||
} | ||
] | ||
} | ||
|
||
For more information, see `Account-level subscription filters <https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/SubscriptionFilters-AccountLevel.html>`__ in the *Amazon CloudWatch Logs User Guide*. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
**To retrieve a list of the deliveries** | ||
|
||
The following ``describe-deliveries`` example retrieves a list of the deliveries that have been created in the account. :: | ||
|
||
aws logs describe-deliveries | ||
|
||
Output:: | ||
|
||
{ | ||
"deliveries": [ | ||
{ | ||
"id": "Example2abcde3eCK", | ||
"arn": "arn:aws:logs:us-east-1:123456789012:delivery:Example2abcde3eCK", | ||
"deliverySourceName": "demo-delivery-source", | ||
"deliveryDestinationArn": "arn:aws:logs:us-east-1:123456789012:delivery-destination:demo-delivery-destination" | ||
}, | ||
{ | ||
"id": "Example1abcde2eCK", | ||
"arn": "arn:aws:logs:us-east-1:123456789012:delivery:Example1abcde2eCK", | ||
"deliverySourceName": "example-delivery-source", | ||
"deliveryDestinationArn": "arn:aws:logs:us-east-1:123456789012:delivery-destination:example-delivery-destination" | ||
} | ||
] | ||
} | ||
|
||
For more information, see `Enable logging from AWS services <https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/AWS-logs-and-resource-policy.html>`__ in the *Amazon CloudWatch Logs User Guide*. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
**To retrieve a list of the delivery destinations** | ||
|
||
The following ``describe-delivery-destinations`` example retrieves a list of delivery destinations that have been created in the account. :: | ||
|
||
aws logs describe-delivery-destinations | ||
|
||
Output:: | ||
|
||
{ | ||
"deliveryDestinations": [ | ||
{ | ||
"name": "KinesisFirehose", | ||
"arn": "arn:aws:logs:us-east-1:123456789012:delivery-destination:KinesisFirehose", | ||
"deliveryDestinationType": "FH", | ||
"deliveryDestinationConfiguration": { | ||
"destinationResourceArn": "arn:aws:firehose:us-east-1:123456789012:deliverystream/PUT-S3-Tlha6" | ||
} | ||
}, | ||
{ | ||
"name": "demo-delivery-destination", | ||
"arn": "arn:aws:logs:us-east-1:123456789012:delivery-destination:demo-delivery-destination", | ||
"deliveryDestinationType": "CWL", | ||
"deliveryDestinationConfiguration": { | ||
"destinationResourceArn": "arn:aws:logs:us-east-1:123456789012:log-group:code-whisperer-logs:*" | ||
} | ||
}, | ||
{ | ||
"name": "example-delivery-destination", | ||
"arn": "arn:aws:logs:us-east-1:123456789012:delivery-destination:example-delivery-destination", | ||
"deliveryDestinationType": "S3", | ||
"deliveryDestinationConfiguration": { | ||
"destinationResourceArn": "arn:aws:s3:::code-whisperer-s3-bucket-test" | ||
} | ||
} | ||
] | ||
} | ||
|
||
For more information, see `Enable logging from AWS services <https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/AWS-logs-and-resource-policy.html>`__ in the *Amazon CloudWatch Logs User Guide*. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
**To retrieve a list of the delivery sources** | ||
|
||
The following ``describe-delivery-sources`` example retrieves a list of the delivery sources that have been created in the account. :: | ||
|
||
aws logs describe-delivery-sources | ||
|
||
Output:: | ||
|
||
{ | ||
"deliverySources": [ | ||
{ | ||
"name": "demo-delivery-source", | ||
"arn": "arn:aws:logs:us-east-1:123456789012:delivery-source:demo-delivery-source", | ||
"resourceArns": [ | ||
"arn:aws:codewhisperer:us-east-1:123456789012:customization/ABC1DE2FGHI" | ||
], | ||
"service": "codewhisperer", | ||
"logType": "EVENT_LOGS" | ||
} | ||
] | ||
} | ||
|
||
For more information, see `Enable logging from AWS services <https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/AWS-logs-and-resource-policy.html>`__ in the *Amazon CloudWatch Logs User Guide*. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
**To list all your destinations** | ||
|
||
The following ``describe-destinations`` example lists all your destinations. :: | ||
|
||
aws logs describe-destinations | ||
|
||
Output:: | ||
|
||
{ | ||
"destinations": [ | ||
{ | ||
"destinationName": "demoDestination", | ||
"targetArn": "arn:aws:kinesis:us-east-1:123456789012:stream/RecipientStream", | ||
"roleArn": "arn:aws:iam::123456789012:role/CWLtoKinesisRole", | ||
"arn": "arn:aws:logs:us-east-1:123456789012:destination:demoDestination", | ||
"creationTime": 1705327053863 | ||
} | ||
] | ||
} | ||
|
||
For more information, see `Cross-account cross-Region subscriptions <https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/CrossAccountSubscriptions.html>`__ in the *Amazon CloudWatch Logs User Guide*. |
Oops, something went wrong.