DataDog / datadogpy

The Datadog Python library
https://datadoghq.com/
Other
605 stars 303 forks source link

Add fvalidate to dogshell #827

Open kkyr opened 3 months ago

kkyr commented 3 months ago

Requirements for Contributing to this repository

What does this PR do?

Add fvalidate command to dogshell which validates a monitor using a file as input.

This PR addresses https://github.com/DataDog/datadogpy/issues/826

Alternate Designs

No other alternate designs considered.

Possible Drawbacks

N/A

Verification Process

Ran command locally against a monitor defined in a file.

monitor.json

{
    "name": "Sample monitor",
    "type": "query alert",
    "query": "avg(last_5m):avg:system.load.1{host:XYZ} by {host} > 5",
    "message": "Message @team",
    "tags": [],
    "options": {
        "thresholds": {
            "critical": 5,
            "warning": 1
        },
        "notify_audit": true,
        "include_tags": true,
        "new_group_delay": 60
    },
    "priority": 2,
    "restricted_roles": [
        "c3a0b9e2-ec22-11ee-be33-da7ad0900005"
    ]
}
➜  Desktop dog --api_host "datadoghq.eu" --pretty monitor fvalidate monitor.json
{}

bad-monitor.json

{
    "name": "Sample monitor",
    "type": "query alert",
    "query": "avg(last_5m):avg:system.load.1{host:XYZ} by {host} > 5",
    "message": "Message @team",
    "tags": [],
    "options": {
        "thresholds": {
            "warning": 1
        },
        "notify_audit": true,
        "include_tags": true,
        "new_group_delay": 60
    },
    "priority": 2,
    "restricted_roles": [
        "c3a0b9e2-ec22-11ee-be33-da7ad0900005"
    ]
}
➜  Desktop dog --api_host "datadoghq.eu" --pretty monitor fvalidate bad-monitor.json
{
  "errors": [
    "Alert status is required."
  ]
}

Additional Notes

N/A

Release Notes

Review checklist (to be filled by reviewers)

github-actions[bot] commented 2 months ago

This issue has been automatically marked as stale because it has not had activity in the last 30 days. Note that the issue will not be automatically closed, but this notification will remind us to investigate why there's been inactivity.