Skip to main content
Community Hub
TL;DR

Learn how to mine query history from Cloud SQL for PostgreSQL to generate lineage and usage metrics.

Your AI can read this via Docs MCPcurl -fsSL "https://docs.atlan.com/install-docs-mcp" | bashConnect

Cloud SQL for PostgreSQL miner app

The Cloud SQL for PostgreSQL miner app mines query history from pg_stat_statements to generate lineage and usage metrics. Build it with the CloudsqlPostgresMiner builder.

A miner doesn't create a connection or take a credential—it runs on an existing Cloud SQL for PostgreSQL connection and reuses that connection's own credential, so you only supply the connection's qualifiedName.

Source extraction​

Mine query history from Cloud SQL for PostgreSQL
from pyatlan.client.atlan import AtlanClient
from pyatlan.model.apps import CloudsqlPostgresMiner

client = AtlanClient()

response = (
CloudsqlPostgresMiner(client)
.connection( # (1)
qualified_name="default/cloudsql-postgres/1700000000",
)
.redact_sql_text(True) # (2)
.run(name="cloudsql-prod-miner") # (3)
)
print(response.slug, response.run_id)
  1. Required. The exact qualifiedName of the existing Cloud SQL for PostgreSQL connection to mine. The builder resolves that connection's credential automatically—no credential step is needed.
  2. Optional. Replace literal values in the mined query text with placeholders. Off by default, and separate from the crawler's setting. See Query redaction.
  3. Always pass an explicit name for miners. A miner has no connection display name to derive one from, so a bare .run() defaults the workflow name to the app id (cloudsql-postgres-miner) and a second run collides (409 already exists).

Update existing workflows​

Publish a new version on the same slug with the builder's load() / update(). It reads the workflow's current inputs, lets you change only the fields you pass, and preserves everything else (the miner keeps reusing the connection's own credential). No run starts; the next run uses the new version.

Turn on Redact SQL Text via the builder
(
CloudsqlPostgresMiner(client)
.load("cloudsql-prod-miner-AbC123") # (1)
.redact_sql_text(True) # (2)
.update()
)
  1. Seed the builder from the workflow's current inputs.
  2. Change only the fields you need; anything unset keeps its current value.

To update every crawler and miner at once, see Update existing workflows on the assets app page. See Manage apps for the rest of the lifecycle—list, get, run status, schedules, and delete—shared by every app.

Was this page helpful?