AlloyDB for PostgreSQL Source
5 minute read
About
AlloyDB for PostgreSQL is a fully-managed, PostgreSQL-compatible database for demanding transactional workloads. It provides enterprise-grade performance and availability while maintaining 100% compatibility with open-source PostgreSQL.
If you are new to AlloyDB for PostgreSQL, you can create a free trial cluster.
Available Tools
AlloyDB for PostgreSQL Source Tools
| Tool Name | Description |
|---|---|
| alloydb-ai-nl Tool | The "alloydb-ai-nl" tool leverages [AlloyDB AI](https://cloud.google.com/alloydb/ai) next-generation Natural Language support to provide the ability to query the database directly using natural language. |
AlloyDB for PostgreSQL Source maintains full compatibility with PostgreSQL Source, allowing you to use the following tools with your AlloyDB for PostgreSQL Source source:
| Tool Name | Description |
|---|---|
| postgres-database-overview Tool | The "postgres-database-overview" fetches the current state of the PostgreSQL server. |
| postgres-execute-sql Tool | A "postgres-execute-sql" tool executes a SQL statement against a Postgres database. |
| postgres-get-column-cardinality Tool | The "postgres-get-column-cardinality" tool estimates the number of unique values in one or all columns of a Postgres database table. |
| postgres-list-active-queries Tool | The "postgres-list-active-queries" tool lists currently active queries in a Postgres database. |
| postgres-list-available-extensions Tool | The "postgres-list-available-extensions" tool retrieves all PostgreSQL extensions available for installation on a Postgres database. |
| postgres-list-database-stats Tool | The "postgres-list-database-stats" tool lists lists key performance and activity statistics of PostgreSQL databases. |
| postgres-list-indexes Tool | The "postgres-list-indexes" tool lists indexes in a Postgres database. |
| postgres-list-installed-extensions Tool | The "postgres-list-installed-extensions" tool retrieves all PostgreSQL extensions installed on a Postgres database. |
| postgres-list-locks Tool | The "postgres-list-locks" tool lists active locks in the database, including the associated process, lock type, relation, mode, and the query holding or waiting on the lock. |
| postgres-list-pg-settings Tool | The "postgres-list-pg-settings" tool lists PostgreSQL run-time configuration settings. |
| postgres-list-publication-tables Tool | The "postgres-list-publication-tables" tool lists publication tables in a Postgres database. |
| postgres-list-query-stats Tool | The "postgres-list-query-stats" tool lists query statistics from a Postgres database. |
| postgres-list-roles Tool | The "postgres-list-roles" tool lists user-created roles in a Postgres database. |
| postgres-list-schemas Tool | The "postgres-list-schemas" tool lists user-defined schemas in a database. |
| postgres-list-sequences Tool | The "postgres-list-sequences" tool lists sequences in a Postgres database. |
| postgres-list-stored-procedure Tool | The "postgres-list-stored-procedure" tool retrieves metadata for stored procedures in PostgreSQL, including procedure definitions, owners, languages, and descriptions. |
| postgres-list-table-stats Tool | The "postgres-list-table-stats" tool reports table statistics including size, scan metrics, and bloat indicators for PostgreSQL tables. |
| postgres-list-tables Tool | The "postgres-list-tables" tool lists schema information for all or specified tables in a Postgres database. |
| postgres-list-tablespaces Tool | The "postgres-list-tablespaces" tool lists tablespaces in a Postgres database. |
| postgres-list-triggers Tool | The "postgres-list-triggers" tool lists triggers in a Postgres database. |
| postgres-list-views Tool | The "postgres-list-views" tool lists views in a Postgres database, with a default limit of 50 rows. |
| postgres-long-running-transactions Tool | The postgres-long-running-transactions tool Identifies and lists database transactions that exceed a specified time limit. For each of the long running transactions, the output contains the process id, database name, user name, application name, client address, state, connection age, transaction age, query age, last activity age, wait event type, wait event, and query string. |
| postgres-replication-stats Tool | The "postgres-replication-stats" tool reports replication-related metrics for WAL streaming replicas, including lag sizes presented in human-readable form. |
| postgres-sql Tool | A "postgres-sql" tool executes a pre-defined SQL statement against a Postgres database. |
Pre-built Configurations
AlloyDB using MCP Connect your IDE to AlloyDB using Toolbox.
AlloyDB Admin API using MCP Create your AlloyDB database with MCP Toolbox.
Requirements
IAM Permissions
By default, AlloyDB for PostgreSQL source uses the AlloyDB Go Connector to authorize and establish mTLS connections to your AlloyDB instance. The Go connector uses your Application Default Credentials (ADC) to authorize your connection to AlloyDB.
In addition to setting the ADC for your server, you need to ensure the IAM identity has been given the following IAM roles (or corresponding permissions):
roles/alloydb.clientroles/serviceusage.serviceUsageConsumer
Networking
AlloyDB supports connecting over both from external networks via the internet (public IP), and internal networks (private IP). For more information on choosing between the two options, see the AlloyDB page Connection overview.
You can configure the ipType parameter in your source configuration to
public or private to match your cluster’s configuration. Regardless of which
you choose, all connections use IAM-based authorization and are encrypted with
mTLS.
Authentication
This source supports both password-based authentication and IAM authentication (using your Application Default Credentials).
Standard Authentication
To connect using user/password, create
a PostgreSQL user and input your credentials in the user and
password fields.
user: ${USER_NAME}
password: ${PASSWORD}
IAM Authentication
To connect using IAM authentication:
- Prepare your database instance and user following this guide.
- You could choose one of the two ways to log in:
- Specify your IAM email as the
user. - Leave your
userfield blank. Toolbox will fetch the ADC automatically and log in using the email associated with it.
- Specify your IAM email as the
- Leave the
passwordfield blank.
Example
kind: sources
name: my-alloydb-pg-source
type: alloydb-postgres
project: my-project-id
region: us-central1
cluster: my-cluster
instance: my-instance
database: my_db
user: ${USER_NAME}
password: ${PASSWORD}
# ipType: "public"
Tip
Use environment variable replacement with the format ${ENV_NAME} instead of hardcoding your secrets into the configuration file.
Managed Connection Pooling
Toolbox automatically supports Managed Connection Pooling. If your AlloyDB instance has Managed Connection Pooling enabled, the connection will immediately benefit from increased throughput and reduced latency.
The interface is identical, so there’s no additional configuration required on the client. For more information on configuring your instance, see the AlloyDB Managed Connection Pooling documentation.
Reference
| field | type | required | description |
|---|---|---|---|
| type | string | true | Must be “alloydb-postgres”. |
| project | string | true | Id of the GCP project that the cluster was created in (e.g. “my-project-id”). |
| region | string | true | Name of the GCP region that the cluster was created in (e.g. “us-central1”). |
| cluster | string | true | Name of the AlloyDB cluster (e.g. “my-cluster”). |
| instance | string | true | Name of the AlloyDB instance within the cluster (e.g. “my-instance”). |
| database | string | true | Name of the Postgres database to connect to (e.g. “my_db”). |
| user | string | false | Name of the Postgres user to connect as (e.g. “my-pg-user”). Defaults to IAM auth using ADC email if unspecified. |
| password | string | false | Password of the Postgres user (e.g. “my-password”). Defaults to attempting IAM authentication if unspecified. |
| ipType | string | false | IP Type of the AlloyDB instance; must be one of public or private. Default: public. |
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.