How to use the datadog.api.Monitor function in datadog

To help you get started, we’ve selected a few datadog examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github DataDog / documentation / content / api / monitors / code_snippets / api-monitor-show.py View on Github external
from datadog import initialize, api


options = {
    'api_key': '9775a026f1ca7d1c6c5af9d94d9595a4',
    'app_key': '87ce4a24b5553d2e482ea8a8500e71b8ad4554ff'
}


initialize(**options)


# Get a monitor's details
api.Monitor.get(2081, group_states='all')
github DataDog / documentation / content / api / monitors / code_snippets / api-monitor-unmute.py View on Github external
from datadog import initialize, api

options = {
    'api_key': '9775a026f1ca7d1c6c5af9d94d9595a4',
    'app_key': '87ce4a24b5553d2e482ea8a8500e71b8ad4554ff'
}


initialize(**options)


# Unmute all alerts
api.Monitor.unmute(2088)
github DataDog / documentation / content / en / api / monitors / code_snippets / api-monitor-can-delete.py View on Github external
from datadog import initialize, api

options = {
    'api_key': '',
    'app_key': ''
}

initialize(**options)

# Check if you can delete the given monitors.
api.Monitor.can_delete(monitor_ids=[56838, 771060, 1000376])
github StackStorm / st2contrib / packs / datadog / actions / lib / monitors.py View on Github external
def _run(self, **kwargs):
        return api.Monitor.mute(kwargs.pop("monitor_id"), **kwargs)
github StackStorm / st2contrib / packs / datadog / actions / lib / monitors.py View on Github external
def _run(self, **kwargs):
        return api.Monitor.get(kwargs.pop("monitor_id"), **kwargs)
github ansible / ansible / lib / ansible / modules / monitoring / datadog / datadog_monitor.py View on Github external
def _get_monitor(module):
    if module.params['id'] is not None:
        monitor = api.Monitor.get(module.params['id'])
        if 'errors' in monitor:
            module.fail_json(msg="Failed to retrieve monitor with id %s, errors are %s" % (module.params['id'], str(monitor['errors'])))
        return monitor
    else:
        monitors = api.Monitor.get_all()
        for monitor in monitors:
            if monitor['name'] == _fix_template_vars(module.params['name']):
                return monitor
    return {}
github DataDog / documentation / ja / code_snippets / api-monitor-mute-all.py View on Github external
from datadog import initialize, api

options = {
    'api_key': '',
    'app_key': ''
}

initialize(**options)

# Mute all monitors
api.Monitor.mute_all()
github ansible / ansible / lib / ansible / modules / extras / monitoring / datadog_monitor.py View on Github external
def delete_monitor(module):
    monitor = _get_monitor(module)
    if not monitor:
        module.exit_json(changed=False)
    try:
        msg = api.Monitor.delete(monitor['id'])
        module.exit_json(changed=True, msg=msg)
    except Exception:
        e = get_exception()
        module.fail_json(msg=str(e))