Skip to content

Commit

Permalink
OM-199 - review feedback
Browse files Browse the repository at this point in the history
fixed python script
  • Loading branch information
mphanias committed Jan 10, 2025
1 parent 61e516f commit 9e753b1
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 32 deletions.
32 changes: 0 additions & 32 deletions config/datadog/monitors/datadog_monitors_creation.py

This file was deleted.

42 changes: 42 additions & 0 deletions config/datadog/monitors/manage_aerospike_monitors.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import json
import requests
import sys

def manage_monitors():
# Prompt user for API key, Application key, and Datadog site
api_key = sys.argv[1].strip()
app_key = sys.argv[2].strip()
datadog_site = sys.argv[3].strip()

# Load the alert rules from the JSON file
with open('aerospike_datadog_monitors.json') as f:
monitors = json.load(f)

for monitor in monitors:

url = f'https://{datadog_site}/api/v1/monitor'

# Send the POST request to create the monitor
response = requests.post(
url,
headers={
'Content-Type': 'application/json',
'DD-API-KEY': api_key,
'DD-APPLICATION-KEY': app_key
},
json=monitor
)

if response.status_code == 200:
print("Monitor created successfully:", response.json())
else:
print("Failed to create monitor. Status code:", response.status_code)
print("Response:", response.json())


if __name__ == '__main__':

if len( sys.argv)!=4 :
print("Usage: python3 manage_aerospike_monitors.py <API_KEY> <APP_KEY> <DATADOG_SITE_ID> ")
else:
manage_monitors()

0 comments on commit 9e753b1

Please sign in to comment.