Repository: ansible-collections/community.general

Issue:
datadog_monitor does not accept "process alert" monitor type anymore
##### SUMMARY
Datadog built-in module failing to deploy a "process alert" type which is a valid type of monitor.

This worked on ansible 2.6 as I referenced here: https://github.com/DataDog/ansible-datadog/issues/219 (I don't know how, but I have deployed several hundred of them)

I just updated to Ansible 2.9.7 and found the issue still.

##### ISSUE TYPE
- Bug Report

##### COMPONENT NAME
`datadog_monitor`

##### ANSIBLE VERSION
<!--- Paste verbatim output from "ansible --version" between quotes -->
```
ansible 2.9.7
  config file = None
  configured module search path = ['/Users/username/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.7/site-packages/ansible
  executable location = /usr/local/bin/ansible
  python version = 3.7.7 (default, Mar 10 2020, 15:43:27) [Clang 10.0.0 (clang-1000.11.45.5)]
```

##### CONFIGURATION
<!--- Paste verbatim output from "ansible-config dump --only-changed" between quotes -->
```paste below

```

##### OS / ENVIRONMENT
<!--- Provide all relevant information below, e.g. target OS versions, network device firmware, etc. -->
OSX 10.13.6
Python 3.7.7


##### STEPS TO REPRODUCE
<!--- Describe exactly how to reproduce the problem, using a minimal test-case -->

<!--- Paste example playbooks or commands between quotes below -->
```yaml
    - name: Deploy datadog monitor
      delegate_to: localhost
      register: datadogstatDeploy
      datadog_monitor:
        type: "process alert"
        thresholds:
          critical: 0
        name: "your alert name"
        state: "present"
        query: "your alert query"
        message: "your alert message"
        api_key: "{{ datadog.apiKey }}"
        app_key: "{{ datadog.appKey }}"
```

<!--- HINT: You can paste gist.github.com links for larger files -->

##### EXPECTED RESULTS
<!--- Describe what you expected to happen when running the steps above -->
The process monitor to deploy.

##### ACTUAL RESULTS
<!--- Describe what actually happened. If possible run with extra verbosity (-vvvv) -->

<!--- Paste verbatim command output between quotes -->
```paste below
FAILED! => {"changed": false, "msg": "value of type must be one of: metric alert, service check, event alert, got: process alert"}
```



Discussion:
Files identified in the description:
* [`plugins/modules/monitoring/datadog/datadog_monitor.py`](https://github.com/ansible-collections/community.general/blob/master/plugins/modules/monitoring/datadog/datadog_monitor.py)

If these files are inaccurate, please update the `component name` section of the description or use the `!component` bot command.

[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)
<!--- boilerplate: components_banner --->
cc @skornehl
[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)
<!--- boilerplate: notify --->
It looks like this *may* be fixed in 2.10 but I can't find a reliable way to test this (nor a release date for 2.10 entering stable)


Another one that was working previously:

```
 "msg": "value of type must be one of: metric alert, service check, event alert, got: log alert"}
```
There is also "log alert" missing, ex. This also worked back on 2.6

```
- name: "Log alert"
  delegate_to: localhost
  datadog_monitor:
    type: "log alert"
    name: "Log Alert Name"
    state: "present"
    query: "logs(\"@envtype:prod @service_name:{{ service_name }} status:critical @http_status_code:504 @msg:\"check failed \"\").index(\"main\").rollup(\"count\").last(\"15m\") >= 2"
```

Resolving patch:
diff --git a/plugins/modules/monitoring/datadog/datadog_monitor.py b/plugins/modules/monitoring/datadog/datadog_monitor.py
--- a/plugins/modules/monitoring/datadog/datadog_monitor.py
+++ b/plugins/modules/monitoring/datadog/datadog_monitor.py
@@ -53,7 +53,7 @@
     type:
         description:
           - The type of the monitor.
-        choices: ['metric alert', 'service check', 'event alert', 'process alert']
+        choices: ['metric alert', 'service check', 'event alert', 'process alert', 'log alert']
         type: str
     query:
         description:
@@ -204,7 +204,7 @@ def main():
             api_host=dict(required=False),
             app_key=dict(required=True, no_log=True),
             state=dict(required=True, choices=['present', 'absent', 'mute', 'unmute']),
-            type=dict(required=False, choices=['metric alert', 'service check', 'event alert', 'process alert']),
+            type=dict(required=False, choices=['metric alert', 'service check', 'event alert', 'process alert', 'log alert']),
             name=dict(required=True),
             query=dict(required=False),
             notification_message=dict(required=False, default=None, aliases=['message'], deprecated_aliases=[dict(name='message', version='2.14')]),


Test patch: