ddutil 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ddutil-0.1.0/.gitignore +26 -0
- ddutil-0.1.0/LICENSE +16 -0
- ddutil-0.1.0/PKG-INFO +568 -0
- ddutil-0.1.0/README.md +535 -0
- ddutil-0.1.0/licenses/datadog-api-client-python-license +176 -0
- ddutil-0.1.0/licenses/datadog-api-client-python-notice +15 -0
- ddutil-0.1.0/pyproject.toml +54 -0
- ddutil-0.1.0/src/ddutil/__init__.py +7 -0
- ddutil-0.1.0/src/ddutil/cli.py +1631 -0
- ddutil-0.1.0/src/ddutil/common/__init__.py +0 -0
- ddutil-0.1.0/src/ddutil/common/aws/auth.py +130 -0
- ddutil-0.1.0/src/ddutil/common/aws/iam.py +351 -0
- ddutil-0.1.0/src/ddutil/common/datadog/aws.py +319 -0
- ddutil-0.1.0/src/ddutil/common/logs.py +30 -0
- ddutil-0.1.0/src/ddutil/common/utils.py +15 -0
ddutil-0.1.0/.gitignore
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# Environment Variables
|
|
7
|
+
.env.development.local
|
|
8
|
+
.env.production.local
|
|
9
|
+
.env.local
|
|
10
|
+
.env-*
|
|
11
|
+
.env
|
|
12
|
+
|
|
13
|
+
# IDEs
|
|
14
|
+
.idea
|
|
15
|
+
.vscode
|
|
16
|
+
|
|
17
|
+
# Mypy
|
|
18
|
+
.mypy_cache
|
|
19
|
+
|
|
20
|
+
# User Ignores
|
|
21
|
+
.old
|
|
22
|
+
.testing
|
|
23
|
+
|
|
24
|
+
# Virtual Environments
|
|
25
|
+
venv/
|
|
26
|
+
.venv/
|
ddutil-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
Copyright 2026 Tom Burge
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software
|
|
4
|
+
and associated documentation files (the βSoftwareβ), to deal in the Software without restriction,
|
|
5
|
+
including without limitation the rights to use, copy, modify, merge, publish, distribute,
|
|
6
|
+
sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
|
|
7
|
+
furnished to do so, subject to the following conditions:
|
|
8
|
+
|
|
9
|
+
The above copyright notice and this permission notice shall be included in all copies or
|
|
10
|
+
substantial portions of the Software.
|
|
11
|
+
|
|
12
|
+
THE SOFTWARE IS PROVIDED βAS ISβ, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
|
|
13
|
+
BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
14
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
15
|
+
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
16
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
ddutil-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,568 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: ddutil
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A CLI tool for managing DataDog AWS integrations
|
|
5
|
+
Project-URL: Homepage, https://github.com/tomburge/datadog-utility
|
|
6
|
+
Project-URL: Repository, https://github.com/tomburge/datadog-utility
|
|
7
|
+
Project-URL: Bug Tracker, https://github.com/tomburge/datadog-utility/issues
|
|
8
|
+
Author-email: Tom Burge <tom@tomburge.org>
|
|
9
|
+
License: MIT
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Keywords: aws,cli,datadog,devops,integration,monitoring
|
|
12
|
+
Classifier: Development Status :: 3 - Alpha
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Intended Audience :: System Administrators
|
|
15
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
16
|
+
Classifier: Operating System :: OS Independent
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
21
|
+
Classifier: Topic :: System :: Systems Administration
|
|
22
|
+
Classifier: Topic :: Utilities
|
|
23
|
+
Requires-Python: >=3.12
|
|
24
|
+
Requires-Dist: boto3>=1.28.0
|
|
25
|
+
Requires-Dist: certifi>=2023.7.22
|
|
26
|
+
Requires-Dist: click>=8.0.0
|
|
27
|
+
Requires-Dist: datadog-api-client>=2.0.0
|
|
28
|
+
Requires-Dist: loguru>=0.7.0
|
|
29
|
+
Requires-Dist: pydantic>=2.0.0
|
|
30
|
+
Requires-Dist: python-dotenv>=0.19.0
|
|
31
|
+
Requires-Dist: rich>=10.0.0
|
|
32
|
+
Description-Content-Type: text/markdown
|
|
33
|
+
|
|
34
|
+
# DataDog AWS Integration CLI
|
|
35
|
+
|
|
36
|
+
A command-line tool for managing DataDog AWS integrations with ease.
|
|
37
|
+
|
|
38
|
+
## Features
|
|
39
|
+
|
|
40
|
+
- π Easy setup of DataDog integrations for AWS accounts
|
|
41
|
+
- π§ Automated IAM role and policy creation/management
|
|
42
|
+
- β
Comprehensive status checking and validation
|
|
43
|
+
- IAM role and policy verification
|
|
44
|
+
- DataDog account configuration validation
|
|
45
|
+
- Settings comparison (regions, services, metrics, resources)
|
|
46
|
+
- π Update existing integrations (regions, services, metrics, resources)
|
|
47
|
+
- ποΈ Clean deletion of integrations
|
|
48
|
+
- π¨ Beautiful terminal output with tables and colors
|
|
49
|
+
- βοΈ Flexible configuration via .env files or CLI arguments
|
|
50
|
+
- π Dry-run mode to preview changes before applying
|
|
51
|
+
- π Verbose logging for debugging
|
|
52
|
+
- π JSON output support for automation
|
|
53
|
+
- π Support for multiple AWS partitions (standard, GovCloud, China)
|
|
54
|
+
- β‘ No complex YAML configuration required
|
|
55
|
+
|
|
56
|
+
## Build Status
|
|
57
|
+
|
|
58
|
+
[](https://github.com/tomburge/datadog-utility/actions/workflows/test-build.yml)
|
|
59
|
+
|
|
60
|
+
[](https://github.com/tomburge/datadog-utility/actions/workflows/publish.yml)
|
|
61
|
+
|
|
62
|
+
## Installation
|
|
63
|
+
|
|
64
|
+
### Using UV (Recommended)
|
|
65
|
+
|
|
66
|
+
[UV](https://github.com/astral-sh/uv) is a blazing-fast Python package manager.
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
# Install UV if you haven't already
|
|
70
|
+
curl -LsSf https://astral.sh/uv/install.sh | sh
|
|
71
|
+
# or on Windows:
|
|
72
|
+
powershell -c "irm https://astral.sh/uv/install.ps1 | iex"
|
|
73
|
+
|
|
74
|
+
# Clone the repository
|
|
75
|
+
git clone <repository-url>
|
|
76
|
+
cd datadog-utility
|
|
77
|
+
|
|
78
|
+
# Create a virtual environment and install dependencies
|
|
79
|
+
uv venv
|
|
80
|
+
uv pip install -e .
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### Using pip
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
# Clone the repository
|
|
87
|
+
git clone <repository-url>
|
|
88
|
+
cd datadog-utility
|
|
89
|
+
|
|
90
|
+
# Create and activate virtual environment
|
|
91
|
+
python -m venv .venv
|
|
92
|
+
source .venv/bin/activate # On Windows: .venv\Scripts\activate
|
|
93
|
+
|
|
94
|
+
# Install the CLI tool
|
|
95
|
+
pip install -e .
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
After installation, the `ddutil` command will be available globally.
|
|
99
|
+
|
|
100
|
+
## Quick Start
|
|
101
|
+
|
|
102
|
+
### 1. Set Up Environment Variables
|
|
103
|
+
|
|
104
|
+
Copy the example `.env` file and fill in your credentials:
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
cp .env.example .env
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
Edit `.env` with your values:
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
# Required
|
|
114
|
+
DD_API_KEY=your_datadog_api_key
|
|
115
|
+
DD_APP_KEY=your_datadog_app_key
|
|
116
|
+
AWS_ACCOUNT_ID=123456789012
|
|
117
|
+
|
|
118
|
+
# Optional but commonly used
|
|
119
|
+
DD_ACCOUNT_ID=your_dd_account_id
|
|
120
|
+
AWS_PROFILE=default
|
|
121
|
+
DD_IAM_ROLE_NAME=datadog-integration-role
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
### 2. Preview the Setup (Dry-Run)
|
|
125
|
+
|
|
126
|
+
```bash
|
|
127
|
+
ddutil setup --dry-run
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
### 3. Apply the Changes
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
ddutil setup
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
That's it! The tool will:
|
|
137
|
+
|
|
138
|
+
- Create the necessary IAM role and policies
|
|
139
|
+
- Configure the DataDog integration
|
|
140
|
+
- Update the IAM role with the external ID from DataDog
|
|
141
|
+
|
|
142
|
+
## Usage
|
|
143
|
+
|
|
144
|
+
### Available Commands
|
|
145
|
+
|
|
146
|
+
```bash
|
|
147
|
+
ddutil --help # Show all available commands
|
|
148
|
+
ddutil --version # Show version information
|
|
149
|
+
ddutil --license # Show license information
|
|
150
|
+
ddutil -v, --verbose # Enable verbose output for any command
|
|
151
|
+
ddutil -q, --quiet # Suppress non-error output
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
**Commands:**
|
|
155
|
+
|
|
156
|
+
- `setup` - Set up DataDog integration for an AWS account
|
|
157
|
+
- `status` - Check the status of DataDog integration and validate configuration
|
|
158
|
+
- `update` - Update an existing DataDog integration
|
|
159
|
+
- `delete` - Delete DataDog integration for an AWS account
|
|
160
|
+
|
|
161
|
+
### Quick Reference
|
|
162
|
+
|
|
163
|
+
```bash
|
|
164
|
+
# Setup with defaults from .env
|
|
165
|
+
ddutil setup
|
|
166
|
+
|
|
167
|
+
# Preview setup without making changes
|
|
168
|
+
ddutil setup --dry-run
|
|
169
|
+
|
|
170
|
+
# Check configuration status and validation
|
|
171
|
+
ddutil status
|
|
172
|
+
|
|
173
|
+
# Update configuration
|
|
174
|
+
ddutil update --regions us-east-1,us-west-2
|
|
175
|
+
|
|
176
|
+
# Delete integration (with confirmation)
|
|
177
|
+
ddutil delete --confirm
|
|
178
|
+
|
|
179
|
+
# Any command with verbose output
|
|
180
|
+
ddutil --verbose <command>
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
### Setup Command
|
|
184
|
+
|
|
185
|
+
Set up DataDog integration for an AWS account:
|
|
186
|
+
|
|
187
|
+
```bash
|
|
188
|
+
# Using environment variables (.env file)
|
|
189
|
+
ddutil setup
|
|
190
|
+
|
|
191
|
+
# Override with CLI arguments
|
|
192
|
+
ddutil setup --account-id 123456789012 --dd-account-id YOUR_DD_ACCOUNT_ID
|
|
193
|
+
|
|
194
|
+
# Specify AWS profile
|
|
195
|
+
ddutil setup --profile aws-prod
|
|
196
|
+
|
|
197
|
+
# Dry-run mode (preview changes without applying)
|
|
198
|
+
ddutil setup --dry-run
|
|
199
|
+
|
|
200
|
+
# Verbose output (shows debug logs)
|
|
201
|
+
ddutil --verbose setup
|
|
202
|
+
|
|
203
|
+
# Specify regions and services
|
|
204
|
+
ddutil setup --regions us-east-1,us-west-2 --services AWS/Lambda,AWS/EC2
|
|
205
|
+
|
|
206
|
+
# Configure metric and resource collection
|
|
207
|
+
ddutil setup --metric-automute true --metric-collect-cloudwatch true \
|
|
208
|
+
--resource-collect-cspm false --resource-collect-extended true
|
|
209
|
+
|
|
210
|
+
# Specify AWS partition (for GovCloud or China regions)
|
|
211
|
+
ddutil setup --partition aws-us-gov
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
### Status Command
|
|
215
|
+
|
|
216
|
+
Check the status of an existing integration and validate configuration:
|
|
217
|
+
|
|
218
|
+
```bash
|
|
219
|
+
# Basic status check
|
|
220
|
+
ddutil status
|
|
221
|
+
|
|
222
|
+
# Check specific account
|
|
223
|
+
ddutil status --account-id 123456789012
|
|
224
|
+
|
|
225
|
+
# Use specific AWS profile
|
|
226
|
+
ddutil status --profile aws-prod
|
|
227
|
+
|
|
228
|
+
# JSON output for programmatic use
|
|
229
|
+
ddutil status --output json
|
|
230
|
+
|
|
231
|
+
# Verbose output with debug info
|
|
232
|
+
ddutil --verbose status
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
The status command validates:
|
|
236
|
+
|
|
237
|
+
- β
IAM role existence and policies
|
|
238
|
+
- β
DataDog account registration
|
|
239
|
+
- β
Configuration sync (regions, services, partition)
|
|
240
|
+
- β
Metric settings (automute, CloudWatch, custom metrics)
|
|
241
|
+
- β
Resource settings (CSPM, extended collection)
|
|
242
|
+
- β
Role name and External ID matching
|
|
243
|
+
|
|
244
|
+
### Update Command
|
|
245
|
+
|
|
246
|
+
Update an existing integration:
|
|
247
|
+
|
|
248
|
+
```bash
|
|
249
|
+
# Update services monitored
|
|
250
|
+
ddutil update --services AWS/Lambda,AWS/EC2,AWS/RDS
|
|
251
|
+
|
|
252
|
+
# Update regions
|
|
253
|
+
ddutil update --regions us-west-2,eu-west-1
|
|
254
|
+
|
|
255
|
+
# Update metric settings
|
|
256
|
+
ddutil update --metric-collect-custom true --metric-automute false
|
|
257
|
+
|
|
258
|
+
# Update resource collection
|
|
259
|
+
ddutil update --resource-collect-cspm true
|
|
260
|
+
|
|
261
|
+
# Preview changes before applying
|
|
262
|
+
ddutil update --regions us-west-2,eu-west-1 --dry-run
|
|
263
|
+
|
|
264
|
+
# Update with verbose output
|
|
265
|
+
ddutil --verbose update --services AWS/Lambda
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
### Delete Command
|
|
269
|
+
|
|
270
|
+
Remove DataDog integration:
|
|
271
|
+
|
|
272
|
+
```bash
|
|
273
|
+
# With confirmation prompt (interactive)
|
|
274
|
+
ddutil delete
|
|
275
|
+
|
|
276
|
+
# Specify account ID
|
|
277
|
+
ddutil delete --account-id 123456789012
|
|
278
|
+
|
|
279
|
+
# Skip confirmation prompt (for automation)
|
|
280
|
+
ddutil delete --confirm
|
|
281
|
+
|
|
282
|
+
# Delete with specific role name
|
|
283
|
+
ddutil delete --role-name custom-datadog-role --confirm
|
|
284
|
+
|
|
285
|
+
# Use specific AWS profile
|
|
286
|
+
ddutil delete --profile aws-prod --confirm
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
## Configuration
|
|
290
|
+
|
|
291
|
+
### Configuration Priority
|
|
292
|
+
|
|
293
|
+
Configuration values are resolved in the following order (highest to lowest priority):
|
|
294
|
+
|
|
295
|
+
1. **CLI arguments** - Values passed directly via command-line flags
|
|
296
|
+
2. **Environment variables** - Values from `.env` file or system environment
|
|
297
|
+
|
|
298
|
+
### Environment Variables
|
|
299
|
+
|
|
300
|
+
Create a `.env` file in your project directory:
|
|
301
|
+
|
|
302
|
+
```bash
|
|
303
|
+
# Copy the example file
|
|
304
|
+
cp .env.example .env
|
|
305
|
+
|
|
306
|
+
# Edit with your values
|
|
307
|
+
nano .env # or your favorite editor
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
### Required Environment Variables
|
|
311
|
+
|
|
312
|
+
```bash
|
|
313
|
+
# DataDog API Credentials
|
|
314
|
+
DD_API_KEY=your_datadog_api_key_here # DataDog API key (required)
|
|
315
|
+
DD_APP_KEY=your_datadog_app_key_here # DataDog application key (required)
|
|
316
|
+
|
|
317
|
+
# AWS Configuration
|
|
318
|
+
AWS_ACCOUNT_ID=123456789012 # Your AWS account ID (required)
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
### Optional Environment Variables
|
|
322
|
+
|
|
323
|
+
```bash
|
|
324
|
+
# Application Settings
|
|
325
|
+
LOG_LEVEL=INFO # Logging level (DEBUG, INFO, WARNING, ERROR)
|
|
326
|
+
|
|
327
|
+
# DataDog Configuration
|
|
328
|
+
DD_ACCOUNT_ID= # DataDog account ID (obtained from DataDog)
|
|
329
|
+
DD_SITE=datadoghq.com # DataDog site (datadoghq.com, datadoghq.eu, etc.)
|
|
330
|
+
DD_PARTITION=aws # AWS partition (aws, aws-cn, aws-us-gov)
|
|
331
|
+
DATADOG_VERIFY_SSL=false # SSL verification for DataDog API
|
|
332
|
+
|
|
333
|
+
# AWS Configuration
|
|
334
|
+
AWS_PROFILE=default # AWS CLI profile name
|
|
335
|
+
|
|
336
|
+
# IAM Configuration
|
|
337
|
+
DD_IAM_ROLE_NAME=datadog-integration-role # IAM role name
|
|
338
|
+
DD_MANAGED_POLICIES= # Comma-separated managed policy ARNs
|
|
339
|
+
# Default: ReadOnlyAccess, SecurityAudit
|
|
340
|
+
DD_POLICY_ACTIONS= # Comma-separated additional IAM actions
|
|
341
|
+
# Default: 32 standard actions (see .env.example)
|
|
342
|
+
|
|
343
|
+
# Monitoring Configuration
|
|
344
|
+
DD_REGIONS= # Comma-separated AWS regions (empty = all)
|
|
345
|
+
DD_SERVICES= # Comma-separated AWS services (empty = default)
|
|
346
|
+
DD_TRACES= # Comma-separated services for X-Ray tracing
|
|
347
|
+
|
|
348
|
+
# Metric Settings
|
|
349
|
+
DD_METRIC_AUTOMUTE=true # Auto-mute monitors (true/false)
|
|
350
|
+
DD_METRIC_COLLECT_CLOUDWATCH=true # Collect CloudWatch alarms (true/false)
|
|
351
|
+
DD_METRIC_COLLECT_CUSTOM=false # Collect custom metrics (true/false)
|
|
352
|
+
DD_METRIC_COLLECT_METRICS=true # Enable metric collection (true/false)
|
|
353
|
+
DD_METRIC_ENABLE=true # Enable metrics globally (true/false)
|
|
354
|
+
|
|
355
|
+
# Resource Settings
|
|
356
|
+
DD_RESOURCE_COLLECT_CSPM=false # Cloud Security Posture Management (true/false)
|
|
357
|
+
DD_RESOURCE_COLLECT_EXTENDED=true # Extended resource collection (true/false)
|
|
358
|
+
```
|
|
359
|
+
|
|
360
|
+
## Examples
|
|
361
|
+
|
|
362
|
+
### Basic Setup with .env File
|
|
363
|
+
|
|
364
|
+
Create `.env`:
|
|
365
|
+
|
|
366
|
+
```bash
|
|
367
|
+
DD_API_KEY=abc123def456...
|
|
368
|
+
DD_APP_KEY=xyz789ghi012...
|
|
369
|
+
AWS_ACCOUNT_ID=123456789012
|
|
370
|
+
AWS_PROFILE=production
|
|
371
|
+
```
|
|
372
|
+
|
|
373
|
+
Run setup:
|
|
374
|
+
|
|
375
|
+
```bash
|
|
376
|
+
# Preview changes
|
|
377
|
+
ddutil setup --dry-run
|
|
378
|
+
|
|
379
|
+
# Apply configuration
|
|
380
|
+
ddutil setup
|
|
381
|
+
|
|
382
|
+
# Check status after setup
|
|
383
|
+
ddutil status
|
|
384
|
+
```
|
|
385
|
+
|
|
386
|
+
### Multi-Region Setup
|
|
387
|
+
|
|
388
|
+
```bash
|
|
389
|
+
# Monitor specific regions only
|
|
390
|
+
ddutil setup --regions us-east-1,us-west-2,eu-west-1
|
|
391
|
+
|
|
392
|
+
# Or set in .env
|
|
393
|
+
DD_REGIONS=us-east-1,us-west-2,eu-west-1
|
|
394
|
+
ddutil setup
|
|
395
|
+
```
|
|
396
|
+
|
|
397
|
+
### Specific Services Only
|
|
398
|
+
|
|
399
|
+
```bash
|
|
400
|
+
# Monitor specific AWS services
|
|
401
|
+
ddutil setup --services AWS/Lambda,AWS/EC2,AWS/RDS
|
|
402
|
+
|
|
403
|
+
# With X-Ray tracing for Lambda
|
|
404
|
+
ddutil setup --services AWS/Lambda,AWS/EC2 --traces AWS/Lambda
|
|
405
|
+
```
|
|
406
|
+
|
|
407
|
+
### Metric and Resource Configuration
|
|
408
|
+
|
|
409
|
+
```bash
|
|
410
|
+
# Enable Cloud Security Posture Management
|
|
411
|
+
ddutil setup --resource-collect-cspm true
|
|
412
|
+
|
|
413
|
+
# Enable custom metrics collection
|
|
414
|
+
ddutil setup --metric-collect-custom true
|
|
415
|
+
|
|
416
|
+
# Configure multiple metric settings
|
|
417
|
+
ddutil setup \
|
|
418
|
+
--metric-automute true \
|
|
419
|
+
--metric-collect-cloudwatch true \
|
|
420
|
+
--metric-collect-custom false \
|
|
421
|
+
--metric-enable true
|
|
422
|
+
```
|
|
423
|
+
|
|
424
|
+
### Override with CLI Arguments
|
|
425
|
+
|
|
426
|
+
```bash
|
|
427
|
+
# Override environment variables for one-off operations
|
|
428
|
+
ddutil setup --account-id 999888777666 --profile dev-account
|
|
429
|
+
|
|
430
|
+
# Use different AWS partition
|
|
431
|
+
ddutil setup --partition aws-us-gov --profile govcloud
|
|
432
|
+
```
|
|
433
|
+
|
|
434
|
+
### Custom IAM Configuration
|
|
435
|
+
|
|
436
|
+
```bash
|
|
437
|
+
# Custom role name and policies
|
|
438
|
+
ddutil setup \
|
|
439
|
+
--role-name custom-datadog-role \
|
|
440
|
+
--managed-policies arn:aws:iam::aws:policy/ReadOnlyAccess \
|
|
441
|
+
--policy-actions logs:PutSubscriptionFilter,s3:GetBucketNotification
|
|
442
|
+
|
|
443
|
+
# Update existing role policies
|
|
444
|
+
ddutil update \
|
|
445
|
+
--managed-policies arn:aws:iam::aws:policy/ReadOnlyAccess,arn:aws:iam::aws:policy/SecurityAudit
|
|
446
|
+
```
|
|
447
|
+
|
|
448
|
+
### Validation and Status Checking
|
|
449
|
+
|
|
450
|
+
```bash
|
|
451
|
+
# Check if configuration matches .env settings
|
|
452
|
+
ddutil status
|
|
453
|
+
|
|
454
|
+
# Get detailed JSON output for monitoring
|
|
455
|
+
ddutil status --output json > status.json
|
|
456
|
+
|
|
457
|
+
# Validate specific account configuration
|
|
458
|
+
ddutil --verbose status --account-id 123456789012
|
|
459
|
+
```
|
|
460
|
+
|
|
461
|
+
## Development
|
|
462
|
+
|
|
463
|
+
### Project Structure
|
|
464
|
+
|
|
465
|
+
```text
|
|
466
|
+
datadog-utility/
|
|
467
|
+
βββ src/
|
|
468
|
+
β βββ ddutil/ # Main package
|
|
469
|
+
β βββ __init__.py # Package initialization
|
|
470
|
+
β βββ cli.py # CLI command definitions
|
|
471
|
+
β βββ common/ # Shared utilities
|
|
472
|
+
β βββ aws/ # AWS-related modules
|
|
473
|
+
β β βββ auth.py # AWS authentication
|
|
474
|
+
β β βββ iam.py # IAM role management
|
|
475
|
+
β βββ datadog/ # DataDog-related modules
|
|
476
|
+
β β βββ aws.py # DataDog API interactions
|
|
477
|
+
β βββ logs.py # Logging configuration
|
|
478
|
+
β βββ utils.py # Utility functions
|
|
479
|
+
βββ pyproject.toml # Package configuration
|
|
480
|
+
βββ .env.example # Example environment variables
|
|
481
|
+
βββ .python-version # Python version for UV
|
|
482
|
+
βββ requirements.txt # Python dependencies
|
|
483
|
+
βββ responses/ # Sample API responses
|
|
484
|
+
```
|
|
485
|
+
|
|
486
|
+
## Troubleshooting
|
|
487
|
+
|
|
488
|
+
### Common Issues
|
|
489
|
+
|
|
490
|
+
**Missing required environment variables:**
|
|
491
|
+
|
|
492
|
+
```bash
|
|
493
|
+
# Check if all required variables are set with dry-run
|
|
494
|
+
ddutil setup --dry-run
|
|
495
|
+
|
|
496
|
+
# Set missing variables in .env file or export them
|
|
497
|
+
export AWS_ACCOUNT_ID=123456789012
|
|
498
|
+
export DD_API_KEY=your_api_key
|
|
499
|
+
export DD_APP_KEY=your_app_key
|
|
500
|
+
```
|
|
501
|
+
|
|
502
|
+
**AWS authentication errors:**
|
|
503
|
+
|
|
504
|
+
```bash
|
|
505
|
+
# Ensure your AWS profile is configured
|
|
506
|
+
aws configure --profile your-profile-name
|
|
507
|
+
|
|
508
|
+
# Or specify profile explicitly
|
|
509
|
+
ddutil setup --profile your-profile-name
|
|
510
|
+
|
|
511
|
+
# Or use environment variables
|
|
512
|
+
export AWS_PROFILE=your-profile-name
|
|
513
|
+
|
|
514
|
+
# Test AWS connectivity
|
|
515
|
+
aws sts get-caller-identity --profile your-profile-name
|
|
516
|
+
```
|
|
517
|
+
|
|
518
|
+
**DataDog API errors:**
|
|
519
|
+
|
|
520
|
+
```bash
|
|
521
|
+
# Verify your API keys are set
|
|
522
|
+
echo $DD_API_KEY
|
|
523
|
+
echo $DD_APP_KEY
|
|
524
|
+
|
|
525
|
+
# Make sure they're in your .env file
|
|
526
|
+
cat .env | grep DD_
|
|
527
|
+
|
|
528
|
+
# Test DataDog API connectivity
|
|
529
|
+
ddutil --verbose status
|
|
530
|
+
```
|
|
531
|
+
|
|
532
|
+
**Configuration mismatch errors:**
|
|
533
|
+
|
|
534
|
+
```bash
|
|
535
|
+
# Use status command to see what doesn't match
|
|
536
|
+
ddutil status
|
|
537
|
+
|
|
538
|
+
# Status will show:
|
|
539
|
+
# - IAM role and policy status
|
|
540
|
+
# - DataDog account configuration
|
|
541
|
+
# - Mismatches between actual and expected settings
|
|
542
|
+
# - Specific issues with regions, services, metrics, resources
|
|
543
|
+
|
|
544
|
+
# Fix mismatches by updating
|
|
545
|
+
ddutil update --regions us-east-1,us-west-2
|
|
546
|
+
ddutil update --metric-collect-cloudwatch true
|
|
547
|
+
```
|
|
548
|
+
|
|
549
|
+
**Debug with verbose and dry-run:**
|
|
550
|
+
|
|
551
|
+
```bash
|
|
552
|
+
# Always test with dry-run first
|
|
553
|
+
ddutil setup --dry-run
|
|
554
|
+
|
|
555
|
+
# Use verbose for detailed debugging
|
|
556
|
+
ddutil --verbose setup --dry-run
|
|
557
|
+
|
|
558
|
+
# Check logs for detailed error messages
|
|
559
|
+
tail -f ~/.ddutil/logs/ddutil.log # if logging to file
|
|
560
|
+
```
|
|
561
|
+
|
|
562
|
+
## Roadmap
|
|
563
|
+
|
|
564
|
+
See [ROADMAP.md](ROADMAP.md) for planned features and improvements.
|
|
565
|
+
|
|
566
|
+
## License
|
|
567
|
+
|
|
568
|
+
MIT License - See LICENSE file for details.
|