Elastic Google Drive connector reference
editElastic Google Drive connector reference
editThe Elastic Google Drive connector is a connector for Google Drive. This connector is written in Python using the Elastic connector framework.
View the source code for this connector (branch 8.17, compatible with Elastic 8.17).
Elastic managed connector reference
editView Elastic managed connector reference
Availability and prerequisites
editThis connector is available as a managed connector as of Elastic version 8.11.0.
To use this connector natively in Elastic Cloud, satisfy all managed connector requirements.
Usage
editTo use this connector natively in Elastic Cloud, see Elastic managed connectors.
For additional operations, see Connectors UI in Kibana.
Connector authentication prerequisites
editBefore syncing any data from Google Drive, you need to create a service account with appropriate access to Google Drive API.
To get started, log into Google Cloud Platform and go to the Console
.
- Create a Google Cloud Project. Give your project a name, change the project ID and click the Create button.
-
Enable Google APIs. Choose APIs & Services from the left menu and click on
Enable APIs and Services
. You need to enable the Drive API. -
Create a Service Account. In the
APIs & Services
section, click onCredentials
and click onCreate credentials
to create a service account. Give your service account a name and a service account ID. This is like an email address and will be used to identify your service account in the future. ClickDone
to finish creating the service account. Your service account needs to have access to at least the following scope:-
https://www.googleapis.com/auth/drive.readonly
-
-
Create a Key File.
-
In the Cloud Console, go to
IAM and Admin
>Service accounts
page. - Click the email address of the service account that you want to create a key for.
-
Click the
Keys
tab. Click theAdd key
drop-down menu, then selectCreate new key
. -
Select JSON as the Key type and then click
Create
. This will download a JSON file that will contain the service account credentials.
-
In the Cloud Console, go to
-
[Optional] Share Google Drive Folders. If you use domain-wide delegation for syncing data you can skip this step. Go to your Google Drive. Right-click the folder or shared drive, choose
Share
and add the email address of the service account you created in step 3. as a viewer to this folder.
When you grant a service account access to a specific folder or shared drive in Google Drive, it’s important to note that the permissions extend to all the children within that folder or drive. This means that any folders or files contained within the granted folder or drive inherit the same access privileges as the parent.
Additional authentication prerequisites for domain-wide delegation
editThis step is required when Use domain-wide delegation for data sync or Enable document level security configuration option is enabled.
-
Enable Google APIs.
Choose APIs & Services from the left menu and click on
Enable APIs and Services
. You need to enable the Admin SDK API and Drive API. -
Google Workspace domain-wide delegation of authority.
To access drive and user data in a Google Workspace domain, the service account that you created needs to be granted access by a super administrator for the domain. You can follow the official documentation to perform Google Workspace domain-wide delegation of authority.
You need to grant the following OAuth Scopes to your service account:
-
https://www.googleapis.com/auth/admin.directory.group.readonly
-
https://www.googleapis.com/auth/admin.directory.user.readonly
-
https://www.googleapis.com/auth/drive.readonly
-
https://www.googleapis.com/auth/drive.metadata.readonly
This step allows the connector to:
- access user data and their group memberships in a Google Workspace organization
- access Google Drive data in drives associated to Google Workspace members
-
Configuration
editThe following configuration fields are required:
- Google Drive service account JSON
- The service account credentials generated from Google Cloud Platform (JSON string). Refer to the Google Cloud documentation for more information.
- Enable document level security
-
Toggle to enable document level security (DLS. DLS is supported for the Google Drive connector. When enabled:
-
Full syncs will fetch access control lists for each document and store them in the
_allow_access_control
field. - Access control syncs will fetch users' access control lists and store them in a separate index.
-
Full syncs will fetch access control lists for each document and store them in the
- Google Workspace admin email
- Google Workspace admin email. Required to enable document level security (DLS) or domain-wide delegation for data sync. A service account with delegated authority can impersonate an admin user with permissions to access Google Workspace user data and their group memberships. Refer to the Google Cloud documentation for more information.
Documents and syncs
editThe connector will fetch all files and folders the service account has access to.
It will attempt to extract the content from Google Suite documents (Google Docs, Google Sheets and Google Slides) and regular files.
- Content from files bigger than 10 MB won’t be extracted. (Self-managed connectors can use the self-managed local extraction service to handle larger binary files.)
- Permissions are not synced by default. You must first enable DLS. Otherwise, all documents indexed to an Elastic deployment will be visible to all users with access to that Elastic Deployment.
Sync types
editFull syncs are supported by default for all connectors.
This connector also supports incremental syncs.
Sync rules
editBasic sync rules are identical for all connectors and are available by default.
Advanced sync rules are not available for this connector in the present version. Currently filtering is controlled via ingest pipelines.
Document level security
editDocument level security (DLS) enables you to restrict access to documents based on a user’s permissions. Refer to configuration on this page for how to enable DLS for this connector.
Refer to DLS in Search Applications to learn how to ingest data from a connector with DLS enabled, when building a search application. The example uses SharePoint Online as the data source, but the same steps apply to every connector.
Content extraction
editSee Content extraction for more information.
Known issues
editThere are currently no known issues for this connector.
Troubleshooting
editSee Troubleshooting.
Security
editSee Security.
Self-managed connector
editView self-managed connector reference
Availability and prerequisites
editThis connector is available as a self-managed self-managed connector. To use this connector, satisfy all self-managed connector requirements.
Usage
editTo use this connector as a self-managed connector, see Self-managed connectors For additional usage operations, see Connectors UI in Kibana.
Connector authentication prerequisites
editBefore syncing any data from Google Drive, you need to create a service account with appropriate access to Google Drive API.
To get started, log into Google Cloud Platform and go to the Console
.
- Create a Google Cloud Project. Give your project a name, change the project ID and click the Create button.
-
Enable Google APIs. Choose APIs & Services from the left menu and click on
Enable APIs and Services
. You need to enable the Drive API. -
Create a Service Account. In the
APIs & Services
section, click onCredentials
and click onCreate credentials
to create a service account. Give your service account a name and a service account ID. This is like an email address and will be used to identify your service account in the future. ClickDone
to finish creating the service account. Your service account needs to have access to at least the following scope:-
https://www.googleapis.com/auth/drive.readonly
-
-
Create a Key File.
-
In the Cloud Console, go to
IAM and Admin
>Service accounts
page. - Click the email address of the service account that you want to create a key for.
-
Click the
Keys
tab. Click theAdd key
drop-down menu, then selectCreate new key
. -
Select JSON as the Key type and then click
Create
. This will download a JSON file that will contain the service account credentials.
-
In the Cloud Console, go to
-
[Optional] Share Google Drive Folders. If you use domain-wide delegation for syncing data you can skip this step. Go to your Google Drive. Right-click the folder or shared drive, choose
Share
and add the email address of the service account you created in step 3. as a viewer to this folder.
When you grant a service account access to a specific folder or shared drive in Google Drive, it’s important to note that the permissions extend to all the children within that folder or drive. This means that any folders or files contained within the granted folder or drive inherit the same access privileges as the parent.
Additional authentication prerequisites for domain-wide delegation
editThis step is required when Use domain-wide delegation for data sync or Enable document level security configuration option is enabled.
-
Enable Google APIs.
Choose APIs & Services from the left menu and click on
Enable APIs and Services
. You need to enable the Admin SDK API and Drive API. -
Google Workspace domain-wide delegation of authority.
To access drive and user data in a Google Workspace domain, the service account that you created needs to be granted access by a super administrator for the domain. You can follow the official documentation to perform Google Workspace domain-wide delegation of authority.
You need to grant the following OAuth Scopes to your service account:
-
https://www.googleapis.com/auth/admin.directory.group.readonly
-
https://www.googleapis.com/auth/admin.directory.user.readonly
-
https://www.googleapis.com/auth/drive.readonly
-
https://www.googleapis.com/auth/drive.metadata.readonly
This step allows the connector to:
- access user data and their group memberships in a Google Workspace organization
- access Google Drive data in drives associated to Google Workspace members
-
Configuration
editWhen using the self-managed connector workflow, initially these fields will use the default configuration set in the connector source code.
These are set in the get_default_configuration
function definition.
These configurable fields will be rendered with their respective labels in the Kibana UI. Once connected, you’ll be able to update these values in Kibana.
The following configuration fields are required:
-
service_account_credentials
- The service account credentials generated from Google Cloud Platform (JSON string). Refer to the Google Cloud documentation for more information.
-
use_domain_wide_delegation_for_sync
- Use domain-wide delegation to automatically sync content from all shared and personal drives in the Google workspace. This eliminates the need to manually share Google Drive data with your service account, though it may increase the sync time. If disabled, only items and folders manually shared with the service account will be synced.
-
google_workspace_admin_email_for_data_sync
- Required when domain-wide delegation for data sync is enabled. This email is used for discovery and syncing of shared drives. Only the shared drives this user has access to are synced.
-
google_workspace_email_for_shared_drives_sync
- Required when domain-wide delegation for data sync is enabled. Provide the Google Workspace user email for discovery and syncing of shared drives. Only the shared drives this user has access to will be synced.
-
use_document_level_security
-
Toggle to enable document level security (DLS. DLS is supported for the Google Drive connector. When enabled:
-
Full syncs will fetch access control lists for each document and store them in the
_allow_access_control
field. - Access control syncs will fetch users' access control lists and store them in a separate index.
-
Full syncs will fetch access control lists for each document and store them in the
-
google_workspace_admin_email
- Google Workspace admin email. Required to enable document level security (DLS) or domain-wide delegation for data sync. A service account with delegated authority can impersonate an admin user with permissions to access Google Workspace user data and their group memberships. Refer to the Google Cloud documentation for more information.
-
max_concurrency
- The maximum number of concurrent HTTP requests to the Google Drive API. Increasing this value can improve data retrieval speed, but it may also place higher demands on system resources and network bandwidth.
-
use_text_extraction_service
-
Requires a separate deployment of the Elastic Text Extraction Service.
Requires that pipeline settings disable text extraction.
Default value is
False
.
Deployment using Docker
editYou can deploy the Google Drive connector as a self-managed connector using Docker. Follow these instructions.
Step 1: Download sample configuration file
Download the sample configuration file. You can either download it manually or run the following command:
curl https://raw.githubusercontent.com/elastic/connectors/main/config.yml.example --output ~/connectors-config/config.yml
Remember to update the --output
argument value if your directory name is different, or you want to use a different config file name.
Step 2: Update the configuration file for your self-managed connector
Update the configuration file with the following settings to match your environment:
-
elasticsearch.host
-
elasticsearch.api_key
-
connectors
If you’re running the connector service against a Dockerized version of Elasticsearch and Kibana, your config file will look like this:
# When connecting to your cloud deployment you should edit the host value elasticsearch.host: http://host.docker.internal:9200 elasticsearch.api_key: <ELASTICSEARCH_API_KEY> connectors: - connector_id: <CONNECTOR_ID_FROM_KIBANA> service_type: google_drive api_key: <CONNECTOR_API_KEY_FROM_KIBANA> # Optional. If not provided, the connector will use the elasticsearch.api_key instead
Using the elasticsearch.api_key
is the recommended authentication method. However, you can also use elasticsearch.username
and elasticsearch.password
to authenticate with your Elasticsearch instance.
Note: You can change other default configurations by simply uncommenting specific settings in the configuration file and modifying their values.
Step 3: Run the Docker image
Run the Docker image with the Connector Service using the following command:
docker run \ -v ~/connectors-config:/config \ --network "elastic" \ --tty \ --rm \ docker.elastic.co/enterprise-search/elastic-connectors:8.17.0.0 \ /app/bin/elastic-ingest \ -c /config/config.yml
Refer to DOCKER.md
in the elastic/connectors
repo for more details.
Find all available Docker images in the official registry.
We also have a quickstart self-managed option using Docker Compose, so you can spin up all required services at once: Elasticsearch, Kibana, and the connectors service.
Refer to this README in the elastic/connectors
repo for more information.
Documents and syncs
editThe connector will fetch all files and folders the service account has access to.
It will attempt to extract the content from Google Suite documents (Google Docs, Google Sheets and Google Slides) and regular files.
- Content from files bigger than 10 MB won’t be extracted
- Permissions are not synced by default. You must first enable DLS. Otherwise, all documents indexed to an Elastic deployment will be visible to all users with access to that Elastic Deployment.
Sync types
editFull syncs are supported by default for all connectors.
This connector also supports incremental syncs.
Sync rules
editBasic sync rules are identical for all connectors and are available by default.
Advanced sync rules are not available for this connector in the present version. Currently filtering is controlled via ingest pipelines.
Document level security
editDocument level security (DLS) enables you to restrict access to documents based on a user’s permissions. Refer to configuration on this page for how to enable DLS for this connector.
Refer to DLS in Search Applications to learn how to ingest data from a connector with DLS enabled, when building a search application. The example uses SharePoint Online as the data source, but the same steps apply to every connector.
Content extraction
editSee Content extraction for more information.
End-to-end testing
editThe connector framework enables operators to run functional tests against a real data source. Refer to Connector testing for more details.
To perform E2E testing for the Google Drive connector, run the following command:
make ftest NAME=google_drive
For faster tests, add the DATA_SIZE=small
flag:
make ftest NAME=google_drive DATA_SIZE=small
Known issues
editThere are currently no known issues for this connector.
Troubleshooting
editSee Troubleshooting.
Security
editSee Security.