Skip to content

Conversation

@sovit-max
Copy link
Contributor

@sovit-max sovit-max commented Nov 20, 2025

Gets training logs from SkyPilot jobs into Datadog.

The key issue was that SkyPilot's subprocess daemon recursively kills all child processes when a phase ends. Starting the DD agent in the setup phase meant it was killed before training started.

the fix is to move DD agent setup from setup phase to run phase (run.sh), so it stays alive during training.

run.sh also tees stdout to a log file for DD to tail, as determined by an env var we pass from launch.py

Fixes agent startup in Docker containers by checking for binary instead
of systemd service, and adds automatic startup during run phase.
Fixes script exit on pgrep failure and adds better error messages
- Add metta_run_id, skypilot_task_id, and other tags to all log entries
- Enables filtering logs by run ID in Datadog Logs Explorer
- Fixes issue where logs weren't searchable by metta_run_id tag
- Remove wildcard paths (use explicit file paths only)
- Create empty log files during setup so agent can collect immediately
- Use unbuffered output (stdbuf) to ensure logs are written in real-time
- Add programmatic log checking script (check_datadog_logs.py)
- Fix tag formatting in log collection config
- Agent now always restarts to ensure logs_enabled and log collection config are loaded
- This ensures the agent picks up config changes made during setup phase
- Add logs section to main datadog.yaml in addition to separate config file
- Change custom_logs.d to custom_logs directory (standard format)
- This ensures logs are collected even if separate config isn't picked up
- Change directory from custom_logs to skypilot_training.d (proper .d format)
- Add logs_config section with auto_multi_line_detection and force_use_http
- This follows Datadog documentation best practices for log collection
- Remove duplicate logs section from main datadog.yaml (logs come from conf.d files)
- Add detailed verification in startup script to check:
  - Agent status and log collection status
  - Log collection config file existence
  - Training log file existence and size
- This helps debug why logs aren't appearing in Datadog
- Show config file contents when found
- Run agent configcheck to verify agent sees the config
- List available config files if our config is missing
- This helps debug why logs aren't being collected
- Set proper file permissions (644) on log config file
- Log config file size for verification
- Validate config contains required fields
- This helps debug why agent isn't collecting logs
This ensures the Datadog agent user (dd-agent) can read logs generated
by the training process user.
- Set /tmp/training_logs to 777
- Set log files to 666
- Temporarily disable pipefail when starting training to avoid silent failures
- Set PYTHONUNBUFFERED=1 for real-time logging
- Add debugging to check if training produces output after 5s
Delays the Datadog agent startup to allow the training process (Ray/Torchrun)
to fully initialize and bind ports. This prevents resource contention or
conflicts that were causing the training process to hang during startup.
Nishad and others added 8 commits December 6, 2025 17:59
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@nishu-builder nishu-builder changed the title fix(skypilot): Enable Datadog Logs Agent and add log collection for training jobs Fix Datadog agent for SkyPilot training jobs Dec 7, 2025
@nishu-builder nishu-builder added this pull request to the merge queue Dec 7, 2025
Merged via the queue into main with commit 7ba1451 Dec 7, 2025
10 of 11 checks passed
@nishu-builder nishu-builder deleted the sovitn-7-datadog-agent-fix branch December 7, 2025 08:38
zfogg pushed a commit that referenced this pull request Dec 20, 2025
Gets training logs from SkyPilot jobs into Datadog.

The key issue was that SkyPilot's subprocess daemon recursively kills
all child processes when a phase ends. Starting the DD agent in the
setup phase meant it was killed before training started.

the fix is to move DD agent setup from setup phase to run phase
(run.sh), so it stays alive during training.

run.sh also `tee`s stdout to a log file for DD to tail, as determined by
an env var we pass from launch.py

---------

Co-authored-by: Nishu <133812901+nishu-builder@users.noreply.github.com>
Co-authored-by: Nishad <nishad@stem.ai>
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stale 🥖 A bot has noticed this PR growing old.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants