-
Notifications
You must be signed in to change notification settings - Fork 8.6k
Mysql datasource #276543
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
erikcurrin-elastic
merged 30 commits into
elastic:main
from
erikcurrin-elastic:mysql-datasource
Sep 15, 2026
Merged
Mysql datasource #276543
Changes from all commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
c04326b
Add MySQL data source connector
erikcurrin-elastic 9a76594
Revamp MySQL connector to conform to current connector-specs conventions
erikcurrin-elastic 66c69ba
Revamp MySQL connector to use ClientTypeSpec framework and add execut…
erikcurrin-elastic d7aa085
Fix LIMIT binding and extract runSql helper in MySQL connector
erikcurrin-elastic 92920af
Harden MySQL connector review follow-ups: shared SQL guard and TLS.
erikcurrin-elastic 527e444
Merge branch 'main' into mysql-datasource
erikcurrin-elastic 1c4f05a
Changes from node scripts/check
kibanamachine 3ef93d5
Fix mock parameter type in mysql client test
erikcurrin-elastic 4149b2e
Fix CI failures: remove unused mock param and add mysql2 renovate owner
erikcurrin-elastic 7e09a8a
Apply suggestions from code review
erikcurrin-elastic 232b7ec
Fix type errors in mysql.test.ts mock
erikcurrin-elastic 98c7605
PR review response
erikcurrin-elastic d6d7f15
Merge branch 'main' into mysql-datasource
erikcurrin-elastic ce6d4cf
Restructure MySQL connector docs per reviewer feedback
erikcurrin-elastic 42b5c23
Apply batched suggestions from code review
erikcurrin-elastic 9606fef
Merge branch 'main' into mysql-datasource
erikcurrin-elastic d9db712
Merge branch 'main' into mysql-datasource
erikcurrin-elastic 5653166
Move clientTypes to server-only entry to fix Storybook webpack build
erikcurrin-elastic 7397dc2
Block MySQL executable comments to prevent read-only guard bypass
erikcurrin-elastic a1db970
Fix clientTypes import to use server entry after moving it out of common
erikcurrin-elastic 6ce63b2
Bump mysql2 3.20.0 → 3.24.3 to fix GHSA-3f6p-5ww8-9rcr
erikcurrin-elastic 05c31d7
TO FIX: Run node 'scripts/yarn_deduplicate && yarn kbn bootstrap' loc…
kibanamachine de81f36
Merge branch 'elastic:main' into mysql-datasource
erikcurrin-elastic d9c8a12
Fix three PR review findings: UPDATE pattern bypass, dead SSL custom-…
erikcurrin-elastic 25fd233
Update src/platform/packages/shared/kbn-connector-specs/src/lib/gener…
erikcurrin-elastic 2e4837f
Address PR review: scope WRITE_PATTERN to MySQL only, flip executeSql…
erikcurrin-elastic f798e6d
Merge branch 'main' into mysql-datasource
erikcurrin-elastic ac3ae10
Merge remote-tracking branch 'upstream/main' into mysql-datasource
erikcurrin-elastic d884c55
Add mysql2@3.24.3 to pnpm-lock.yaml after pnpm migration merge
erikcurrin-elastic 182f1c2
Merge branch 'main' into mysql-datasource
erikcurrin-elastic File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -44,6 +44,7 @@ lightningcss | |
| tar-fs | ||
| browserslist | ||
| react-day-picker | ||
| mysql2 | ||
| jszip | ||
| @rsdoctor/rspack-plugin | ||
| @rspack/core | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,133 @@ | ||
| --- | ||
| navigation_title: "MySQL" | ||
| type: reference | ||
| description: "Use the MySQL connector to query, explore schema, and execute SQL against a MySQL database." | ||
| applies_to: | ||
| stack: preview 9.6 | ||
| serverless: preview | ||
| --- | ||
|
|
||
| # MySQL connector [mysql-action-type] | ||
|
|
||
| The MySQL connector connects directly to a MySQL database so you can search, query, and explore schema from chat conversations. Workflow authors can also run write or DDL statements through **Execute SQL**. | ||
|
|
||
| ## Requirements [mysql-requirements] | ||
|
|
||
| The MySQL connector connects directly to MySQL over the native MySQL protocol (default port 3306). Your MySQL server must be network-accessible from your Kibana instance. TLS is required by default. | ||
|
|
||
| To use the MySQL connector, you need: | ||
|
|
||
| 1. A MySQL server accessible from your Kibana instance. | ||
| 2. A MySQL user with access to the databases you want to query. | ||
| 3. The server hostname, port, database name, and credentials. | ||
|
|
||
| ## Get connection details [mysql-api-credentials] | ||
|
|
||
| To configure the connector: | ||
|
|
||
| 1. Identify the hostname or IP address of your MySQL server. | ||
| 2. Create a MySQL user with the appropriate permissions for your use case (see [Database user permissions](#mysql-security)). | ||
| 3. Note the server port (default: 3306) and the default database name. | ||
|
|
||
| ## Create connectors in {{kib}} [define-mysql-ui] | ||
|
|
||
| You can create connectors in **{{stack-manage-app}} > {{connectors-ui}}**. | ||
|
|
||
| ### Connector configuration [mysql-connector-configuration] | ||
|
|
||
| MySQL connectors have the following configuration properties: | ||
|
|
||
| Host | ||
| : The hostname or IP address of the MySQL server (for example, `mysql.example.com`, `192.168.1.1`, `localhost`). Do not include a protocol prefix. | ||
|
|
||
| Port | ||
| : The port number of the MySQL server (default: 3306). | ||
|
|
||
| Database | ||
| : The name of the default database to query. | ||
|
|
||
| Username | ||
| : The MySQL user to authenticate as. | ||
|
|
||
| Password | ||
| : The password for the MySQL user. | ||
|
|
||
| TLS | ||
| : Whether to encrypt the connection. **Required** (default) uses Kibana TLS settings. **Disabled** is only for servers that do not support TLS. | ||
|
|
||
|
|
||
| ## Test connectors [mysql-action-configuration] | ||
|
|
||
| You can test connectors as you're creating or editing the connector in {{kib}}. | ||
|
|
||
| ## MySQL Connector actions [mysql-connector-actions] | ||
|
|
||
| The MySQL connector has the following actions: | ||
|
|
||
| Query | ||
| : Run a read-only SQL query against the MySQL database. | ||
| - **sql** (required): The SQL query to run. Include a `LIMIT` clause to bound the result size. Do not include a trailing semicolon. | ||
|
|
||
| List Databases | ||
| : List all databases accessible to the authenticated user. | ||
|
|
||
| List Tables | ||
| : List all tables in a database. | ||
| - **database** (optional): The database name. Uses the configured default if omitted. | ||
|
|
||
| Describe Table | ||
| : Describe the schema of a table, including column names, types, and constraints. | ||
| - **table** (required): The table name to describe. | ||
| - **database** (optional): The database name. Uses the configured default if omitted. | ||
|
|
||
| Search Rows | ||
| : Search rows in a table by matching a search term against specified columns. | ||
| - **table** (required): The table to search. | ||
| - **searchTerm** (required): The text to search for. | ||
| - **columns** (required): Array of column names to search in. Use `describeTable` to discover available columns. | ||
| - **maxRows** (optional): Maximum number of rows to return (1-1000, default: 100). | ||
| - **database** (optional): The database name. Uses the configured default if omitted. | ||
|
|
||
| Execute SQL | ||
| : Run any SQL statement against the MySQL database. No restrictions — `INSERT`, `UPDATE`, `DELETE`, `DROP`, and DDL are all permitted. Use only when the workflow explicitly requires a write or destructive operation. Prefer **Query** for read-only access. | ||
| - **sql** (required): The SQL statement to execute. | ||
|
|
||
|
|
||
| ## Database user permissions [mysql-security] | ||
|
|
||
| The permissions you grant to the MySQL user determine what the connector can do. Configure them to match your intended use case. | ||
|
erikcurrin-elastic marked this conversation as resolved.
|
||
|
|
||
| ### Read-only chat use case (recommended) | ||
|
|
||
| For chat conversations, where the goal is to query and explore data, use a dedicated user with only `SELECT` access. This is the recommended configuration and provides the strongest protection against unintended modifications. | ||
|
|
||
| ```sql | ||
| -- Create a read-only user and grant SELECT on the target databases | ||
| CREATE USER 'kibana_reader'@'%' IDENTIFIED BY '<password>'; | ||
| GRANT SELECT ON my_database.* TO 'kibana_reader'@'%'; | ||
| FLUSH PRIVILEGES; | ||
| ``` | ||
|
|
||
| The `query` action enforces read-only access at the application level by accepting only `SELECT` and `WITH` statements and by blocking multi-statement input. Use **List Tables** and **Describe Table** for schema discovery. | ||
|
|
||
| ::::{note} | ||
| The application-level read-only check is not a security guarantee. Prompt injection and other techniques may craft inputs that bypass it. The only reliable protection is granting the database user read-only permissions. Application-level enforcement is a defense-in-depth measure, not a substitute for least-privilege credentials. | ||
| :::: | ||
|
|
||
| Using a least-privilege database user adds a second, independent layer of enforcement. Note: the `executeSql` action bypasses these restrictions and can run any statement — do not grant write privileges unless your use case requires them. | ||
|
|
||
| You can further restrict the user to connections from your Kibana host's IP address: | ||
|
|
||
| ```sql | ||
| CREATE USER 'kibana_reader'@'<kibana-host-ip>' IDENTIFIED BY '<password>'; | ||
| ``` | ||
|
|
||
| ### Broader access | ||
|
|
||
| If your use case requires write access or access across multiple databases, grant the appropriate privileges to the MySQL user. Scope permissions as narrowly as possible for your use case. | ||
|
|
||
| ```sql | ||
| -- Example: grant read/write access to a specific database | ||
| GRANT SELECT, INSERT, UPDATE, DELETE ON my_database.* TO 'kibana_user'@'%'; | ||
| FLUSH PRIVILEGES; | ||
| ``` | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.