Learn how to mine query history from Cloud SQL for PostgreSQL to generate lineage and usage metrics.
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
- Python
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)
- Required. The exact
qualifiedNameof the existing Cloud SQL for PostgreSQL connection to mine. The builder resolves that connection's credential automatically—no credential step is needed. - Optional. Replace literal values in the mined query text with placeholders. Off by default, and separate from the crawler's setting. See Query redaction.
- Always pass an explicit
namefor 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.
- Python
(
CloudsqlPostgresMiner(client)
.load("cloudsql-prod-miner-AbC123") # (1)
.redact_sql_text(True) # (2)
.update()
)
- Seed the builder from the workflow's current inputs.
- 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.