Datadog quickstart

This quickstart guide will help you get a Datadog agent up and running with Container Apps on Crunchy Bridge. We recommend you start with the Container Apps Quickstart to get a general understanding of Container Apps.

About Datadog

Datadog collects metrics and logs for Postgres and other applications servers and hosts. For Postgres, the agent will monitor PostgreSQL states. You can visualize system metrics including load, cpu usage, i/o wait, memory, and network traffic. You can configure notifications about events and customize to your use cases inside the Datadog dashboard.

Datadog with Postgres container apps quickstart

First, make sure you have Container Apps enabled. As a user with superuser privileges, run CREATE EXTENSION pgpodman; to install the extension in the postgres database of the desired cluster.

You'll also need to locate your API key from Datadog to include as the DD_API_KEY parameter when you start the container.

Create a Datadog user in your database, and note the password to include as the DD_INSTANCES_PASSWORD parameter when you start the container:

CREATE ROLE datadog WITH PASSWORD 'datadog_db_user_password';
GRANT pg_monitor TO datadog;
GRANT SELECT ON pg_stat_database TO datadog;

Create a function so Datadog can collect your system activity:

CREATE FUNCTION pg_stat_activity() RETURNS SETOF pg_catalog.pg_stat_activity AS
$$ SELECT * from pg_catalog.pg_stat_activity; $$
LANGUAGE sql VOLATILE SECURITY DEFINER;

CREATE VIEW pg_stat_activity_dd AS SELECT * FROM pg_stat_activity();
GRANT SELECT ON pg_stat_activity_dd TO datadog;

To start your Datadog collector, run the following using your own values for DD_API_KEY, cluster_id, datadog_db_user, and datadog_db_user_password:

SELECT run_container('-dt -p 5438:5438 -v /proc/:/host/proc/:ro -v /run/user/26/podman/podman.sock:/var/run/docker.sock -v /sys/fs/cgroup/:/host/sys/fs/cgroup:ro --privileged -e DD_PROCESS_AGENT_ENABLED=true -e DD_API_KEY="<dd_api_key_goes_here>" -e DD_HOSTNAME="p.<cluster_id>.db.postgresbridge.com" -e DD_APM_ENABLE=true -e DD_APM_NON_LOCAL_TRAFFIC=true --label com.datadoghq.ad.checks="{\"postgres\": {\"instances\": [{\"host\": \"p.<cluster_id>.db.postgresbridge.com\", \"port\": 5432, \"username\": \"<datadog_db_user>\", \"password\": \"<datadog_db_user_password>\", \"dbname\": \"postgres\", \"ssl\": \"require\"}]}}" docker.io/datadog/agent');

The collector should immediately begin sending data to Datadog. Visit the Datadog documentation for more details on the Datadog collector.

Additional resources

See Datadog's Docker page for information about environment and configuration variables. See Datadog's page on podman support.