The Datadog Agent is a comprehensive monitoring and observability agent written primarily in Go. It collects metrics, traces, logs, and security events from systems and applications, forwarding them to the Datadog platform. This is the main repository for Agent versions 6 and 7.
-
/cmd/- Entry points for various agent componentsagent/- Main agent binarycluster-agent/- Kubernetes cluster agentdogstatsd/- StatsD metrics daemontrace-agent/- APM trace collection agentsystem-probe/- System-level monitoring (eBPF)security-agent/- Security monitoringprocess-agent/- Process monitoring
-
/pkg/- Core Go packages and librariesaggregator/- Metrics aggregationcollector/- Check scheduling and executionconfig/- Configuration managementlogs/- Log collection and processingmetrics/- Metrics types and handlingnetwork/- Network monitoringsecurity/- Security monitoring componentstrace/- APM tracing components
-
/comp/- Component-based architecture modulescore/- Core componentsmetadata/- Metadata collectionlogs/- Log componentstrace/- Trace components
-
/tasks/- Python invoke tasks for development- Build, test, lint, and deployment automation
-
/rtloader/- Runtime loader for Python checks
# install dda on mac OS
brew install --cask dda
# Install development tools
dda inv install-tools
# Build the main agent
dda inv agent.build --build-exclude=systemd
# Build specific components
dda inv dogstatsd.build
dda inv trace-agent.build
dda inv system-probe.build# Run all tests
dda inv test
# Test specific package
dda inv test --targets=./pkg/aggregator
# Run Go linters
dda inv linter.go
# Run all linters
dda inv linter.all# Create dev config with testing API key
echo "api_key: 0000001" > dev/dist/datadog.yaml
# Run the agent
./bin/agent/agent run -c bin/agent/dist/datadog.yamlThe development configuration file should be placed at dev/dist/datadog.yaml. After building, it gets copied to bin/agent/dist/datadog.yaml.
- Checks are Python or Go modules that collect metrics
- Located in
cmd/agent/dist/checks/ - Can be autodiscovered via Kubernetes annotations/labels
- Main config:
datadog.yaml - Check configs:
conf.d/<check_name>.d/conf.yaml - Supports environment variable overrides with
DD_prefix
- Go tests using standard
go test - Python tests using pytest
- Run with
dda inv test --targets=<package>
- E2E framework in
test/new-e2e/
- Go: golangci-lint via
dda inv linter.go - Python: various linters via
dda inv linter.python - YAML: yamllint
- Shell: shellcheck
The project uses Python's Invoke framework with custom tasks. Main task categories:
agent.*- Core agent taskstest- Testing taskslinter.*- Linting tasksdocker.*- Docker image tasksrelease.*- Release management
Go build tags control feature inclusion, some examples are:
kubeapiserver- Kubernetes API server supportcontainerd- containerd supportdocker- Docker supportebpf- eBPF supportpython- Python check support- and MANY more, refer to ./tasks/build_tags.py for a full reference.
datadog.yaml- Main agent configurationmodules.yml- Go module definitionsrelease.json- Release version information.gitlab-ci.yml- CI/CD pipeline configuration
/docs/- Internal documentation/docs/dev/- Developer guidesREADME.md- Project overviewCONTRIBUTING.md- Contribution guidelines
- Primary CI system
- Defined in
.gitlab-ci.ymland.gitlab/directory - Runs tests, builds, and deployments
- Secondary CI for specific workflows
- Tests about the pull-request settings or repository configuration
- Release automation workflows
- Never commit API keys or secrets
- Use secret backend for credentials
The project uses Go modules with multiple sub-modules. TODO: Describe specific strategies for managing modules, including any invoke tasks.
- Linux: Full support (amd64, arm64)
- Windows: Full support (Server 2016+, Windows 10+)
- macOS: Supported
- AIX: No support in this codebase
- Container: Docker, Kubernetes, ECS, containerd, and more
- Always run linters before committing:
dda inv linter.go - Always test your changes:
dda inv test --targets=<your_package> - Follow Go conventions: Use gofmt, follow project structure
- Update documentation: Keep docs in sync with code changes
- Check for security implications: Review security-sensitive changes carefully
- Missing tools: Run
dda inv install-tools - CMake errors: Remove
dda inv rtloader.clean
- Flaky tests: Check
flakes.yamlfor known issues - Coverage issues: Use
--coverageflag