nayan_wylde
Esteemed Contributor II

use this code to view all active jobs. But use a token that is admin to the workspace.

%python
import requests
import json

# Replace these variables with your specific values
databricks_instance = 'your-workspace-url'
token = 'use an admin token'

# Define the API endpoint
url = f'https://{databricks_instance}/api/2.0/jobs/runs/list'

# Define the parameters
params = {
    'active_only': 'true'
}

# Define the headers
headers = {
    'Authorization': f'Bearer {token}'
}

# Make the GET request
response = requests.get(url, headers=headers, params=params)

# Check if the request was successful
if response.status_code == 200:
    # Parse the JSON response
    data = response.json()
    # Print the active job runs
    print(json.dumps(data, indent=4))
else:
    print(f'Error: {response.status_code}')
    print(response.text)