Skip to content

Add SQL Server diagnostics#23621

Open
joelmarcotte wants to merge 3 commits intomasterfrom
joel.marcotte/sqlserver-diagnose
Open

Add SQL Server diagnostics#23621
joelmarcotte wants to merge 3 commits intomasterfrom
joel.marcotte/sqlserver-diagnose

Conversation

@joelmarcotte
Copy link
Copy Markdown
Contributor

Summary

  • add explicit datadog-agent diagnose checks for SQL Server setup permissions
  • register the SQL Server diagnose runner on check initialization
  • cover connection, version, permission, DBM, msdb, and Azure SQL Database skip behavior

Validation

  • ddev test -fs sqlserver
  • ddev --no-interactive test sqlserver -- tests/test_diagnose.py (stopped during the final matrix run after repeated env passes at user request)

@codecov
Copy link
Copy Markdown

codecov Bot commented May 6, 2026

Codecov Report

❌ Patch coverage is 94.02985% with 24 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.43%. Comparing base (891aa96) to head (9b8b412).
⚠️ Report is 18 commits behind head on master.

Additional details and impacted files
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@datadog-datadog-prod-us1
Copy link
Copy Markdown
Contributor

datadog-datadog-prod-us1 Bot commented May 6, 2026

Tests

🎉 All green!

❄️ No new flaky tests detected
🧪 All tests passed

🎯 Code Coverage (details)
Patch Coverage: 94.03%
Overall Coverage: 90.20% (+2.95%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 9b8b412 | Docs | Datadog PR Page | Give us feedback!

@joelmarcotte joelmarcotte marked this pull request as ready for review May 7, 2026 12:51
@joelmarcotte joelmarcotte requested review from a team as code owners May 7, 2026 12:51
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 288359bce9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread sqlserver/datadog_checks/sqlserver/diagnose.py
Comment thread sqlserver/datadog_checks/sqlserver/diagnose.py
- skip server-level VIEW SERVER STATE probe on Azure SQL Database
  and validate via sys.dm_exec_sessions (VIEW DATABASE STATE)
- probe msdb.dbo.syssessions when agent_jobs is enabled and not on RDS

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@dd-octo-sts
Copy link
Copy Markdown
Contributor

dd-octo-sts Bot commented May 8, 2026

Validation Report

All 20 validations passed.

Show details
Validation Description Status
agent-reqs Verify check versions match the Agent requirements file
ci Validate CI configuration and Codecov settings
codeowners Validate every integration has a CODEOWNERS entry
config Validate default configuration files against spec.yaml
dep Verify dependency pins are consistent and Agent-compatible
http Validate integrations use the HTTP wrapper correctly
imports Validate check imports do not use deprecated modules
integration-style Validate check code style conventions
jmx-metrics Validate JMX metrics definition files and config
labeler Validate PR labeler config matches integration directories
legacy-signature Validate no integration uses the legacy Agent check signature
license-headers Validate Python files have proper license headers
licenses Validate third-party license attribution list
metadata Validate metadata.csv metric definitions
models Validate configuration data models match spec.yaml
openmetrics Validate OpenMetrics integrations disable the metric limit
package Validate Python package metadata and naming
readmes Validate README files have required sections
saved-views Validate saved view JSON file structure and fields
version Validate version consistency between package and changelog

View full run

@joelmarcotte
Copy link
Copy Markdown
Contributor Author

@codex review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9b8b4122a3

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

if not azure and not _has_server_permission(cursor, "VIEW SERVER STATE"):
self._fail(code, diagnosis="The Datadog login does not have VIEW SERVER STATE.")
return
_execute_read_probe(cursor, "SELECT TOP 1 session_id FROM sys.dm_exec_sessions")
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Validate Azure database-state permissions explicitly

When the target is Azure SQL Database and the login lacks VIEW DATABASE STATE, this probe can still succeed because Microsoft documents that everyone can see their own sys.dm_exec_sessions row, while VIEW DATABASE STATE is required to see all connections in the current database (https://learn.microsoft.com/en-us/sql/relational-databases/system-dynamic-management-views/sys-dm-exec-sessions-transact-sql). As a result datadog-agent diagnose reports this permission as granted even though DBM/query-activity collection remains under-permissioned; the Azure branch should explicitly check HAS_PERMS_BY_NAME(..., 'DATABASE', 'VIEW DATABASE STATE') or otherwise verify visibility beyond the current session.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant