<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Catch Metadata Workflow databricks in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/catch-metadata-workflow-databricks/m-p/104700#M41848</link>
    <description>&lt;P&gt;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/133094"&gt;@jeremy98&lt;/a&gt;,&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Accessing metadata such as the start time, end time, and trigger information of a running Databricks job cannot be accomplished using dbutils.widgets.get(). The dbutils.widgets utility is designed for retrieving the current value of input widgets within notebooks and does not provide access to job metadata.&lt;BR /&gt;&lt;BR /&gt;To obtain metadata about a running job, you should utilize the Databricks REST API, specifically the Jobs API. The GET /api/2.0/jobs/runs/get endpoint allows you to retrieve detailed information about a specific job run, including its start time, end time, and the user who triggered the run. See the Jobs Api docs for more deitails&amp;nbsp;&lt;A href="https://docs.databricks.com/en/reference/jobs-2.0-api.html?utm_source=chatgpt.com" target="_blank" rel="noopener"&gt;Jobs API 2.0 | Databricks on AWS&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Here's an example of how you can use the Databricks REST API to retrieve job run metadata:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import requests

# Replace with your Databricks workspace URL and access token
workspace_url = 'https://&amp;lt;databricks-instance&amp;gt;'
access_token = 'your_access_token'

# Replace with your job run ID
run_id = '&amp;lt;run_id&amp;gt;'

# Set up the request headers with the access token
headers = {
    'Authorization': f'Bearer {access_token}'
}

# Make the API request to get job run details
response = requests.get(f'{workspace_url}/api/2.0/jobs/runs/get?run_id={run_id}', headers=headers)

# Check if the request was successful
if response.status_code == 200:
    run_details = response.json()
    # Extract metadata from the response
    start_time = run_details.get('start_time')
    end_time = run_details.get('end_time')
    triggered_by = run_details.get('creator_user_name')
    print(f'Start Time: {start_time}')
    print(f'End Time: {end_time}')
    print(f'Triggered By: {triggered_by}')
else:
    print(f'Error: {response.status_code} - {response.text}')&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 08 Jan 2025 12:52:12 GMT</pubDate>
    <dc:creator>fmadeiro</dc:creator>
    <dc:date>2025-01-08T12:52:12Z</dc:date>
    <item>
      <title>Catch Metadata Workflow databricks</title>
      <link>https://community.databricks.com/t5/data-engineering/catch-metadata-workflow-databricks/m-p/104670#M41837</link>
      <description>&lt;P&gt;Hello community,&lt;/P&gt;&lt;P&gt;Is it possible to get metadata workflow of a databricks job that is running? Like the start time, end time, triggered by etc.? Using dbutils.widgets.get()?&lt;/P&gt;</description>
      <pubDate>Wed, 08 Jan 2025 10:47:38 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/catch-metadata-workflow-databricks/m-p/104670#M41837</guid>
      <dc:creator>jeremy98</dc:creator>
      <dc:date>2025-01-08T10:47:38Z</dc:date>
    </item>
    <item>
      <title>Re: Catch Metadata Workflow databricks</title>
      <link>https://community.databricks.com/t5/data-engineering/catch-metadata-workflow-databricks/m-p/104673#M41839</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/133094"&gt;@jeremy98&lt;/a&gt;&amp;nbsp;, Good Day!&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Could you please refer to the below community post on how to Retrieve job-level parameters in Python?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://community.databricks.com/t5/data-engineering/retrieve-job-level-parameters-in-python/td-p/44720" target="_blank" rel="noopener"&gt;https://community.databricks.com/t5/data-engineering/retrieve-job-level-parameters-in-python/td-p/44720&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Also please refer to this document to understand how we can use the command &lt;STRONG&gt;dbutils.widgets.get&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://docs.databricks.com/en/dev-tools/databricks-utils.html#get-command-dbutilswidgetsget" target="_blank"&gt;https://docs.databricks.com/en/dev-tools/databricks-utils.html#get-command-dbutilswidgetsget&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Please let me know if this helps and leave a like if this information is useful, followups are appreciated.&lt;BR /&gt;Kudos&lt;BR /&gt;Ayushi&lt;/P&gt;</description>
      <pubDate>Wed, 08 Jan 2025 11:07:14 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/catch-metadata-workflow-databricks/m-p/104673#M41839</guid>
      <dc:creator>Ayushi_Suthar</dc:creator>
      <dc:date>2025-01-08T11:07:14Z</dc:date>
    </item>
    <item>
      <title>Re: Catch Metadata Workflow databricks</title>
      <link>https://community.databricks.com/t5/data-engineering/catch-metadata-workflow-databricks/m-p/104676#M41841</link>
      <description>&lt;P&gt;I want this information about databricks workflow run (metadata):&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jeremy98_0-1736334880103.png" style="width: 400px;"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/13945i6CFA585ECC7090DC/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jeremy98_0-1736334880103.png" alt="jeremy98_0-1736334880103.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Jan 2025 11:15:27 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/catch-metadata-workflow-databricks/m-p/104676#M41841</guid>
      <dc:creator>jeremy98</dc:creator>
      <dc:date>2025-01-08T11:15:27Z</dc:date>
    </item>
    <item>
      <title>Re: Catch Metadata Workflow databricks</title>
      <link>https://community.databricks.com/t5/data-engineering/catch-metadata-workflow-databricks/m-p/104700#M41848</link>
      <description>&lt;P&gt;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/133094"&gt;@jeremy98&lt;/a&gt;,&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Accessing metadata such as the start time, end time, and trigger information of a running Databricks job cannot be accomplished using dbutils.widgets.get(). The dbutils.widgets utility is designed for retrieving the current value of input widgets within notebooks and does not provide access to job metadata.&lt;BR /&gt;&lt;BR /&gt;To obtain metadata about a running job, you should utilize the Databricks REST API, specifically the Jobs API. The GET /api/2.0/jobs/runs/get endpoint allows you to retrieve detailed information about a specific job run, including its start time, end time, and the user who triggered the run. See the Jobs Api docs for more deitails&amp;nbsp;&lt;A href="https://docs.databricks.com/en/reference/jobs-2.0-api.html?utm_source=chatgpt.com" target="_blank" rel="noopener"&gt;Jobs API 2.0 | Databricks on AWS&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Here's an example of how you can use the Databricks REST API to retrieve job run metadata:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import requests

# Replace with your Databricks workspace URL and access token
workspace_url = 'https://&amp;lt;databricks-instance&amp;gt;'
access_token = 'your_access_token'

# Replace with your job run ID
run_id = '&amp;lt;run_id&amp;gt;'

# Set up the request headers with the access token
headers = {
    'Authorization': f'Bearer {access_token}'
}

# Make the API request to get job run details
response = requests.get(f'{workspace_url}/api/2.0/jobs/runs/get?run_id={run_id}', headers=headers)

# Check if the request was successful
if response.status_code == 200:
    run_details = response.json()
    # Extract metadata from the response
    start_time = run_details.get('start_time')
    end_time = run_details.get('end_time')
    triggered_by = run_details.get('creator_user_name')
    print(f'Start Time: {start_time}')
    print(f'End Time: {end_time}')
    print(f'Triggered By: {triggered_by}')
else:
    print(f'Error: {response.status_code} - {response.text}')&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Jan 2025 12:52:12 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/catch-metadata-workflow-databricks/m-p/104700#M41848</guid>
      <dc:creator>fmadeiro</dc:creator>
      <dc:date>2025-01-08T12:52:12Z</dc:date>
    </item>
    <item>
      <title>Re: Catch Metadata Workflow databricks</title>
      <link>https://community.databricks.com/t5/data-engineering/catch-metadata-workflow-databricks/m-p/104769#M41871</link>
      <description>&lt;P&gt;Hello,&lt;BR /&gt;Thanks for this answer :), but if I want to know which is the last run about the same workflow that I actually run? How to catch the run_id?&lt;BR /&gt;&lt;BR /&gt;EDIT: ok, I need to change the API url in this way&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;/api/2.0/jobs/runs/list?job_id=&amp;lt;id-of-the-job&amp;gt; ... thanks! Considering the query parameters possible to use perfect&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Wed, 08 Jan 2025 19:20:57 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/catch-metadata-workflow-databricks/m-p/104769#M41871</guid>
      <dc:creator>jeremy98</dc:creator>
      <dc:date>2025-01-08T19:20:57Z</dc:date>
    </item>
    <item>
      <title>Re: Catch Metadata Workflow databricks</title>
      <link>https://community.databricks.com/t5/data-engineering/catch-metadata-workflow-databricks/m-p/104773#M41872</link>
      <description>&lt;P&gt;To identify the run_id of the last run of a specific Databricks job (or workflow), you can use the Databricks REST API's GET /api/2.0/jobs/runs/list endpoint. This endpoint returns a list of runs for a specified job, sorted in descending order by their start time. By examining the most recent entry, you can obtain the run_id of the last run.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Here’s how you can catch the run_id of the most recent run for a given job:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import requests

# Replace with your Databricks workspace URL and access token
workspace_url = 'https://&amp;lt;databricks-instance&amp;gt;'
access_token = 'your_access_token'

# Replace with your job ID
job_id = '&amp;lt;job_id&amp;gt;'

# Set up the request headers with the access token
headers = {
    'Authorization': f'Bearer {access_token}'
}

# Make the API request to list runs for the specified job
response = requests.get(f'{workspace_url}/api/2.0/jobs/runs/list?job_id={job_id}', headers=headers)

# Check if the request was successful
if response.status_code == 200:
    runs = response.json().get('runs', [])
    if runs:
        # Get the most recent run (first in the list)
        last_run = runs[0]
        last_run_id = last_run.get('run_id')
        print(f'Last Run ID: {last_run_id}')
    else:
        print('No runs found for the specified job.')
else:
    print(f'Error: {response.status_code} - {response.text}')&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Jan 2025 20:00:26 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/catch-metadata-workflow-databricks/m-p/104773#M41872</guid>
      <dc:creator>fmadeiro</dc:creator>
      <dc:date>2025-01-08T20:00:26Z</dc:date>
    </item>
    <item>
      <title>Re: Catch Metadata Workflow databricks</title>
      <link>https://community.databricks.com/t5/data-engineering/catch-metadata-workflow-databricks/m-p/120266#M46109</link>
      <description>&lt;P&gt;Now The best practice for this is not using the API (some functions were deprecated for this objective) instead you should use job parameters&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;job_id = dbutils.widgets.get("job parameter name with job_id")
job_run = dbutils.widgets.get("job parameter name with job_run")
job_name = dbutils.widgets.get("job parameter name with job_name")&lt;/LI-CODE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Juan_Cardona_0-1748293834042.png" style="width: 400px;"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/17138iA51660507A085B63/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Juan_Cardona_0-1748293834042.png" alt="Juan_Cardona_0-1748293834042.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;this list might not have all the job metadata&lt;/P&gt;&lt;P&gt;the list : ( to see the complete list just add as value over the parameter {{}} and a dropdown will appear.)&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Juan_Cardona_1-1748293914615.png" style="width: 400px;"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/17139i427044AC4051A707/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Juan_Cardona_1-1748293914615.png" alt="Juan_Cardona_1-1748293914615.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 26 May 2025 21:13:31 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/catch-metadata-workflow-databricks/m-p/120266#M46109</guid>
      <dc:creator>Juan_Cardona</dc:creator>
      <dc:date>2025-05-26T21:13:31Z</dc:date>
    </item>
  </channel>
</rss>

