From 05bc3006ee8e73ff35b7ec4feec4c15b29408717 Mon Sep 17 00:00:00 2001 From: Anastasiia Tovpeko <114177030+atovpeko@users.noreply.github.com> Date: Fri, 14 Feb 2025 09:56:53 +0200 Subject: [PATCH] Duplicated PostgreSQL FDW to Integrations --- _partials/_foreign-data-wrappers.md | 196 ++++++++++++++++++ .../integrations/amazon-sagemaker.md | 2 +- use-timescale/integrations/aws-lambda.md | 4 +- .../integrations/find-connection-details.md | 2 +- use-timescale/integrations/index.md | 45 ++-- use-timescale/integrations/postgresql.md | 13 ++ use-timescale/page-index/page-index.js | 25 ++- .../foreign-data-wrappers.md | 104 +--------- 8 files changed, 255 insertions(+), 136 deletions(-) create mode 100644 _partials/_foreign-data-wrappers.md create mode 100644 use-timescale/integrations/postgresql.md diff --git a/_partials/_foreign-data-wrappers.md b/_partials/_foreign-data-wrappers.md new file mode 100644 index 0000000000..b720b66a8f --- /dev/null +++ b/_partials/_foreign-data-wrappers.md @@ -0,0 +1,196 @@ +import IntegrationPrereqs from "versionContent/_partials/_integration-prereqs.mdx"; + +You use PostgreSQL foreign data wrappers (FDWs) to query external data sources from a $SERVICE_LONG. These external data sources can be one of the following: + +- Other $SERVICE_LONGs +- PostgreSQL databases outside of $CLOUD_LONG + +If you are using $VPC peering, you can create FDWs in your Customer VPC to query a $SERVICE_SHORT in your $CLOUD_LONG project. However, you can't create FDWs in your $SERVICE_LONGs to query a data source in your Customer VPC. This is because $CLOUD_LONG $VPC peering uses AWS PrivateLink for increased security. See [VPC peering documentation][vpc-peering] for additional details. + +PostgreSQL FDWs are particularly useful if you manage multiple $SERVICE_LONGs with different capabilities, and need to seamlessly access and merge regular and time-series data. + +## Prerequisites + + + +## Query another data source + +To query another data source: + + + + + +You create PostgreSQL FDWs with the `postgres_fdw` extension, which is enabled by default in $CLOUD_LONG. + + + +1. **Connect to your service** + + See [how to connect][connect]. + +1. **Create a server** + + Run the following command using your [connection details][connection-info]: + + ```sql + CREATE SERVER myserver + FOREIGN DATA WRAPPER postgres_fdw + OPTIONS (host '', dbname 'tsdb', port ''); + ``` + +1. **Create user mapping** + + Run the following command using your [connection details][connection-info]: + + ```sql + CREATE USER MAPPING FOR tsdbadmin + SERVER myserver + OPTIONS (user 'tsdbadmin', password ''); + ``` + +1. **Import a foreign schema (recommended) or create a foreign table** + + - Import the whole schema: + + ```sql + CREATE SCHEMA foreign_stuff; + + IMPORT FOREIGN SCHEMA public + FROM SERVER myserver + INTO foreign_stuff ; + ``` + + - Alternatively, import a limited number of tables: + + ```sql + CREATE SCHEMA foreign_stuff; + + IMPORT FOREIGN SCHEMA public + LIMIT TO (table1, table2) + FROM SERVER myserver + INTO foreign_stuff; + ``` + + - Create a foreign table. Skip if you are importing a schema: + + ```sql + CREATE FOREIGN TABLE films ( + code char(5) NOT NULL, + title varchar(40) NOT NULL, + did integer NOT NULL, + date_prod date, + kind varchar(10), + len interval hour to minute + ) + SERVER film_server; + ``` + + + + +A user with the `tsdbadmin` role assigned already has the required `USAGE` permission to create PostgreSQL FDWs. You can enable another user, without the `tsdbadmin` role assigned, to query foreign data. To do so, explicitly grant the permission. For example, for a new `grafana` user: + +```sql +CREATE USER grafana; + +GRANT grafana TO tsdbadmin; + +CREATE SCHEMA fdw AUTHORIZATION grafana; + +CREATE SERVER db1 FOREIGN DATA WRAPPER postgres_fdw +OPTIONS (host '', dbname 'tsdb', port ''); + +CREATE USER MAPPING FOR grafana SERVER db1 +OPTIONS (user 'tsdbadmin', password ''); + +GRANT USAGE ON FOREIGN SERVER db1 TO grafana; + +SET ROLE grafana; + +IMPORT FOREIGN SCHEMA public + FROM SERVER db1 + INTO fdw; +``` + + + + + +You create PostgreSQL FDWs with the `postgres_fdw` extension. See [documenation][enable-fdw-docs] on how to enable it. + + + +1. **Connect to your database** + + Use [`psql`][psql] to connect to your database. + +1. **Create a server** + + Run the following command using your [connection details][connection-info]: + + ```sql + CREATE SERVER myserver + FOREIGN DATA WRAPPER postgres_fdw + OPTIONS (host '', dbname '', port ''); + ``` + +1. **Create user mapping** + + Run the following command using your [connection details][connection-info]: + + ```sql + CREATE USER MAPPING FOR postgres + SERVER myserver + OPTIONS (user 'postgres', password ''); + ``` + +1. **Import a foreign schema (recommended) or create a foreign table** + + - Import the whole schema: + + ```sql + CREATE SCHEMA foreign_stuff; + + IMPORT FOREIGN SCHEMA public + FROM SERVER myserver + INTO foreign_stuff ; + ``` + + - Alternatively, import a limited number of tables: + + ```sql + CREATE SCHEMA foreign_stuff; + + IMPORT FOREIGN SCHEMA public + LIMIT TO (table1, table2) + FROM SERVER myserver + INTO foreign_stuff; + ``` + + - Create a foreign table. Skip if you are importing a schema: + + ```sql + CREATE FOREIGN TABLE films ( + code char(5) NOT NULL, + title varchar(40) NOT NULL, + did integer NOT NULL, + date_prod date, + kind varchar(10), + len interval hour to minute + ) + SERVER film_server; + ``` + + + + + + + +[vpc-peering]: /use-timescale/:currentVersion:/security/vpc/ +[sql-editor]: /getting-started/:currentVersion:/run-queries-from-console/#ops-mode-sql-editor/ +[connect]: /getting-started/:currentVersion:/run-queries-from-console/ +[connection-info]: /use-timescale/:currentVersion:/integrations/find-connection-details/ +[enable-fdw-docs]: https://www.postgresql.org/docs/current/postgres-fdw.html +[psql]: /use-timescale/:currentVersion:/integrations/psql/ diff --git a/use-timescale/integrations/amazon-sagemaker.md b/use-timescale/integrations/amazon-sagemaker.md index a5c4928b85..d1a6b28b5b 100644 --- a/use-timescale/integrations/amazon-sagemaker.md +++ b/use-timescale/integrations/amazon-sagemaker.md @@ -19,7 +19,7 @@ This page shows you how to integrate Amazon Sagemaker with a $SERVICE_LONG. -* Setup an [AWS Account][aws-sign-up] +* Set up an [AWS Account][aws-sign-up] ## Prepare your $SERVICE_LONG to ingest data from SageMaker diff --git a/use-timescale/integrations/aws-lambda.md b/use-timescale/integrations/aws-lambda.md index 9ce2c86805..bcc2a9a36c 100644 --- a/use-timescale/integrations/aws-lambda.md +++ b/use-timescale/integrations/aws-lambda.md @@ -1,6 +1,6 @@ --- -title: Integrate AWS Lambda with $CLOUD_LONG -excerpt: ADD +title: Integrate AWS Lambda with Timescale Cloud +excerpt: With AWS Lambda, you can run code without provisioning or managing servers, and scale automatically. Integrate AWS Lambda with Timescale Cloud and inject data into your service products: [cloud, mst, self_hosted] keywords: [connect, integrate, aws, lambda] --- diff --git a/use-timescale/integrations/find-connection-details.md b/use-timescale/integrations/find-connection-details.md index c7c38c060e..4cf6b02430 100644 --- a/use-timescale/integrations/find-connection-details.md +++ b/use-timescale/integrations/find-connection-details.md @@ -37,7 +37,7 @@ Retrieve the connection details for your $SERVICE_LONG: -Find the connection details in the [PostgreSQL configuration file][postgres-config] or by asking your database administrator. +Find the connection details in the [PostgreSQL configuration file][postgres-config] or by asking your database administrator. The `postgres` superuser, created during PostgreSQL installation, has all the permissions required to run procedures in this documentation. However, it is recommended to create other users and assign permissions on the need-only basis. diff --git a/use-timescale/integrations/index.md b/use-timescale/integrations/index.md index 27856f9904..aeb3027b01 100644 --- a/use-timescale/integrations/index.md +++ b/use-timescale/integrations/index.md @@ -18,39 +18,39 @@ Some of the most in-demand integrations for $CLOUD_LONG are listed below, with l ## Query and administration -| Name | Description | -|:------------------------:|-------------------------------------------------------------------------------------------------------------------------------------------------| -| [Azure Data Studio][ads] | An open-source, cross-platform hybrid data analytics tool designed to simplify the data landscape. | -| [DBeaver][dbeaver] | A free cross-platform database tool for developers, database administrators, analysts, and everyone working with data. | -| [pgAdmin][pgadmin] | A feature-rich open-source administration and development platform for PostgreSQL. | -| [psql][psql] | A terminal-based frontend to PostgreSQL that enables you to type in queries interactively, issue them to PostgreSQL, and see the query results. | -| [qStudio][qstudio] | A modern free SQL editor that provides syntax highlighting, code completion, excel export, charting, and more. | - +| Name | Description | +|:------------------------:|-------------------------------------------------------------------------------------------------------------------------------------------| +| [Azure Data Studio][ads] | Query, manage, visualize, and develop databases across SQL Server, Azure SQL, and PostgreSQL. | +| [DBeaver][dbeaver] | Connect to, manage, query, and analyze multiple database in a single interface with SQL editing, visualization, and administration tools. | +| [pgAdmin][pgadmin] | Manage, query, and administer PostgreSQL databases through a graphical interface. | +| [psql][psql] | Run SQL queries, manage databases, automate tasks, and interact directly with PostgreSQL. | +| [qStudio][qstudio] | Write and execute SQL queries, manage database objects, and analyze data in a user-friendly interface. | +| [PostgreSQL][postgresql] | Access and query data from external sources as if they were regular PostgreSQL tables. | ## Observability and alerting -| Name | Description | -|:-------------------------------:|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| [Amazon Cloudwatch][cloudwatch] | A monitoring and observability service designed to help collect, analyze, and act on data from applications, infrastructure, and services running in AWS and on-premises environments. | -| [Datadog][datadog] | A cloud-based monitoring and analytics platform that provides comprehensive visibility into applications, infrastructure, and systems through real-time monitoring, logging, and analytics. | -| [Grafana][grafana] | An open-source analytics and monitoring solution that enables you to query, visualize, alert on, and explore your metrics, logs. | -| [Prometheus][prometheus] | An open-source monitoring system with a dimensional data model, flexible query language, and a modern alerting approach. | -| [Tableau][tableau] | A popular analytics platform that helps you gain greater intelligence about your business. | +| Name | Description | +|:-------------------------------:|------------------------------------------------------------------------------------------------------------------------------------| +| [Amazon Cloudwatch][cloudwatch] | Collect, analyze, and act on data from applications, infrastructure, and services running in AWS and on-premises environments. | +| [Datadog][datadog] | Gain comprehensive visibility into applications, infrastructure, and systems through real-time monitoring, logging, and analytics. | +| [Grafana][grafana] | Query, visualize, alert on, and explore your metrics and logs. | +| [Prometheus][prometheus] | Track the performance and health of systems, applications, and infrastructure. | +| [Tableau][tableau] | Connect to data sources, analyze data, and create interactive visualizations and dashboards. | ## Configuration and deployment -| Name | Description | -|:---------------------------:|-----------------------------------------------------------------------------------------------------------------------------| -| [Terraform][terraform] | An infrastructure-as-code tool that enables you to safely and predictably provision and manage infrastructure in any cloud. | +| Name | Description | +|:---------------------------:|--------------------------------------------------------------------------| +| [Terraform][terraform] | Safely and predictably provision and manage infrastructure in any cloud. | ## Data engineering and extract, transform, load -| Name | Description | -|:--------------------------------:|-------------------------------------------------------------------------------| -| [Amazon SageMaker][amazon-sagemaker]| Build, train, and deploy ML models into a production-ready hosted environment | -| [Apache Airflow][apache-airflow] | Programmatically author, schedule, and monitor workflows. | +| Name | Description | +|:--------------------------------:|-------------------------------------------------------------------------------------| +| [Amazon SageMaker][amazon-sagemaker]| Build, train, and deploy ML models into a production-ready hosted environment. | +| [Apache Airflow][apache-airflow] | Programmatically author, schedule, and monitor workflows. | | [AWS Lambda][aws-lambda]| Run code without provisioning or managing servers, scaling automatically as needed. | @@ -69,3 +69,4 @@ Some of the most in-demand integrations for $CLOUD_LONG are listed below, with l [postgresql-integrations]: https://slashdot.org/software/p/PostgreSQL/integrations/ [prometheus]: /use-timescale/:currentVersion:/integrations/prometheus [amazon-sagemaker]: /use-timescale/:currentVersion:/integrations/amazon-sagemaker +[postgresql]: /use-timescale/:currentVersion:/integrations/postgresql \ No newline at end of file diff --git a/use-timescale/integrations/postgresql.md b/use-timescale/integrations/postgresql.md new file mode 100644 index 0000000000..6373e73fad --- /dev/null +++ b/use-timescale/integrations/postgresql.md @@ -0,0 +1,13 @@ +--- +title: Integrate with PostgreSQL +excerpt: Query any other PostgreSQL database or another Timescale Cloud service from your service by using foreign data wrappers +products: [cloud] +keywords: [integrate, foreign data wrappers, fdw] +tags: [change] +--- + +import FDW from "versionContent/_partials/_foreign-data-wrappers.mdx"; + +# Integrate PostgreSQL with $CLOUD_LONG + + \ No newline at end of file diff --git a/use-timescale/page-index/page-index.js b/use-timescale/page-index/page-index.js index 5ad57deff9..8f0d3165be 100644 --- a/use-timescale/page-index/page-index.js +++ b/use-timescale/page-index/page-index.js @@ -778,6 +778,11 @@ module.exports = [ href: "find-connection-details", excerpt: "Learn about connecting to your Timescale database", }, + { + title: "Amazon CloudWatch", + href: "cloudwatch", + excerpt: "Integrate Amazon Cloudwatch with Timescale Cloud", + }, { title: "Amazon SageMaker", href: "amazon-sagemaker", @@ -788,11 +793,6 @@ module.exports = [ href: "apache-airflow", excerpt: "Integrate Apache Airflow with Timescale products", }, - { - title: "Amazon CloudWatch", - href: "cloudwatch", - excerpt: "Integrate Amazon Cloudwatch with Timescale Cloud", - }, { title: "AWS Lambda", href: "aws-lambda", @@ -813,11 +813,21 @@ module.exports = [ href: "dbeaver", excerpt: "Integrate DBeaver with Timescale products", }, + { + title: "Grafana", + href: "grafana", + excerpt: "Integrate Grafana with Timescale products", + }, { title: "pgAdmin", href: "pgadmin", excerpt: "Integrate pgAdmin with Timescale products", }, + { + title: "PostgreSQL", + href: "postgresql", + excerpt: "Integrate PostgreSQL with Timescale Cloud", + }, { title: "Prometheus", href: "prometheus", @@ -833,11 +843,6 @@ module.exports = [ href: "qstudio", excerpt: "Integrate qstudio with Timescale products", }, - { - title: "Grafana", - href: "grafana", - excerpt: "Integrate Grafana with Timescale products", - }, { title: "Tableau", href: "tableau", diff --git a/use-timescale/schema-management/foreign-data-wrappers.md b/use-timescale/schema-management/foreign-data-wrappers.md index e4ab4fb92c..6ace4b1ee0 100644 --- a/use-timescale/schema-management/foreign-data-wrappers.md +++ b/use-timescale/schema-management/foreign-data-wrappers.md @@ -1,112 +1,16 @@ --- title: Foreign data wrappers -excerpt: Query other Timescale Cloud services or external PostgreSQL databases by using foreign data wrappers +excerpt: Query other Timescale Cloud services or external PostgreSQL databases by using PostgreSQL foreign data wrappers products: [cloud, mst, self_hosted] keywords: [hypertables, schemas, alter] tags: [change] --- -# Foreign data wrappers - -You use foreign data wrappers (FDWs) to query external data sources from a $SERVICE_LONG. These external data sources can be one of the following: - -- $SERVICE_LONGs -- PostgreSQL databases outside of $CLOUD_LONG - -If you are using $VPC peering, you can create FDWs in your Customer VPC to query a $SERVICE_SHORT in your $CLOUD_LONG project. However, you can't create FDWs in your $SERVICE_LONGs to query a data source in your Customer VPC. This is because $CLOUD_LONG $VPC peering uses AWS PrivateLink for increased security. See [VPC peering documentation][vpc-peering] for additional details. - -FDWs are particularly useful if you manage multiple $SERVICE_LONGs with different capabilities, and need to seamlessly access and merge regular and time-series data. - -## Query another data source - -You create FDWs with the `postgres_fdw` extension, which is enabled by default. - - - -To query another data source, run the following queries in the [SQL editor][sql-editor]: - -1. **Create a server:** - - ```sql - CREATE SERVER myserver - FOREIGN DATA WRAPPER postgres_fdw - OPTIONS (host 'serviceID.projectID.tsdb.cloud.timescale.com', dbname 'tsdb', port '30702'); - ``` - -1. **Create user mapping:** - - ```sql - CREATE USER MAPPING FOR tsdbadmin - SERVER myserver - OPTIONS (user 'tsdbadmin', password 'mysupersecurepassword'); - ``` - -1. **Import a foreign schema (recommended) or create a foreign table:** - - - Import the whole schema: +import FDW from "versionContent/_partials/_foreign-data-wrappers.mdx"; - ```sql - CREATE SCHEMA foreign_stuff; - - IMPORT FOREIGN SCHEMA public - FROM SERVER myserver - INTO foreign_stuff ; - ``` - - - Alternatively, import a limited number of tables: - - ```sql - CREATE SCHEMA foreign_stuff; - - IMPORT FOREIGN SCHEMA public - LIMIT TO (table1, table2) - FROM SERVER myserver - INTO foreign_stuff; - ``` - - - Create a foreign table. Skip if you are importing a schema: - - ```sql - CREATE FOREIGN TABLE films ( - code char(5) NOT NULL, - title varchar(40) NOT NULL, - did integer NOT NULL, - date_prod date, - kind varchar(10), - len interval hour to minute - ) - SERVER film_server; - ``` - - - - -A user with the `tsdbadmin` role assigned already has the required `USAGE` permission to create FDWs. You can enable another user, without the `tsdbadmin` role assigned, to query foreign data. To do so, explicitly grant the permission: - -```sql -CREATE USER grafana; - -GRANT grafana TO tsdbadmin; - -CREATE SCHEMA fdw AUTHORIZATION grafana; - -CREATE SERVER db1 FOREIGN DATA WRAPPER postgres_fdw -OPTIONS (host 'serviceID.projectID.tsdb.cloud.timescale.com', dbname 'tsdb', port '30702'); - -CREATE USER MAPPING FOR grafana SERVER db1 -OPTIONS (user 'tsdbadmin', password 'mysupersecurepassword'); - -GRANT USAGE ON FOREIGN SERVER db1 TO grafana; - -SET ROLE grafana; - -IMPORT FOREIGN SCHEMA public - FROM SERVER db1 - INTO fdw; -``` +# Foreign data wrappers -[vpc-peering]: /use-timescale/:currentVersion:/security/vpc/ -[sql-editor]: /getting-started/:currentVersion:/run-queries-from-console/#ops-mode-sql-editor/ +