Skip to content

Commit 44d02d1

Browse files
mobuchowskiclaude
andauthored
add data observability query actions check (DataDog#22793)
* add do query actions Signed-off-by: Maciej Obuchowski <maciej.obuchowski@datadoghq.com> add do query actions Signed-off-by: Maciej Obuchowski <maciej.obuchowski@datadoghq.com> * Fix CI validation failures: sync CI config, add changelog entries, update conf.yaml.example - Run ddev validate ci --sync to add do_query_actions to CI config - Add changelog entries for do_query_actions (added), datadog_checks_base (added), postgres (changed) - Regenerate conf.yaml.example from spec.yaml to sync updated port/db_type descriptions Signed-off-by: Maciej Obuchowski <maciej.obuchowski@datadoghq.com> Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * Fix test_token_provider.py patch paths after moving providers to datadog_checks_base AWSTokenProvider and AzureTokenProvider were moved from postgres/connection_pool.py to datadog_checks_base/utils/db/postgres_connection.py, which inlines boto3/azure calls directly instead of delegating to postgres.aws/postgres.azure helpers. Update mocks to target the actual call sites: - boto3.client / boto3.Session instead of datadog_checks.postgres.aws.generate_rds_iam_token - azure.identity.ManagedIdentityCredential instead of datadog_checks.postgres.azure.ManagedIdentityCredential - datadog_checks.base.utils.db.postgres_connection.time instead of connection_pool.time.time Signed-off-by: Maciej Obuchowski <maciej.obuchowski@datadoghq.com> Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * Fix lint formatting in test_token_provider.py Signed-off-by: Maciej Obuchowski <maciej.obuchowski@datadoghq.com> Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * Fix dep pinning, changelog date, and add E2E fixture for do_query_actions - Pin boto3==1.42.54, azure-identity==1.25.2, psycopg[c,pool]==3.3.3 to match agent versions - Fix CHANGELOG.md date (Unreleased -> 2026-03-05) - Add dd_environment fixture and docker-compose.yml for E2E tests against postgres Signed-off-by: Maciej Obuchowski <maciej.obuchowski@datadoghq.com> Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * Fix license headers in do_query_actions: correct year (2026) and license text Signed-off-by: Maciej Obuchowski <maciej.obuchowski@datadoghq.com> Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * Add tests for uncovered branches in do_query_actions check.py - Azure managed identity token provider path - token_provider kwarg forwarded to ConnectionPool - DoQueryCursor.execute SQL comment prepending - conn.rollback() exception swallowed after query failure - entity.model_dump() (pydantic model) serialization - dict(entity) fallback serialization check.py now at 100% coverage. Signed-off-by: Maciej Obuchowski <maciej.obuchowski@datadoghq.com> Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * Add do_query_actions label to labeler config Signed-off-by: Maciej Obuchowski <maciej.obuchowski@datadoghq.com> Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * Remove premature release section from do_query_actions CHANGELOG.md Unreleased integrations (version 0.0.1) should not have release sections. Signed-off-by: Maciej Obuchowski <maciej.obuchowski@datadoghq.com> Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * Improve changelog descriptions with Data Observability context Signed-off-by: Maciej Obuchowski <maciej.obuchowski@datadoghq.com> Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * Trim do_query_actions changelog description Signed-off-by: Maciej Obuchowski <maciej.obuchowski@datadoghq.com> Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * revert making postgres conn details shared Signed-off-by: Maciej Obuchowski <maciej.obuchowski@datadoghq.com> * logs, text Signed-off-by: Maciej Obuchowski <maciej.obuchowski@datadoghq.com> * fix some AI feedback Signed-off-by: Maciej Obuchowski <maciej.obuchowski@datadoghq.com> * make the config required Signed-off-by: Maciej Obuchowski <maciej.obuchowski@datadoghq.com> * fix bugs Signed-off-by: Maciej Obuchowski <maciej.obuchowski@datadoghq.com> * address code review Signed-off-by: Maciej Obuchowski <maciej.obuchowski@datadoghq.com> * code review comments Signed-off-by: Maciej Obuchowski <maciej.obuchowski@datadoghq.com> * code review comments Signed-off-by: Maciej Obuchowski <maciej.obuchowski@datadoghq.com> * remove service checks from manifest Signed-off-by: Maciej Obuchowski <maciej.obuchowski@datadoghq.com> --------- Signed-off-by: Maciej Obuchowski <maciej.obuchowski@datadoghq.com> Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 99c4705 commit 44d02d1

27 files changed

Lines changed: 1925 additions & 0 deletions

.codecov.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,10 @@ coverage:
170170
target: 75
171171
flags:
172172
- dns_check
173+
DO_Query_Actions:
174+
target: 75
175+
flags:
176+
- do_query_actions
173177
Datadog_Checks_Base:
174178
target: 75
175179
flags:
@@ -1085,6 +1089,11 @@ flags:
10851089
paths:
10861090
- dns_check/datadog_checks/dns_check
10871091
- dns_check/tests
1092+
do_query_actions:
1093+
carryforward: true
1094+
paths:
1095+
- do_query_actions/datadog_checks/do_query_actions
1096+
- do_query_actions/tests
10881097
dotnetclr:
10891098
carryforward: true
10901099
paths:

.github/CODEOWNERS

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,11 @@ datadog_checks_base/tests/**/test_db_statements.py @DataDog/database-monitoring
175175
/clickhouse/*.md @DataDog/database-monitoring @DataDog/agent-integrations @DataDog/documentation
176176
/clickhouse/manifest.json @DataDog/database-monitoring @DataDog/agent-integrations @DataDog/documentation
177177

178+
# Data Observability
179+
/do_query_actions/ @DataDog/data-observability @DataDog/agent-integrations
180+
/do_query_actions/*.md @DataDog/data-observability @DataDog/agent-integrations @DataDog/documentation
181+
/do_query_actions/manifest.json @DataDog/data-observability @DataDog/agent-integrations @DataDog/documentation
182+
178183
# Data Streams Monitoring
179184
/kafka_actions/ @DataDog/data-streams-monitoring @DataDog/agent-integrations
180185
/kafka_actions/*.md @DataDog/data-streams-monitoring @DataDog/agent-integrations @DataDog/documentation

.github/workflows/config/labeler.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,10 @@ integration/dnsfilter:
450450
- changed-files:
451451
- any-glob-to-any-file:
452452
- dnsfilter/**/*
453+
integration/do_query_actions:
454+
- changed-files:
455+
- any-glob-to-any-file:
456+
- do_query_actions/**/*
453457
integration/docker_daemon:
454458
- changed-files:
455459
- any-glob-to-any-file:

.github/workflows/test-all.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1043,6 +1043,26 @@ jobs:
10431043
minimum-base-package: ${{ inputs.minimum-base-package }}
10441044
pytest-args: ${{ inputs.pytest-args }}
10451045
secrets: inherit
1046+
j297b771:
1047+
uses: ./.github/workflows/test-target.yml
1048+
with:
1049+
job-name: DO Query Actions
1050+
target: do_query_actions
1051+
platform: linux
1052+
runner: '["ubuntu-22.04"]'
1053+
repo: "${{ inputs.repo }}"
1054+
context: ${{ inputs.context }}
1055+
python-version: "${{ inputs.python-version }}"
1056+
latest: ${{ inputs.latest }}
1057+
agent-image: "${{ inputs.agent-image }}"
1058+
agent-image-py2: "${{ inputs.agent-image-py2 }}"
1059+
agent-image-windows: "${{ inputs.agent-image-windows }}"
1060+
agent-image-windows-py2: "${{ inputs.agent-image-windows-py2 }}"
1061+
test-py2: ${{ inputs.test-py2 }}
1062+
test-py3: ${{ inputs.test-py3 }}
1063+
minimum-base-package: ${{ inputs.minimum-base-package }}
1064+
pytest-args: ${{ inputs.pytest-args }}
1065+
secrets: inherit
10461066
j274814f:
10471067
uses: ./.github/workflows/test-target.yml
10481068
with:

do_query_actions/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# CHANGELOG - DO Query Actions
2+
3+
<!-- towncrier release notes start -->

do_query_actions/README.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Agent Check: DO Query Actions
2+
3+
## Overview
4+
5+
The DO Query Actions check executes SQL queries against PostgreSQL and reports success/failure metrics. This check is designed to receive configuration via Remote Config and execute queries on demand.
6+
7+
## Setup
8+
9+
### Installation
10+
11+
The DO Query Actions check is included in the Datadog Agent package.
12+
13+
### Configuration
14+
15+
1. Edit the `do_query_actions.d/conf.yaml` file in the `conf.d/` folder at the root of your Agent's configuration directory to start collecting metrics. See the sample `do_query_actions.d/conf.yaml.example` for all available configuration options.
16+
17+
2. Restart the Agent.
18+
19+
### Validation
20+
21+
Run the Agent's status subcommand and look for `do_query_actions` under the Checks section.
22+
23+
## Data Collected
24+
25+
### Metrics
26+
27+
| Metric | Type | Description |
28+
|--------|------|-------------|
29+
| `do_query_actions.query_execution_time` | gauge | Time taken to execute the query in seconds |
30+
| `do_query_actions.query_status` | gauge | 1 if query succeeded, 0 if failed |
31+
32+
### Service Checks
33+
34+
No service checks are provided by this integration.
35+
36+
### Events
37+
38+
Query results are sent as events via the `do-query-results` event track type, containing query output, execution metadata, and entity information.
39+
40+
## Troubleshooting
41+
42+
Need help? Contact [Datadog support][1].
43+
44+
[1]: https://docs.datadoghq.com/help/
Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
name: DO Query Actions
2+
files:
3+
- name: do_query_actions.yaml
4+
options:
5+
- template: init_config
6+
options:
7+
- template: init_config/default
8+
- template: instances
9+
options:
10+
- name: db_identifier
11+
required: true
12+
description: |
13+
Identifies the target database for this query configuration.
14+
value:
15+
type: object
16+
required:
17+
- host
18+
- dbname
19+
properties:
20+
- name: host
21+
type: string
22+
- name: dbname
23+
type: string
24+
- name: username
25+
required: true
26+
description: |
27+
The database username for authentication.
28+
value:
29+
example: "datadog"
30+
type: string
31+
- name: password
32+
secret: true
33+
description: |
34+
The database password for authentication.
35+
value:
36+
type: string
37+
- name: port
38+
description: |
39+
The database port to connect to.
40+
If not specified, defaults to 5432.
41+
value:
42+
type: integer
43+
- name: ssl
44+
description: |
45+
SSL mode for PostgreSQL connections.
46+
Valid values: disable, allow, prefer, require, verify-ca, verify-full.
47+
value:
48+
type: string
49+
- name: ssl_cert
50+
description: |
51+
Path to the client SSL certificate.
52+
value:
53+
type: string
54+
- name: ssl_root_cert
55+
description: |
56+
Path to the SSL root certificate authority.
57+
value:
58+
type: string
59+
- name: ssl_key
60+
description: |
61+
Path to the client SSL private key.
62+
value:
63+
type: string
64+
- name: ssl_password
65+
secret: true
66+
description: |
67+
Password for the client SSL private key.
68+
value:
69+
type: string
70+
- name: aws
71+
description: |
72+
AWS configuration for RDS IAM authentication.
73+
value:
74+
type: object
75+
properties:
76+
- name: region
77+
type: string
78+
- name: managed_authentication
79+
type: object
80+
properties:
81+
- name: enabled
82+
type: boolean
83+
- name: role_arn
84+
type: string
85+
- name: managed_authentication
86+
description: |
87+
Azure Managed Identity configuration.
88+
value:
89+
type: object
90+
properties:
91+
- name: enabled
92+
type: boolean
93+
- name: client_id
94+
type: string
95+
- name: identity_scope
96+
type: string
97+
- name: config_id
98+
description: |
99+
An identifier for tracking this query configuration via Remote Config.
100+
value:
101+
type: string
102+
- name: db_type
103+
required: true
104+
description: |
105+
The database engine to connect to. Currently only 'postgres' is supported.
106+
value:
107+
example: "postgres"
108+
type: string
109+
- name: queries
110+
required: true
111+
description: |
112+
List of SQL queries to execute with per-query scheduling.
113+
Each query has its own interval and timeout settings.
114+
value:
115+
type: array
116+
items:
117+
type: object
118+
required:
119+
- monitor_id
120+
- query
121+
- interval_seconds
122+
- timeout_seconds
123+
- entity
124+
properties:
125+
- name: type
126+
type: string
127+
- name: monitor_id
128+
type: integer
129+
- name: query
130+
type: string
131+
- name: interval_seconds
132+
type: integer
133+
- name: timeout_seconds
134+
type: integer
135+
- name: entity
136+
type: object
137+
required:
138+
- platform
139+
- account
140+
- database
141+
- schema
142+
- table
143+
properties:
144+
- name: platform
145+
type: string
146+
- name: account
147+
type: string
148+
- name: database
149+
type: string
150+
- name: schema
151+
type: string
152+
- name: table
153+
type: string
154+
- name: custom_sql_select_fields
155+
type: object
156+
properties:
157+
- name: metric_config_id
158+
type: integer
159+
- name: entity_id
160+
type: string
161+
- template: instances/default
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Initial Release
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# (C) Datadog, Inc. 2026-present
2+
# All rights reserved
3+
# Licensed under a 3-clause BSD style license (see LICENSE)
4+
__version__ = '0.0.1'
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# (C) Datadog, Inc. 2026-present
2+
# All rights reserved
3+
# Licensed under a 3-clause BSD style license (see LICENSE)
4+
from .__about__ import __version__
5+
from .check import DOQueryActionsCheck
6+
7+
__all__ = ['__version__', 'DOQueryActionsCheck']

0 commit comments

Comments
 (0)