Skip to content

Commit e661fd3

Browse files
committed
Add serverless details to connector tutorial
1 parent 285866e commit e661fd3

File tree

3 files changed

+144
-122
lines changed

3 files changed

+144
-122
lines changed

docs/docset.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,3 +111,5 @@ subs:
111111
feat-imp: "feature importance"
112112
feat-imp-cap: "Feature importance"
113113
nlp: "natural language processing"
114+
index-manage-app: "Index Management"
115+
connectors-app: "Connectors"

docs/reference/search-connectors/es-postgresql-connector-client-tutorial.md

Lines changed: 139 additions & 120 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,45 @@ navigation_title: "Tutorial"
33
mapped_pages:
44
- https://www.elastic.co/guide/en/elasticsearch/reference/current/es-postgresql-connector-client-tutorial.html
55
- https://www.elastic.co/guide/en/starting-with-the-elasticsearch-platform-and-its-solutions/current/getting-started-appsearch.html
6+
applies_to:
7+
stack: ga
8+
serverless: ga
9+
description: Set up a self-managed connector to synchronize and search data from an PostgreSQL data source.
610
---
711

8-
# PostgreSQL self-managed connector tutorial [es-postgresql-connector-client-tutorial]
9-
10-
11-
This tutorial walks you through the process of creating a self-managed connector for a PostgreSQL data source. You’ll be using the [self-managed connector](/reference/search-connectors/self-managed-connectors.md) workflow in the Kibana UI. This means you’ll be deploying the connector on your own infrastructure. Refer to the [Elastic PostgreSQL connector reference](/reference/search-connectors/es-connectors-postgresql.md) for more information about this connector.
12-
12+
# Set up a self-managed connector to search a PostgreSQL database
13+
14+
This tutorial walks you through the process of creating a self-managed connector for a PostgreSQL data source.
15+
<!--
16+
TBD: Moot point now?
17+
You’ll be using the [self-managed connector](/reference/search-connectors/self-managed-connectors.md) workflow in the Kibana UI. This means you’ll be deploying the connector on your own infrastructure.
18+
-->
19+
<!--
20+
TBD: Too soon to refer elsewhere?
21+
Refer to the [Elastic PostgreSQL connector reference](/reference/search-connectors/es-connectors-postgresql.md) for more information about this connector.
22+
-->
1323
In this exercise, you’ll be working in both the terminal (or your IDE) and the Kibana UI.
1424

1525
If you want to deploy a self-managed connector for another data source, use this tutorial as a blueprint. Refer to the list of available [connectors](/reference/search-connectors/index.md).
1626

1727
::::{tip}
1828
Want to get started quickly testing a self-managed connector using Docker Compose? Refer to this [guide](https://github.com/elastic/connectors/tree/main/scripts/stack#readme) in the `elastic/connectors` repo for more information.
29+
<!--
30+
TBD: Looks like this is only for the Stack scenario, not serverless?
31+
-->
1932
::::
2033

2134
## Prerequisites [es-postgresql-connector-client-tutorial-prerequisites]
2235

23-
2436
### Elastic prerequisites [es-postgresql-connector-client-tutorial-prerequisites-elastic]
2537

2638
First, ensure you satisfy the [prerequisites](/reference/search-connectors/self-managed-connectors.md#es-build-connector-prerequisites) for self-managed connectors.
2739

40+
<!--
41+
TBD: What privileges are required to complete these steps?
42+
- If you're using {{serverless-full}}, you must have a `developer` or `admin` predefined role or an equivalent custom role to add the connector.
43+
- If you're using {{ech}} or a self-managed cluster, start {{es}} and {{kib}}. To add the connector, you must have ...
44+
-->
2845

2946
### PostgreSQL prerequisites [es-postgresql-connector-client-tutorial-postgresql-prerequisites]
3047

@@ -47,142 +64,137 @@ Then restart the PostgreSQL server.
4764

4865
::::
4966

67+
## Set up the connector
5068

69+
:::::{stepper}
5170

52-
## Steps [es-postgresql-connector-client-tutorial-steps]
53-
54-
To complete this tutorial, you’ll need to complete the following steps:
55-
56-
1. [Create an Elasticsearch index](#es-postgresql-connector-client-tutorial-create-index)
57-
2. [Set up the connector](#es-postgresql-connector-client-tutorial-setup-connector)
58-
3. [Run the `connectors` connector service](#es-postgresql-connector-client-tutorial-run-connector-service)
59-
4. [Sync your PostgreSQL data source](#es-postgresql-connector-client-tutorial-sync-data-source)
71+
::::{step} Create an Elasticsearch index
72+
Elastic connectors enable you to create searchable, read-only replicas of your data sources in Elasticsearch.
73+
The first step in setting up your self-managed connector is to create an index.
6074

75+
In the Kibana UI, navigate to **{{index-manage-app}}** or use the [global search field](docs-content://explore-analyze/find-and-organize/find-apps-and-objects.md).
6176

62-
## Create an Elasticsearch index [es-postgresql-connector-client-tutorial-create-index]
63-
64-
Elastic connectors enable you to create searchable, read-only replicas of your data sources in Elasticsearch. The first step in setting up your self-managed connector is to create an index.
65-
66-
In the [Kibana^](docs-content://get-started/the-stack.md) UI, navigate to **Search > Content > Elasticsearch indices** from the main menu, or use the [global search field](docs-content://explore-analyze/query-filter/filtering.md#_finding_your_apps_and_objects).
67-
68-
Create a new connector index:
77+
{applies_to}`serverless: ga` Follow the index creation workflow then optionally define field mappings.
78+
For example, to add semantic search capabilities, you could add an extra field that stores your vectors for semantic search.
6979

80+
{applies_to}`stack: ga` Create a new connector index:
81+
<!--
82+
TBD: This steps don't apply to serverless?
83+
-->
7084
1. Under **Select an ingestion method** choose **Connector**.
7185
2. Choose **PostgreSQL** from the list of connectors.
7286
3. Name your index and optionally change the language analyzer to match the human language of your data source. (The index name you provide is automatically prefixed with `search-`.)
7387
4. Save your changes.
7488

7589
The index is created and ready to configure.
76-
77-
::::{admonition} Gather Elastic details
78-
:name: es-postgresql-connector-client-tutorial-gather-elastic-details
79-
80-
Before you can configure the connector, you need to gather some details about your Elastic deployment:
81-
82-
* **Elasticsearch endpoint**.
83-
84-
* If you’re an Elastic Cloud user, find your deployment’s Elasticsearch endpoint in the Cloud UI under **Cloud > Deployments > <your-deployment> > Elasticsearch**.
85-
* If you’re running your Elastic deployment and the connector service in Docker, the default Elasticsearch endpoint is `http://host.docker.internal:9200`.
86-
87-
* **API key.** You’ll need this key to configure the connector. Use an existing key or create a new one.
88-
* **Connector ID**. Your unique connector ID is automatically generated when you create the connector. Find this in the Kibana UI.
89-
9090
::::
9191

92+
::::{step} Configure the connector
93+
Once you’ve created an index, you can set up the connector.
94+
You will be guided through this process in the UI.
9295

96+
In the Kibana UI, navigate to **{{connectors-app}}** or use the global search field.
97+
If you're using {{es-serverless}}, click **{icon}`plus_in_circle` Self-managed connector**.
9398

94-
## Set up the connector [es-postgresql-connector-client-tutorial-setup-connector]
95-
96-
Once you’ve created an index, you can set up the connector. You will be guided through this process in the UI.
97-
98-
1. **Edit the name and description for the connector.** This will help your team identify the connector.
99-
2. **Clone and edit the connector service code.** For this example, we’ll use the [Python framework](https://github.com/elastic/connectors/tree/main). Follow these steps:
100-
101-
* Clone or fork that repository locally with the following command: `git clone https://github.com/elastic/connectors`.
102-
* Open the `config.yml` configuration file in your editor of choice.
103-
* Replace the values for `host`, `api_key`, and `connector_id` with the values you gathered [earlier](#es-postgresql-connector-client-tutorial-gather-elastic-details). Use the `service_type` value `postgresql` for this connector.
104-
105-
::::{dropdown} Expand to see an example config.yml file
106-
Replace the values for `host`, `api_key`, and `connector_id` with your own values. Use the `service_type` value `postgresql` for this connector.
107-
108-
```yaml
109-
elasticsearch:
110-
host: <https://<my-elastic-deployment.es.us-west2.gcp.elastic-cloud.com>> # Your Elasticsearch endpoint
111-
api_key: '<YOUR-API-KEY>' # Your top-level Elasticsearch API key
112-
...
113-
connectors:
114-
-
115-
connector_id: "<YOUR-CONNECTOR-ID>"
116-
api_key: "'<YOUR-API-KEY>" # Your scoped connector index API key (optional). If not provided, the top-level API key is used.
117-
service_type: "postgresql"
118-
119-
99+
1. Edit the name and description for the connector. This will help your team identify the connector.
100+
1. {applies_to}`serverless: ga` Choose PostgreSQL from the list of connector types.
101+
1. {applies_to}`serverless: ga` Copy the configuration details. Keep in mind the `api_key` for both `connector` and `elasticsearch` variables is the same.
102+
1. {applies_to}`stack: ga` Gather configuration details. Before you can proceed to the next step, you need to gather some details about your Elastic deployment:
120103

121-
# Self-managed connector settings
122-
connector_id: '<YOUR-CONNECTOR-ID>' # Your connector ID
123-
service_type: 'postgresql' # The service type for your connector
124-
125-
sources:
126-
# mongodb: connectors.sources.mongo:MongoDataSource
127-
# s3: connectors.sources.s3:S3DataSource
128-
# dir: connectors.sources.directory:DirectoryDataSource
129-
# mysql: connectors.sources.mysql:MySqlDataSource
130-
# network_drive: connectors.sources.network_drive:NASDataSource
131-
# google_cloud_storage: connectors.sources.google_cloud_storage:GoogleCloudStorageDataSource
132-
# azure_blob_storage: connectors.sources.azure_blob_storage:AzureBlobStorageDataSource
133-
postgresql: connectors.sources.postgresql:PostgreSQLDataSource
134-
# oracle: connectors.sources.oracle:OracleDataSource
135-
# sharepoint: connectors.sources.sharepoint:SharepointDataSource
136-
# mssql: connectors.sources.mssql:MSSQLDataSource
137-
# jira: connectors.sources.jira:JiraDataSource
138-
```
139-
140-
::::
141-
142-
143-
144-
## Run the connector service [es-postgresql-connector-client-tutorial-run-connector-service]
145-
146-
Now that you’ve configured the connector code, you can run the connector service.
147-
148-
In your terminal or IDE:
149-
150-
1. `cd` into the root of your `connectors` clone/fork.
151-
2. Run the following command: `make run`.
104+
* Elasticsearch endpoint:
105+
* If you’re an Elastic Cloud user, find your deployment’s Elasticsearch endpoint in the Cloud UI under **Cloud > Deployments > <your-deployment> > Elasticsearch**.
106+
* If you’re running your Elastic deployment and the connector service in Docker, the default Elasticsearch endpoint is `http://host.docker.internal:9200`.
107+
* API key: You’ll need this key to configure the connector. Use an existing key or create a new one.
108+
* Connector ID: Your unique connector ID is automatically generated when you create the connector. Find this in the Kibana UI.
109+
::::
110+
::::{step} Link your connector to Elasticsearch
111+
You need to run the connector code on your own infrastructure and link it to {{es}}.
112+
You have two options: [Run with Docker](/search-connectors/es-connectors-run-from-docker.md) and [Run from source](/search-connectors/es-connectors-run-from-source.md).
113+
For this example, we’ll use the latter method:
114+
115+
1. Clone or fork that repository locally with the following command: `git clone https://github.com/elastic/connectors`.
116+
1. Open the `config.yml` configuration file in your editor of choice.
117+
1. Replace the values for `host`, `api_key`, and `connector_id` with the values you gathered earlier. Use the `service_type` value `postgresql` for this connector.
118+
119+
:::{dropdown} Expand to see an example config.yml file
120+
Replace the values for `host`, `api_key`, and `connector_id` with your own values. Use the `service_type` value `postgresql` for this connector.
121+
122+
```yaml
123+
elasticsearch:
124+
host: <https://<my-elastic-deployment.es.us-west2.gcp.elastic-cloud.com>> # Your Elasticsearch endpoint
125+
api_key: '<YOUR-API-KEY>' # Your top-level Elasticsearch API key
126+
...
127+
connectors:
128+
-
129+
connector_id: "<YOUR-CONNECTOR-ID>"
130+
api_key: "'<YOUR-API-KEY>" # Your scoped connector index API key (optional). If not provided, the top-level API key is used.
131+
service_type: "postgresql"
132+
133+
134+
135+
# Self-managed connector settings
136+
connector_id: '<YOUR-CONNECTOR-ID>' # Your connector ID
137+
service_type: 'postgresql' # The service type for your connector
138+
139+
sources:
140+
# mongodb: connectors.sources.mongo:MongoDataSource
141+
# s3: connectors.sources.s3:S3DataSource
142+
# dir: connectors.sources.directory:DirectoryDataSource
143+
# mysql: connectors.sources.mysql:MySqlDataSource
144+
# network_drive: connectors.sources.network_drive:NASDataSource
145+
# google_cloud_storage: connectors.sources.google_cloud_storage:GoogleCloudStorageDataSource
146+
# azure_blob_storage: connectors.sources.azure_blob_storage:AzureBlobStorageDataSource
147+
postgresql: connectors.sources.postgresql:PostgreSQLDataSource
148+
# oracle: connectors.sources.oracle:OracleDataSource
149+
# sharepoint: connectors.sources.sharepoint:SharepointDataSource
150+
# mssql: connectors.sources.mssql:MSSQLDataSource
151+
# jira: connectors.sources.jira:JiraDataSource
152+
```
153+
154+
:::
155+
1. Now that you’ve configured the connector code, you can run the connector service. In your terminal or IDE:
156+
157+
1. `cd` into the root of your `connectors` clone/fork.
158+
1. Run the following command: `make run`.
152159

153160
The connector service should now be running. The UI will let you know that the connector has successfully connected to Elasticsearch.
154161

155-
Here we’re working locally. In production setups, you’ll deploy the connector service to your own infrastructure. If you prefer to use Docker, refer to the [repo docs](https://github.com/elastic/connectors/tree/main/docs/DOCKER.md) for instructions.
156-
157-
158-
## Sync your PostgreSQL data source [es-postgresql-connector-client-tutorial-sync-data-source]
159-
160-
161-
### Enter your PostgreSQL data source details [es-postgresql-connector-client-tutorial-sync-data-source-details]
162-
162+
:::{tip}
163+
Here we’re working locally. In production setups, you’ll deploy the connector service to your own infrastructure.
164+
:::
165+
::::
166+
::::{step} Enter your data source details
163167
Once you’ve configured the connector, you can use it to index your data source.
164168

165-
You can now enter your PostgreSQL instance details in the Kibana UI.
166-
167-
Enter the following information:
169+
Enter the following PostgreSQL instance details in the Kibana UI:
168170

169-
* **Host**. Server host address for your PostgreSQL instance.
170-
* **Port**. Port number for your PostgreSQL instance.
171-
* **Username**. Username of the PostgreSQL account.
172-
* **Password**. Password for that user.
173-
* **Database**. Name of the PostgreSQL database.
174-
* **Comma-separated list of tables**. `*` will fetch data from all tables in the configured database.
171+
* **Host**: The server host address for your PostgreSQL instance.
172+
* **Port**: The port number for your PostgreSQL instance.
173+
* **Username**: The username of the PostgreSQL account.
174+
* **Password**: The password for that user.
175+
* **Database**: The name of the PostgreSQL database.
176+
* **Comma-separated list of tables**: `*` will fetch data from all tables in the configured database.
175177

176-
Once you’ve entered all these details, select **Save configuration**.
177-
178-
179-
### Launch a sync [es-postgresql-connector-client-tutorial-sync-data-source-launch-sync]
178+
After you’ve entered all these details, select **Save configuration**.
179+
::::
180+
::::{step} Link your index
181+
{applies_to}`serverless: ga` Select the index to which the data must be synchronized.
182+
In this case, use the index we created in an earlier step.
183+
Click **Sync**.
184+
The connector will traverse the database and synchronize documents to your index.
185+
<!--
186+
TBD: Confirm whether the status at this stage should be "configured" or "sync complete"
187+
In the main **{{connectors-app}}** page, you can see the connector’s status.
188+
It should now indicate that the connector is configured and that the sync is complete.
189+
-->
190+
::::
191+
:::::
180192

181-
If you navigate to the **Overview** tab in the Kibana UI, you can see the connector’s *ingestion status*. This should now have changed to **Configured**.
193+
## Sync your data source [es-postgresql-connector-client-tutorial-sync-data-source]
182194

183-
It’s time to launch a sync by selecting the **Sync** button.
195+
In the **{{connectors-app}}** page, you can launch a sync on-demand or on a schedule.
184196

185-
If you navigate to the terminal window where you’re running the connector service, you should see output like the following:
197+
If you navigate to the terminal window where you’re running the connector service, after a sync occurs you should see output like the following:
186198

187199
```shell
188200
[FMWK][13:22:26][INFO] Fetcher <create: 499 update: 0 |delete: 0>
@@ -193,14 +205,21 @@ If you navigate to the terminal window where you’re running the connector serv
193205
(27 seconds)
194206
```
195207

196-
This confirms the connector has fetched records from your PostgreSQL table(s) and transformed them into documents in your Elasticsearch index.
208+
This confirms the connector has fetched records from your PostgreSQL tables and transformed them into documents in your Elasticsearch index.
209+
210+
If you verify your Elasticsearch documents and you’re happy with the results, set a recurring sync schedule.
211+
This will ensure your searchable data in {{es}} is always up to date with changes to your PostgreSQL data source.
197212

198-
Verify your Elasticsearch documents in the **Documents** tab in the Kibana UI.
213+
For example, in the **{{connectors-app}}** page, click on the connector, and then click **Scheduling**.
214+
Select every hour and click **Save**.
215+
The content will be synchronized at the top of every hour, as long as the connector is up and running.
199216

200-
If you’re happy with the results, set a recurring sync schedule in the **Scheduling** tab. This will ensure your *searchable* data in Elasticsearch is always up to date with changes to your PostgreSQL data source.
217+
## Next steps
201218

219+
You just learned how to synchronize data from an external database to {{es}}.
220+
For an overview of how to start searching and analyzing your data in Kibana, go to [Explore and analyze](docs-content://explore-analyze/index.md).
202221

203-
## Learn more [es-postgresql-connector-client-tutorial-learn-more]
222+
Learn more:
204223

205224
* [Overview of self-managed connectors and frameworks](/reference/search-connectors/self-managed-connectors.md)
206225
* [Elastic connector framework repository](https://github.com/elastic/connectors/tree/main)

docs/reference/search-connectors/self-managed-connectors.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ Self-managed [Elastic connectors](/reference/search-connectors/index.md) are run
1818
## Availability and Elastic prerequisites [es-build-connector-prerequisites]
1919

2020
::::{note}
21-
Self-managed connectors currently don’t support Windows. Use this [compatibility matrix](https://www.elastic.co/support/matrix#matrix_os) to check which operating systems are supported by self-managed connectors. Find this information under **self-managed connectors** on that page.
21+
Self-managed connectors currently don’t support Windows. Use this [compatibility matrix](https://www.elastic.co/support/matrix#matrix_os) to check which operating systems are supported by self-managed connectors.
22+
% Find this information under **self-managed connectors** on that page.
2223

2324
::::
2425

@@ -28,7 +29,7 @@ Your Elastic deployment must include the following Elastic services:
2829
* **Elasticsearch**
2930
* **Kibana**
3031

31-
(A new Elastic Cloud deployment includes these services by default.)
32+
A new {{ech}} deployment or {{es-serverless}} project includes these services by default.
3233

3334
To run self-managed connectors, your self-deployed connector service version must match your Elasticsearch version. For example, if you’re running Elasticsearch 8.10.1, your connector service should be version 8.10.1.x. Elastic does not support deployments running mismatched versions (except during upgrades).
3435

0 commit comments

Comments
 (0)