Before You Begin
Amazon DocumentDB Elastic Clusters are not supported.
Direct Connection Requirement
The Atatus Infra Agent must connect directly to each DocumentDB instance being monitored. Do not use connection strings or SRV endpoints, as automatic failover or load balancing can route the Agent to a different host, resulting in inaccurate metrics. If you use Terraform, this is handled for you: give it the cluster identifier and it discovers the members and writes one entry per instance. See Replica sets.Setup Database Access for the Agent
The Atatus Infra Agent requires read-only access to collect statistics and queries from your Amazon DocumentDB instances.-
Connect to the primary node of your DocumentDB cluster using the Mongo shell and authenticate as the admin user:
-
Create a read-only monitoring user for the Atatus Infra Agent:
-
Grant read access to specific databases you want to monitor (Optional):
Alternatively, to monitor all databases, grant the
readAnyDatabaserole:
Configure Atatus Infrastructure Agent
-
To enable Database Monitoring for your databases, install the Atatus Infrastructure Agent on a host that has network access to your Amazon DocumentDB instances. This can be a Linux host, a Docker container, or a Kubernetes pod.
The Agent must connect consistently to the same DocumentDB host. Avoid connecting through load balancers, proxies, or rotating endpoints.
-
Copy the MongoDB example configuration file:
-
Update the MongoDB configuration file.
Add the following configuration to
/etc/atatus-infra-agent/conf.d/mongodb.d/mongodb.yml. Single Instance:Replica Set (1 Primary + 2 Secondaries):Amazon DocumentDB requires TLS. Ensuretls: trueis set and provide the CA certificate path viatls_ca_file. Download the Amazon DocumentDB CA certificate from the AWS documentation. -
Restart the Atatus Infrastructure Agent:
This restarts the agent on the host, not your database. It is safe to run at any time. The only effect is a gap in collection of a few seconds while the agent comes back, and your clusters keep serving throughout.
Set it up with Terraform
The agent host, the TLS material, instance discovery and the$external user
can all be provisioned instead of configured by hand. That has its own page,
including how to monitor PostgreSQL from the same host:
The working Terraform is at
atatus-database-monitoring-sample.
Authenticating with IAM
Amazon DocumentDB can authenticate an IAM principal, so the agent needs no database password. Access is then revoked by editing IAM or dropping the mapped user, rather than by rotating a password every host holds a copy of. This needs Atatus Infra Agent 4.3.0 or newer.This is not the same mechanism PostgreSQL uses. RDS PostgreSQL mints a short
lived
rds-db:connect token and presents it as the password, which is why it
needs an IAM policy naming a dbuser ARN. DocumentDB has no such token: the
driver signs each handshake itself using the MONGODB-AWS SASL mechanism.
There is no IAM policy to attach for DocumentDB.Map the agent’s role to a database user
Instead of an IAM policy, you create a user inside the cluster whose name is the agent’s role ARN. Connect to the primary as your admin user:Configure the agent
Removeusername and password, and add an aws block:
TLS stays mandatory and always verifies both the certificate and the hostname.
ssl_mode accepts require, verify-ca and verify-full, which all verify:
the MongoDB driver has no weaker setting, and the modes permitting an
unencrypted connection are rejected outright.
Monitoring a cluster in another AWS account
The agent’s own credentials are used only to callsts:AssumeRole. The
handshake is then signed with the temporary credentials that role returns, so
it is that role’s ARN you map to a $external user above:
Turning it on in Terraform
use_managed_authentication covers both engines, so one host can run
PostgreSQL and DocumentDB on IAM together:
$external user has to exist before the agent can connect, and Terraform
has no connection to the cluster, so the order is: apply, read
agent_iam_role_arn, create the user, then restart the agent.
While you finish that mapping, keep DocumentDB on a password and PostgreSQL on
IAM:
How instances are discovered
The agent must reach each instance directly, so Terraform expands a cluster into one config entry per instance. It resolves them by callingaws docdb describe-db-clusters at apply time, which means the AWS CLI has to
be available wherever you run Terraform. If it is not, list the endpoints
yourself with instance_endpoints on that cluster, and remember that a
hand written list does not follow a scale out on its own.
Once verified, navigate to the Database Monitoring page in Atatus to view your Amazon DocumentDB performance data.