Log Collection Settings
Database Cloud Agent can periodically collect various logs, including RDS and Aurora instances, using the AWS CloudWatch Logs API.
This document explains how the API affects costs and provides guidance on configuring collection settings appropriately.
NCP Cloud DB for PostgreSQL collects logs through Object Storage. For setup, see NCP Cloud DB log collection.
Using CloudWatch Logs API and Cost Impact
The DBXC Agent uses the CloudWatch Logs FilterLogEvents API to query already stored logs.
The cost incurred is determined mainly by two factors:
First, the amount of data retrieved. When the API is called, it fetches logs from CloudWatch Logs within the specified time range and limit (regular_fetch_limit). The larger the volume of data retrieved, the higher the cost due to AWS internal processing and data transfer.
Second, the number of API calls. If the interval is short or there are many target log groups, frequent API calls occur periodically. Since API calls themselves are billed, frequent calls at short intervals may accumulate costs even if the data volume is small.
As a result, in log collection using FilterLogEvents, the amount of retrieved data has a greater impact on costs. However, using short intervals with many target groups makes API call costs also significant.
Therefore, for efficient operation, avoid fetching unnecessarily large volumes of logs at once with regular_fetch_limit, and adjust the interval according to your environment to control the number of calls.
Official References
- AWS API Reference: FilterLogEvents
- AWS Pricing: CloudWatch Logs Pricing
Log Collection Mechanism
The DBXC Agent periodically calls the FilterLogEvents API to fetch new logs from specified log groups.
At each call, it queries only logs between the last collection time and the current time, managing collection status separately for each log group.
The last collection time is stored in a local state file, so even after restarting the agent, collection resumes from the previous point.
Recommended Settings by Environment
All settings require specifying the actual log group list in logs.groups, and log collection requires logs:FilterLogEvents and logs:DescribeLogGroups permissions.
General Production Environment (Default)
logs:
groups:
- "/aws/rds/instance/prod-mysql/error"
- "/aws/rds/instance/prod-mysql/general"
interval: 60
regular_fetch_limit: 1000
This is the agent’s default configuration, applied even if not explicitly defined in the config file. It prevents unnecessary bulk log retrieval at service startup and stably collects up to 1,000 logs per cycle afterward. With a good balance of real-time performance, stability, and cost efficiency, this setting suits most production environments.
Real-time Oriented Environment
logs:
groups:
- "/aws/rds/cluster/prod-aurora/audit"
- "/aws/rds/cluster/prod-aurora/error"
interval: 30
regular_fetch_limit: 200
Collecting logs every 30 seconds minimizes latency while reducing memory usage by limiting the amount retrieved at once. However, since the number of API calls increases, this setup may raise API call costs and should be used only for services requiring strong real-time capabilities.
Cost-optimized Environment
logs:
groups:
- "/aws/rds/instance/mysql/error"
interval: 300
regular_fetch_limit: 500
Collecting logs every 5 minutes significantly reduces API call frequency and lowers costs. However, it introduces up to a 5-minute delay in log reflection, making it unsuitable for environments where real-time monitoring is critical.
Tuning Guidelines
If API costs are higher than expected, increase the interval or reduce regular_fetch_limit.
If log loss is a concern, reduce the interval. If memory usage is high, reduce regular_fetch_limit or decrease the number of target log groups.
IAM Permission Configuration
{
"Effect": "Allow",
"Action": [
"logs:FilterLogEvents",
"logs:DescribeLogGroups"
],
"Resource": "arn:aws:logs:*:*:log-group:/aws/rds/*"
}
The agent queries logs.groups using its default role. Grant the permissions above to the role set in input.assume_role_arn, or, if it is not set, to the role of the EC2 Instance Profile where the agent runs. clusters.account_configs[].assume_role_arn is not used to query logs.groups.
To verify the permissions before starting the agent, run dbxc-ctl validate -c config.yaml. It calls FilterLogEvents on each log group and reports ERROR on failure.
NCP Cloud DB log collection
You can collect DB logs from NCP Cloud DB for PostgreSQL (VPC) and view them on the WhaTap log screens. For basic agent settings, see Cloud Agent Configuration.
How it works
NCP provides no API for querying log content. The agent exports log files to an Object Storage bucket and then reads the logs from the bucket.
For each DB server specified in input.instances, the agent repeats the following steps every 5 minutes.
-
Retrieves the list of log files.
-
Exports only the log files that have grown since the previous cycle to the bucket.
-
Reads the logs after the previously read position from the exported objects and sends them to the WhaTap collection server.
-
Deletes the read objects from the bucket.
-
The agent collects only logs written after log collection is first enabled.
-
Because log files go through an export step, logs appear with a delay of up to 5 minutes.
-
Log files whose size has not changed are not exported. If there are no new logs, the agent only retrieves the list of log files.
-
The agent saves the read position of each log file in a local state file. After a restart, the agent resumes collection from the saved position.
Prerequisites
Object Storage bucket
Create a bucket for exported logs in advance, in the same site (site) as the DB server.
Authentication key permissions
Log collection uses the same accessKey and secretKey as metric collection. The main account authentication key needs no additional permissions. If you use a Sub Account authentication key, grant the following policies.
| Target | Managed policy | Actions required for a custom policy |
|---|---|---|
| Cloud DB for PostgreSQL | NCP_VPC_CLOUD_DB_FOR_POSTGRESQL_MANAGER | View/getDBServerLogs, Change/exportDBServerLogsToObjectStorage |
| Object Storage | NCP_OBJECT_STORAGE_MANAGER | - |
-
Log export is a Change action, so the Cloud DB
VIEWERpolicy cannot collect logs. -
When you select
Change/exportDBServerLogsToObjectStoragein a custom policy, related actions are selected together. Do not deselect the related actions. -
Object Storage custom policies have no object read or delete actions, and the
NCP_OBJECT_STORAGE_VIEWERpolicy has no object delete permission. The agent deletes objects after reading them, so grant theNCP_OBJECT_STORAGE_MANAGERpolicy.
Official references
Configuration
Add the input.logs item to your existing NCP settings.
input:
csp: "ncp"
namespace: "vpc_postgresql"
region: "KR"
accessKey: "YOUR_ACCESS_KEY"
secretKey: "YOUR_SECRET_KEY"
instances:
- name: "instance-name"
domain: "pg-xxxxx.vpc-pub-cdb-kr.ntruss.com"
metrics:
- "cpu_user"
logs:
enabled: true
interval: 300
ncp:
bucket: "my-dbxc-logs"
folder_path: "dbxc"
keep_exported: false
| Field | Description |
|---|---|
logs.enabled | Whether to collect logs - true: Collect- false: Do not collect (default) |
logs.interval | (Optional) Log collection interval (seconds) - Minimum: 300- Values below 300 run as 300 |
logs.ncp.bucket | Name of the Object Storage bucket to export logs to - If empty, logs are not collected |
logs.ncp.folder_path | (Optional) Folder path in the bucket - If empty, logs are exported to the bucket root |
logs.ncp.log_types | (Optional) Log types to collect - Supported value: POSTGRESQL_LOG (default) |
logs.ncp.keep_exported | (Optional) Whether to keep read objects - true: Keep- false: Delete (default) |
NCP does not use the AWS logs.groups item. The agent collects all logs from the DB servers specified in instances.
Bucket usage
NCP creates a new object each time a log file is exported. Each object contains the entire log file at the time of export. The object name format is <folder_path>/<DB Server name>_<log file name>.<Unix time (seconds)>.
-
With the default setting (
keep_exported: false), the agent deletes objects immediately after reading them. -
With
keep_exported: true, a full copy of the log file accumulates in the bucket in every cycle in which the log grows. Set a retention period with a Lifecycle policy on the bucket. -
Objects that the agent fails to delete remain in the bucket. Set a Lifecycle policy on the bucket even with the default setting.
Verifying collection
In the agent log, check that the NCPLogs-<instance number> task runs every 5 minutes for each DB server. WhaTap displays collected logs with the category #NCP_LOG. The log_group tag is the log type, and the log_stream tag is the log file name.
| Agent log | Cause and action |
|---|---|
input.logs.ncp.bucket is empty; logs will not be collected | logs.ncp.bucket not set |
list_ncp_logs_failed | Failed to retrieve log file list - Check authentication key permissions, instances[].name, and region |
export_ncp_log_failed | Failed to export logs - Check bucket name, bucket site, and export permission |
collect_ncp_logs_failed | Failed to read logs from the bucket - Check Object Storage permissions |
delete_ncp_log_objects_failed | Failed to delete read objects. Collection continues, but objects accumulate in the bucket - Check Object Storage permissions |
Renaming the configuration file also changes the state file, so the agent starts collecting again from that point, as it does on first run.