Skip to main content
Question

Getting running job metrics using python sdk


Yumura
Fan

Is it possible to get the running job’s metric using Python sdk, e.g execution time, status etc?

2 replies

Bikram
Headliner
Forum|alt.badge.img+1
  • Headliner
  • 486 replies
  • April 14, 2023

@Yumura 

To get the metrices we can call rest API call in python sdk. kindly try this code snippet and check if it helps.

 

You can create a function with argument as control hub url, api key , job id in it and return the response string .

 

import requests
endpoint_url = ‘SDC URL/jobrunner/rest/v1/jobs/{job_id}/metrics'

headers = {
        'Content-Type': 'application/json',
        'X-Requested-By': 'SDC',
        'X-SS-REST-CALL': 'true',
        'X-SS-User-Auth-Token': api_key
    }

response = requests.get(endpoint_url, headers=headers)

if response.status_code == 200:
        # Return the job metrics from the response
        return response.json()


  • Opening Band
  • 8 replies
  • December 13, 2023
Bikram wrote:

@Yumura

To get the metrices we can call rest API call in python sdk. kindly try this code snippet and check if it helps.

 

You can create a function with argument as control hub url, api key , job id in it and return the response string .

 

import requests
endpoint_url = ‘SDC URL/jobrunner/rest/v1/jobs/{job_id}/metrics'

headers = {
        'Content-Type': 'application/json',
        'X-Requested-By': 'SDC',
        'X-SS-REST-CALL': 'true',
        'X-SS-User-Auth-Token': api_key
    }

response = requests.get(endpoint_url, headers=headers)

if response.status_code == 200:
        # Return the job metrics from the response
        return response.json()

This was outside of the SDK and I find it hard to use.

 

With the newly released version 6 SDK, can we retrieve job metrics now? From the SDK doc, I can’t see how to retrieve attributes like start time, etc. I have figured out how to get other attributes like job id, name, status (status, and status color), tags, etc.

Now, we are also moving to the new “Platform” from the classical ControlHub. The above code snippet hasn’t worked for me, using the new base URL na02.hub.streamsets.com.

Thanks!


Reply