Connecting to Databricks
Connect your Databricks account to OneLens for cost visibility, analysis, and optimization — using a read-only service principal and Unity Catalog system tables.
TL;DR
What this does: Connects OneLens to your Databricks account via Unity Catalog system tables to pull DBU consumption, SKU pricing, compute configuration, and job/pipeline metadata — giving you unified cost visibility, right-sizing recommendations, idle-compute detection, tag-based allocation, and anomaly detection across every workspace in your Databricks account.
Time required: ~20 minutes
Who you need: A Databricks user who is both an account admin and a metastore admin (required to grant access to system schemas), plus a workspace admin to grant SQL warehouse access.
What OneLens reads: Read-only SELECT on a specific list of system catalog schemas — system.billing, system.compute, system.lakeflow, and system.access.workspaces_latest. OneLens does not read any of your data catalogs, tables, notebooks, or audit logs.
What You'll Get Once Connected
Unified Cost Explorer
See Databricks DBU spend alongside your AWS, Azure, GCP, OCI, and AI provider costs in one dashboard.
Cost by Workspace, SKU & Product
Break spend down by workspace, SKU, and billing origin product (Jobs, All-Purpose, SQL, DLT, Model Serving).
List-Price Cost Attribution
Joins system.billing.usage to system.billing.list_prices to convert raw DBU quantities into dollar cost per record.
Job & Pipeline Cost Attribution
Attribute DBU spend down to individual jobs, tasks, runs, and Lakeflow pipelines — not just to a workspace.
Tag-Based Allocation & Chargeback
Use custom tags on clusters, warehouses, and jobs to allocate cost to teams, cost centers, or products.
Idle & Oversized Compute Detection
Flags clusters with long auto-termination windows, warehouses with generous auto-stop, and consistently under-utilized nodes.
All-Purpose vs. Jobs Compute Waste
Identifies scheduled workloads running on All-Purpose compute, where the same work on Jobs compute costs materially less.
Warehouse Right-Sizing
Correlates warehouse size and uptime against actual query load to recommend a smaller size or tighter auto-stop.
Cost Anomaly Detection
Alerts when Databricks spend deviates from historical baselines — catch a runaway cluster the day it starts.
Budgets & Forecasting
Set budgets at the account, workspace, or tag level and track run-rate against them with OneLens alerts.
Security at a Glance
Does OneLens read our data — tables, notebooks, or files?
No. OneLens is granted SELECT only on named system catalog schemas. It has no privileges on any user catalog, schema, table, volume, or model, and cannot browse or query them.
Does OneLens read our audit logs?
No. system.access.audit is explicitly not granted. The only table OneLens reads from the access schema is system.access.workspaces_latest, which provides workspace IDs and names for labelling.
Does OneLens see user identities or object names?
Yes — this is unavoidable and worth understanding. system.billing.usage includes an identity_metadata struct (run_as, owned_by, created_by) containing user emails, and a usage_metadata struct that can include job_name, notebook_path, app_name, and — for materialized views — uc_table_catalog, uc_table_schema, and uc_table_name. These are names and paths, never contents. They are what makes per-owner and per-job chargeback possible. See the FAQ for what this does and does not reveal.
Does OneLens see SQL query text?
Only if you opt in. system.query.history contains a statement_text column. It is not part of the default grant. Enable it only if you want query-level cost attribution — see Optional: Query-Level Attribution.
Is access read-only?
Yes. System tables are read-only by design and cannot be modified by anyone. The service principal is granted USE CATALOG, USE SCHEMA, and SELECT — no MODIFY, CREATE, MANAGE, or ownership.
What authentication is used?
A Databricks-managed service principal using OAuth M2M (client credentials). Access tokens are short-lived — one hour — and minted per request. No long-lived personal access token is used.
Can the service principal run expensive compute?
It is granted CAN USE on one SQL warehouse only. It cannot create clusters, warehouses, jobs, or pipelines, and cannot attach to or modify any other compute.
How is data transmitted and stored?
All calls use HTTPS/TLS 1.2+ to your workspace URL. The client secret is entered directly in the OneLens integration form and encrypted at rest using GCP KMS.
Can I restrict by IP?
Yes. Add OneLens's static egress IP ranges to your Databricks workspace IP access list. Contact support@astuto.ai for the current ranges.
What about Databricks' guidance on exporting system table data?
Databricks advises care when moving system table data off-platform, because system tables can expose sensitive operational detail. This is why OneLens's default grant excludes audit logs, lineage, and query text — the ingested set is billing, pricing, compute configuration, and job metadata only.
Cost of the Integration
OneLens creates no new infrastructure in your Databricks account. System tables themselves are free — Databricks charges only for the compute used to query them. The only cost is a small amount of SQL warehouse uptime once per day.
The figures below assume a dedicated 2X-Small serverless SQL warehouse at the AWS US list rate of 4 DBU/hour × $0.70/DBU = $2.80/hour ($0.047/minute), with auto_stop_mins set to 5 — the lowest value the UI allows for serverless.
Serverless SQL warehouse compute
~5–10 min of 2X-Small uptime per day: 3–5 min of query execution plus the auto-stop idle tail. 5 min/day = $0.23/day; 10 min/day = $0.47/day
$7–$14/month
System table storage & retention
Hosted by Databricks, free for the standard retention period
$0
Data egress
Result sets leave Databricks-hosted serverless compute, not your VPC
$0
Storage in your account
None — OneLens writes nothing back
$0
New resources created
None
$0
Estimated total
Sum of above
$7–$14/month
If you reuse an existing warehouse that is already running during your business day, the marginal cost is effectively $0 — OneLens's queries execute inside uptime you are already paying for. This is the cheapest option, and OneLens's queries are small enough not to affect concurrency.
If you use a classic or pro warehouse instead of serverless, add the underlying cloud VM cost (a 2X-Small classic warehouse runs one i3.2xlarge driver plus one worker) for the duration of the poll. Serverless is recommended precisely because it avoids this.
How It Works
Databricks system tables are a Databricks-hosted analytical store of your account's operational data, exposed as read-only Delta tables in the system catalog of every Unity Catalog metastore. They are governed by Unity Catalog, and no principal has access to them by default — access must be granted explicitly by a user who is both an account admin and a metastore admin.
Critically, system tables are account-wide, not workspace-wide. system.billing.usage contains billable usage for every workspace in your account, and is replicated globally. system.compute and system.lakeflow contain regional data covering every workspace in that region — including workspaces that are not themselves Unity Catalog-enabled. This means a single OneLens connection, made through one UC-enabled workspace, covers your whole account in that region.
OneLens authenticates as a Databricks service principal using OAuth M2M, exchanges the client ID and secret for a one-hour access token at your workspace's OIDC token endpoint, and runs parameterised SELECT statements through the SQL Statement Execution API (/api/2.0/sql/statements) against a SQL warehouse you nominate. Queries are date-bounded and column-selective. Costs are computed by joining usage records to the SKU price effective at the time of usage:
Two details in that query matter for accuracy. First, OneLens reads pricing.effective_list.default rather than pricing.default, because effective_list is the field Databricks resolves list and promotional pricing into — using pricing.default alone overstates cost during a promotional period. Second, the query aggregates with SUM rather than reading individual rows. system.billing.usage handles corrections by appending a RETRACTION record with a negated usage_quantity followed by a RESTATEMENT record with the corrected values. Summing lets the retraction cancel the original automatically; reading rows individually would double-count.
Prerequisites
A Databricks account on a Premium plan or above — Unity Catalog and system tables are not available on Standard or Trial workspaces.
At least one Unity Catalog-enabled workspace. System tables can only be queried from a UC-enabled workspace, though they contain data from all workspaces.
The metastore must be on Unity Catalog Privilege Model Version 1.0. Older metastores need to be upgraded to privilege inheritance first.
A user with both the account admin and metastore admin roles — required to grant
SELECTon system schemas. Neither role alone is sufficient.A SQL warehouse in the UC-enabled workspace. A dedicated 2X-Small serverless warehouse is recommended.
Your workspace URL (for example
https://dbc-a1b2c3d4-e5f6.cloud.databricks.com) and the target SQL warehouse ID.
What OneLens Will Access
The service principal is granted USE CATALOG on system, then USE SCHEMA + SELECT on exactly these schemas:
system.billing
usage, list_prices
The core cost dataset: DBU quantity per record, SKU, workspace, custom tags, and the historical price log used to convert DBUs to dollars.
system.compute
clusters, warehouses, warehouse_events, node_timeline, node_types, instance_pools
Compute configuration and utilization — powers right-sizing, idle detection, and auto-stop/auto-termination recommendations.
system.lakeflow
jobs, job_tasks, job_run_timeline, job_task_run_timeline, pipelines, pipeline_update_timeline
Job and pipeline metadata, so DBU spend can be attributed to a named job or pipeline rather than an anonymous cluster ID.
system.access
workspaces_latest only
Maps workspace IDs to human-readable workspace names. Granted at table level — not at schema level, so system.access.audit and the lineage tables stay out of scope.
Optional: AI & Model Serving Costs
If you run Mosaic AI Model Serving or AI Gateway and want that spend broken out in OneLens alongside your OpenAI, Anthropic, and Bedrock costs, additionally grant:
system.serving
served_entities, endpoint_usage
Per-endpoint token counts and served model metadata.
system.ai_gateway
usage, external_model_spend
AI Gateway request metrics and estimated spend on externally routed models.
Optional: Query-Level Attribution
system.query.history enables per-query cost attribution — showing which queries drove warehouse uptime and which users are responsible for spend.
What OneLens Will NOT Access
Any user catalog, schema, table, view, volume, function, or model — the service principal holds no privileges outside the
systemcatalog.system.access.audit— audit logs are never granted.system.access.table_lineageandsystem.access.column_lineage— lineage data is out of scope.system.query.history— excluded unless you explicitly opt in.Notebooks, repos, workspace files, and secrets — no workspace object permissions are granted.
Model invocation — the service principal cannot call model serving endpoints or run any inference.
Cluster, warehouse, job, or pipeline creation or modification — it holds
CAN USEon a single warehouse and nothing more.Account or workspace administration — the service principal is not an account admin, metastore admin, or workspace admin.
Billing and payment method details — OneLens reads usage and list prices, not your invoice or payment instrument.
Confirm System Schemas Are Enabled
Some system schemas are enabled by default and others must be turned on. Check which are active, and enable any that are missing.
Run this from a machine with the Databricks CLI configured against your account. Find your metastore ID in Catalog Explorer → your metastore → Details.
billing is enabled by default on all accounts. The caller must be an account admin or metastore admin.
Create a Service Principal and OAuth Secret
Create a dedicated Databricks-managed service principal so its access can be audited, rotated, and revoked independently of any human user.
In the account console, go to User management → Service principals → Add service principal.
Name it OneLens Integration. Do not grant it account admin.
Open the service principal, go to the Permissions tab, and assign it to the Unity Catalog-enabled workspace you will connect through. Assign the User entitlement only — not workspace admin.
Generate the OAuth secret. In the account console this is the service principal's Credentials & secrets tab; from inside a workspace it is Settings → Identity and access → Service principals → Manage → select the principal → Secrets. Click Generate secret and set a lifetime (maximum 730 days).
Copy the Client ID (the same value as the Application ID) and the Secret.
Both account admins and workspace admins can create an OAuth secret.
Grant Read Access on the System Schemas
Run the following in a SQL editor or notebook in your UC-enabled workspace. The user running this must hold both the account admin and metastore admin roles — an account admin alone will get PERMISSION_DENIED: User is not an owner of Schema 'system.compute'.
Replace <CLIENT_ID> with the service principal's application ID (the UUID, not the display name).
Optional — AI and model serving spend:
Optional — query-level attribution (contains query text, see the warning above):
Verify the grants landed:
Grant Warehouse Access
The service principal needs a warehouse to execute its queries on. A dedicated 2X-Small serverless warehouse keeps the cost predictable and isolates OneLens from your users' workloads.
Go to SQL → SQL Warehouses.
Either create a new warehouse (Serverless, size 2X-Small, max clusters 1) or pick an existing one.
On Auto stop: serverless warehouses default to 10 minutes and the UI will not let you go below 5. If you want to trim the idle tail further, create or edit the warehouse through the SQL Warehouses API, where
auto_stop_minscan be set as low as 1. That takes the integration's monthly cost from roughly $7–14 down to $4–6.Open the warehouse → Permissions → add the OneLens Integration service principal with CAN USE.
Copy the warehouse ID from the warehouse's Connection details tab, or from the end of the HTTP path (
/sql/1.0/warehouses/<warehouse_id>).
CAN USE permits running queries on the warehouse. It does not permit editing, resizing, or deleting it.
(Optional) Restrict Access by IP
If your workspace uses IP access lists, add OneLens's static egress ranges so the integration isn't blocked.
Request the current OneLens egress IP ranges from support@astuto.ai.
In the workspace, go to Settings → Security → IP access list.
Add the ranges to your allow list.
If you do not use IP access lists, skip this step — nothing further is required.
Connect to OneLens
In OneLens, open the Integrations page, select the Databricks integration, and enter the following. The client secret is encrypted at rest — there is no need to share it over email or chat.
Integration Name
A display name for this connection
Acme Corp Databricks
Workspace URL
Your UC-enabled workspace host, no trailing path
https://dbc-a1b2c3d4-e5f6.cloud.databricks.com
Client ID
The service principal's application ID
a1b2c3d4-e5f6-7890-abcd-ef1234567890
Client Secret
The OAuth secret generated in Step 2
dose...
SQL Warehouse ID
The warehouse the service principal can use
abc123def4567890
Cloud
Which cloud your Databricks account runs on
AWS / Azure / GCP
Backfill Window
How far back to load history (max 12 months)
12 months
OneLens will begin ingesting on the next scheduled poll.
Verify the Connection
After connecting, check the OneLens dashboard for:
Databricks spend appearing in the cost explorer
Workspace, SKU, and billing-origin-product breakdowns populating
Job and pipeline level attribution appearing under cost allocation
Historical usage backfilling across the requested window
If nothing appears within 24 hours, confirm the credentials and grants work independently. Mint a token and run a probe query:
A SUCCEEDED status with rows confirms authentication, warehouse permission, and Unity Catalog grants are all correct.
Data Refresh Schedule
Billing and pricing (
system.billing.usage,system.billing.list_prices): polled once per 24 hours. Databricks explicitly does not support real-time monitoring of system tables — data lands throughout the day with inherent latency, so polling more often surfaces no fresher data while adding warehouse uptime cost.Compute and job metadata (
system.compute,system.lakeflow): polled in the same daily window, since configuration changes slowly.Backfill on connection: OneLens loads up to 12 months of history on first connect, bounded by Databricks' free retention period for
system.billing.usage(365 days).node_timelineretains 90 days;list_pricesis retained indefinitely.Current-period figures may shift, for two reasons. Usage records arrive with a lag, so the current month's total moves as records land. Separately, Databricks issues corrections by appending
RETRACTIONandRESTATEMENTrecords, which can revise a figure for a date that has already closed. OneLens re-reads a trailing window on each poll to pick these up.
Data Privacy & Security
Least-privilege scope —
SELECTon four named system schemas, withsystem.accessgranted at table level so audit logs and lineage stay out of reach.No data-plane access — zero privileges on any user catalog, schema, table, volume, or model. OneLens sees object names and owner identities from the billing metadata, never contents.
Read-only by construction — system tables are read-only for every principal; no
MODIFY,CREATE,MANAGE, or ownership is granted.Short-lived credentials — OAuth M2M access tokens expire after one hour and are minted per request. No long-lived personal access token.
Query text excluded by default —
system.query.historyis opt-in, with a redacted mode available.TLS in transit — all calls to your workspace use HTTPS/TLS 1.2+.
Encrypted at rest — the client secret is entered directly in the OneLens form and encrypted using GCP KMS; no external key-sharing tool is involved.
Network restriction supported — OneLens egress IPs can be pinned in your workspace IP access list.
Data retention — 12-month default, configurable. Deletion within 30 days on request with confirmation.
Troubleshooting
PERMISSION_DENIED: User is not an owner of Schema 'system.compute'
The person running the GRANT statements holds only the account admin role, not metastore admin.
In the account console, open Catalog → your metastore → Edit and assign yourself as metastore admin. Re-run the grants. You can unassign yourself afterwards.
Schema 'system.compute' does not exist or the schema is empty
The system schema has not been enabled on the metastore.
Run databricks system-schemas enable <METASTORE_ID> compute, then repeat for lakeflow and access.
401 Unauthorized from the token endpoint
Wrong token issuer, or the secret has expired. M2M tokens must come from the Databricks OIDC endpoint, not your IdP or cloud provider.
Confirm you are posting to <workspace-url>/oidc/v1/token with grant_type=client_credentials&scope=all-apis. Generate a fresh secret if the old one has lapsed.
Workspace not found / host not found
The service principal has not been assigned to the workspace, or the workspace URL includes a trailing /api or path segment.
Assign the service principal to the workspace in the account console. Use the bare workspace URL with no suffix.
Warehouse ... does not exist or you do not have permission
CAN USE was never granted on the warehouse, or the warehouse ID belongs to a different workspace.
Add the service principal with CAN USE on the warehouse, and confirm the ID matches the workspace in the connection.
System Table query returned too much data. Please repeat query with more selective predicates.
A query was not sufficiently selective — Databricks rejects unbounded system table scans to protect performance.
OneLens date-bounds every query. If this appears during backfill, shorten the backfill window and let it load incrementally.
Connected, but no data after 24–48 hours
Either the first poll has not run, or the warehouse is failing to start.
Run the verification query from Step 7. Check SQL Warehouses → Monitoring for start failures, and confirm the warehouse is not stopped by a policy.
Cost figures look lower than the Databricks invoice
System tables report list price. They do not apply DBCU commit discounts, private offers, or negotiated rates, and exclude the underlying cloud VM cost for classic compute.
Expected behaviour. Configure your commit discount in OneLens, and connect your AWS/Azure/GCP account so the infrastructure side of the bill is captured too.
New columns cause ingestion warnings
Databricks may add columns to system tables or fields to struct columns at any time.
No action needed — OneLens selects columns explicitly and tolerates additive schema changes. Report persistent warnings to support.
Some workspaces are missing from the data
System tables are regional for compute and lakeflow. Workspaces in another cloud region belong to a different metastore.
Add a second OneLens Databricks integration through a UC-enabled workspace in that region. Note that system.billing.usage is global and already covers everything.
Appendix: Personal Access Token Authentication
Not recommended. OneLens also supports authenticating as a service principal using a personal access token (PAT) instead of OAuth M2M. This exists only for environments where OAuth is blocked by policy.
PATs are long-lived bearer credentials. If one leaks, it stays valid until someone notices and revokes it, whereas an OAuth M2M access token expires within the hour. Databricks is steadily moving customers toward OAuth across its drivers and SDKs, so PAT-based setups should be treated as a migration liability rather than a steady state.
If you must use a PAT: generate it on behalf of the service principal (never a human user), scope the same Unity Catalog grants and warehouse permission described above, set the shortest workable expiry, and put a calendar reminder on rotation. Supply the workspace URL, the token, and the warehouse ID in the OneLens integration form. Plan to move to OAuth M2M when policy allows.
Frequently Asked Questions
Need Help?
Databricks Documentation:
OneLens Support: support@astuto.ai
Last updated

