Loading...
Loading...
Configures log and metric export for CockroachDB Cloud clusters to external monitoring services including AWS CloudWatch, GCP Cloud Logging, and Datadog. Use when setting up log export for audit compliance, configuring metric export for monitoring, or troubleshooting log delivery issues.
npx skill4agent add cockroachlabs/cockroachdb-skills configuring-log-exportccloud cluster listccloud auth whoami
ccloud cluster info <cluster-name> -o json
# Look for "plan": "ADVANCED"cloudwatch:PutMetricData# Check if log export is currently configured
ccloud cluster info <cluster-name> -o json
# Look for "log_export_config" in the outputFollow this section only if the user selected AWS CloudWatch in Decision 1. Skip to Step 3 if using GCP Cloud Logging.
# Create a log group in AWS (if it doesn't exist)
aws logs create-log-group \
--log-group-name cockroachdb-<cluster-name> \
--region <aws-region>
# Set retention policy (recommended)
aws logs put-retention-policy \
--log-group-name cockroachdb-<cluster-name> \
--retention-in-days 90 \
--region <aws-region>logs:CreateLogStreamlogs:PutLogEventslogs:DescribeLogGroupslogs:DescribeLogStreams# Enable log export to CloudWatch
ccloud cluster log-export create <cluster-id> \
--log-group-name cockroachdb-<cluster-name> \
--auth-principal <iam-role-arn> \
--type AWS_CLOUDWATCH \
--region <aws-region>Follow this section only if the user selected GCP Cloud Logging in Decision 1. Skip if using AWS CloudWatch.
gcloud services enable logging.googleapis.com# Get the CockroachDB Cloud service account from ccloud cluster info
# Grant Logs Writer role
gcloud projects add-iam-policy-binding <gcp-project-id> \
--member="serviceAccount:<cockroachdb-service-account>" \
--role="roles/logging.logWriter"ccloud cluster log-export create <cluster-id> \
--auth-principal <gcp-project-id> \
--type GCP_CLOUD_LOGGINGSkip this section if the user selected Skip in Decision 2. Follow only the relevant subsection (4.1 or 4.2) based on the selected metric export destination.
ccloud cluster metric-export create cloudwatch <cluster-id> \
--role-arn <iam-role-arn> \
--target-region <aws-region>cloudwatch:PutMetricDataccloud cluster metric-export create datadog <cluster-id> \
--api-key <datadog-api-key> \
--site <datadog-site>datadoghq.comdatadoghq.euus3.datadoghq.comus5.datadoghq.com# Check log export status
ccloud cluster log-export list <cluster-id> -o json
# Status should be ENABLED
# Check metric export status
ccloud cluster metric-export list <cluster-id> -o json# Check for recent log streams
aws logs describe-log-streams \
--log-group-name cockroachdb-<cluster-name> \
--order-by LastEventTime \
--descending \
--limit 5 \
--region <aws-region>
# Tail recent log events
aws logs tail cockroachdb-<cluster-name> \
--since 1h \
--region <aws-region>-- Check audit logging is enabled
SHOW CLUSTER SETTING sql.log.admin_audit.enabled;
SHOW CLUSTER SETTING sql.log.user_audit;resource "cockroach_log_export_config" "main" {
id = cockroach_cluster.main.id
auth_principal = "<iam-role-arn>"
log_name = "cockroachdb-${cockroach_cluster.main.name}"
type = "AWS_CLOUDWATCH"
region = "<aws-region>"
}
resource "cockroach_metric_export_cloudwatch_config" "main" {
id = cockroach_cluster.main.id
role_arn = "<iam-role-arn>"
target_region = "<aws-region>"
}terraform apply| Impact Type | Severity | Recommendation |
|---|---|---|
| Log export enabling | Low | No impact on cluster operation |
| Log export disabling | Low | Stops log delivery but does not affect cluster |
| IAM misconfiguration | Medium | Log export will fail silently; monitor for delivery gaps |
| Cost impact | Medium | High-volume clusters can generate significant CloudWatch/logging costs |
| Terraform race condition | Medium | Apply cluster creation before log/CMEK config |
# Disable log export
ccloud cluster log-export delete <cluster-id>
# Disable metric export
ccloud cluster metric-export delete cloudwatch <cluster-id>
ccloud cluster metric-export delete datadog <cluster-id>