06-15-2022 05:23 AM
We are having Databricks Job running with main class and JAR file in it. Our JAR file code base is in Scala. Now, when our job starts running, we need to log Job ID and Run ID into the database for future purpose. How can we achieve this?
06-15-2022 05:25 AM
You can pass {job_id}} and {{run_id}} in Job arguments and print that information and save into wherever its needed
please find below the documentation for the same
https://docs.databricks.com/data-engineering/jobs/jobs.html#task-parameter-variables
{{job_id}}
The unique identifier assigned to a job
1276862
{{run_id}}
The unique identifier assigned to a job run
3447843
{{parent_run_id}}
The unique identifier assigned to the run of a job with multiple tasks.
3447835
{{task_key}}
The unique name assigned to a task that’s part of a job with multiple tasks.
06-15-2022 05:25 AM
You can pass {job_id}} and {{run_id}} in Job arguments and print that information and save into wherever its needed
please find below the documentation for the same
https://docs.databricks.com/data-engineering/jobs/jobs.html#task-parameter-variables
{{job_id}}
The unique identifier assigned to a job
1276862
{{run_id}}
The unique identifier assigned to a job run
3447843
{{parent_run_id}}
The unique identifier assigned to the run of a job with multiple tasks.
3447835
{{task_key}}
The unique name assigned to a task that’s part of a job with multiple tasks.
02-24-2023 11:16 AM
Here is a blog with code and examples on how to achieve this https://medium.com/@canadiandataguy/how-to-get-the-job-id-and-run-id-for-a-databricks-job-b0da484e66...
05-08-2024 01:05 AM
That article is for members only, can we also specify here how to do it (for those that are not medium members?). Thanks!
03-30-2026 11:56 AM
i came across a similar requirement and got it through named parameters. Wrote a community blog about it