-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvalidate.py
More file actions
30 lines (23 loc) · 788 Bytes
/
validate.py
File metadata and controls
30 lines (23 loc) · 788 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import json
from datadog import initialize, api
with open('config.json') as json_file:
data = json.load(json_file)
options = {
'api_key': data['datadog']['api_key'],
'app_key': data['datadog']['app_key']
}
initialize(**options)
monitor_type = data['validation_input']['monitor_type']
query = data['validation_input']['query']
monitor_options = {"thresholds": {"critical": data['validation_input']['threshold']}}
response = api.Monitor.validate(
type=monitor_type,
query=query,
options=monitor_options,
)
if not bool(response):
print 'Success: The query is valid'
if 'errors' in response:
print 'Error:'
for error in response.get('errors'):
print '- %s' % error