23 Jul 2021
02:49 PM
- last edited on
03 Oct 2022
11:20 AM
by
Ana_Kuzmenchuk
Hi Peeps,
I'm having an issue with creating a custom disk rule with tags. The rule gets created - no problems there. The only issue is the when the tags are included in the JSON data structure - spaces come between the Key and the Value. I have checked my python code to ensure that no spaces(or whitespaces) are getting inserted into the data structure passed into the POST REST API. I wonder if anyone else has encountered similar. Any insight is much appreciated. Thanks in advance. Here are my details:
So here is the snippet of code that does the creation of this custom disk rule:
Output of the script:
Processing metric: odsstl_data_data3...
{"name":"odsstl_data_data3","enabled":true,"metric":"LOW_DISK_SPACE","threshold":10.0,"samples":5,"violatingSamples":3,"diskNameFilter":{"operator":"EQUALS","value":"/odsstl/data/data3"},"tagFilters":[{"value":"/odsstl/data/data3","key":"LinInf_DBAFS","context":"CONTEXTLESS"}]}
Completed Successfuly. Response Code: 201
(In debug mode it prints the contents of the JSON variable (jdisk_event_detail)
Here we have a snippet of the calling function(from the script):
if debug:
print("\n" + jdisk_event_detail + "\n") ç= This is what prints the contents of the JSON data
stat = dyn_api_token.create_dyn_obj(dynapi_token, "anomalyDetection/diskEvents", jdisk_event_detail) ç The call to the function to create the metric
if stat == 201:
print("Completed Successfuly. " + "Response Code: " + str(stat))
else:
print("Failed. " + "Response Code: " + str(stat))
:
:
(Goes on to do other bits)
Called Function:
def create_dyn_obj(dynapi_token, url_diskevents, jdisk_event_detail):
dynapi_token = "Api-token " + dynapi_token
localurl = ""
localurl = url + url_diskevents
try:
jfmt_dmetrics = requests.post(localurl, data = jdisk_event_detail, proxies = { "https" : clsproxy }, headers = { "Authorization" : dynapi_token, "Content-Type" : "application/json" }) ç POST API
except:
print("")
print("GET request to URL: " + url + " failed with error: " + jfmt_dmetrics)
print("")
else:
return jfmt_dmetrics.status_code
Hello Community members, would you save a few minutes to take a broad look at the issue detailed in the post above? What would be helpful to go through it?