I'm using Python (as Python wheel application) on Databricks.
I deploy & run my jobs using dbx.
I defined some Databricks Workflow using Python wheel tasks.
Everything is working fine, but I'm having issue to extract "databricks_job_id" & "databricks_run_id" for logging/monitoring purpose.
I'm used to defined {{job_id}} & {{run_id}} as parameter in "Notebook Task" or other task type, ( see this How do you get the run parameters and runId within Databricks notebook?) but with Python wheel I'm not able to define theses :
With Python wheel task, parameters are basically an array of string :
["/dbfs/Shared/dbx/projects/myproject/66655665aac24e748d4e7b28c6f4d624/artifacts/myparameter.yml","/dbfs/Shared/dbx/projects/myproject/66655665aac24e748d4e7b28c6f4d624/artifacts/conf"]
Adding "{{job_id}}" & "{{run_id}}" in this array doesn't seems to work ...
Do you have any ideas ? Don't want to use any REST API during my workload just to extract theses ids...
Follow below Approach .You will get the Run Id and job id .
code:
Using Log analytics: If you have configured diagnostic logs in azure databricks , you can use KQL queries to get the JobID and RunID :
For information refer this SO thread by CHEEKATLAPRADEEP.
First create pass the parameter and define the job or task and Fetch and print the values.
For more info refer this blog by Jitesh Soni