How to query Databricks audit logs?

Mohammad Saber 591 Reputation points
2023-02-15T05:23:20.95+00:00

Hi,

I would like to ask where the Databricks Audit Log files are stored on the DBFS.

And is there any way that I can query log files?

Thanks.

Azure Databricks
Azure Databricks
An Apache Spark-based analytics platform optimized for Azure.
{count} votes

Answer accepted by question author
  1. Umang Middha 555 Reputation points
    2023-02-15T06:02:55.1066667+00:00

    Hello Mohammad,

    Hope you are doing well today. To query Databricks audit logs, you can use the Databricks REST API, which allows you to programmatically retrieve audit log events.

    Here are the general steps to follow:

    1. Generate an access token for your Databricks workspace. You can do this from the Databricks UI by going to the "User Settings" page, selecting the "Access Tokens" tab, and clicking "Generate New Token". Make sure to save the token somewhere safe, as it will be used to authenticate your API requests.
    2. Use the Databricks API to query the audit logs. The endpoint for querying audit logs is /api/2.0/audit/get. You can specify a range of time to query by setting the start_time and end_time parameters in ISO 8601 format. You can also filter by user, event type, resource type, and other parameters. For example, to get all audit events for a particular user, you can set the user_name parameter to the user's email address.
    3. Analyze the results of the API query. The audit log events will be returned in JSON format. You can use a tool like Jupyter Notebook or Apache Spark to load the JSON data and analyze it using Python or SQL.

    Regards,

    Umang Middha

    ******@gmail.com

    1 person found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. Maddipatla Madhura 1 Reputation point
    2024-04-29T07:02:48.6366667+00:00

    Hi @Umang Middha Can you please share official documentation link to support this

    Use the Databricks API to query the audit logs. The endpoint for querying audit logs is /api/2.0/audit/get.

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.