Showing results for 
Show  only  | Search instead for 
Did you mean: 

Creating a custom disk metric using API


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...




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))


              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


    jfmt_dmetrics =, data = jdisk_event_detail, proxies = { "https" : clsproxy }, headers = { "Authorization" : dynapi_token, "Content-Type" : "application/json" }) ç POST API



    print("GET request to URL: " + url + " failed with error: " + jfmt_dmetrics)



    return jfmt_dmetrics.status_code




Community Team
Community Team

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?

Featured Posts