-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Implement TiDB database monitoring #20826
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
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -8,7 +8,7 @@ The MySQL integration tracks the performance of your MySQL instances. It collect | |||||
|
||||||
Enable [Database Monitoring][32] (DBM) for enhanced insights into query performance and database health. In addition to the standard integration, Datadog DBM provides query-level metrics, live and historical query snapshots, wait event analysis, database load, and query explain plans. | ||||||
|
||||||
MySQL version 5.6, 5.7, 8.0, and MariaDB versions 10.5, 10.6, 10.11 and 11.1 are supported. | ||||||
MySQL version 5.6, 5.7, 8.0, MariaDB versions 10.5, 10.6, 10.11 and 11.1, and TiDB version 8.1+ are supported. | ||||||
|
||||||
## Setup | ||||||
|
||||||
|
@@ -68,6 +68,24 @@ mysql> GRANT PROCESS ON *.* TO 'datadog'@'%'; | |||||
Query OK, 0 rows affected (0.00 sec) | ||||||
``` | ||||||
|
||||||
##### TiDB-specific setup | ||||||
|
||||||
For TiDB databases, the user setup is similar but with some differences: | ||||||
|
||||||
- TiDB does not have `performance_schema`, so skip the performance_schema grant | ||||||
- TiDB does not support the `REPLICATION CLIENT` privilege, but this is not needed as TiDB uses different replication mechanisms | ||||||
- The `innodb_index_stats` table is not available in TiDB | ||||||
|
||||||
For TiDB, create the user with these commands: | ||||||
|
||||||
```shell | ||||||
mysql> CREATE USER 'datadog'@'%' IDENTIFIED BY '<UNIQUEPASSWORD>'; | ||||||
Query OK, 0 rows affected (0.00 sec) | ||||||
|
||||||
mysql> GRANT PROCESS ON *.* TO 'datadog'@'%'; | ||||||
Query OK, 0 rows affected (0.00 sec) | ||||||
``` | ||||||
|
||||||
Verify the replication client. Replace `<UNIQUEPASSWORD>` with the password you created above: | ||||||
|
||||||
```shell | ||||||
|
@@ -141,6 +159,27 @@ For a full list of available configuration options, see the [sample `mysql.d/con | |||||
|
||||||
To collect `extra_performance_metrics`, your MySQL server must have `performance_schema` enabled - otherwise set `extra_performance_metrics` to `false`. For more information on `performance_schema`, see [MySQL Performance Schema Quick Start][9]. | ||||||
|
||||||
##### TiDB Configuration | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed in |
||||||
|
||||||
For TiDB instances, some configuration options should be adjusted: | ||||||
|
||||||
```yaml | ||||||
init_config: | ||||||
|
||||||
instances: | ||||||
- host: 127.0.0.1 | ||||||
username: datadog | ||||||
password: "<YOUR_CHOSEN_PASSWORD>" | ||||||
port: 4000 # Default TiDB port | ||||||
options: | ||||||
replication: false # TiDB uses different replication mechanisms | ||||||
galera_cluster: false | ||||||
extra_status_metrics: true | ||||||
extra_innodb_metrics: false # TiDB doesn't have InnoDB | ||||||
disable_innodb_metrics: true # Disable InnoDB metrics for TiDB | ||||||
extra_performance_metrics: false # TiDB doesn't have performance_schema | ||||||
``` | ||||||
|
||||||
**Note**: The `datadog` user should be set up in the MySQL integration configuration as `host: 127.0.0.1` instead of `localhost`. Alternatively, you may also use `sock`. | ||||||
|
||||||
[Restart the Agent][10] to start sending MySQL metrics to Datadog. | ||||||
|
@@ -251,6 +290,14 @@ LABEL "com.datadoghq.ad.init_configs"='[{}]' | |||||
LABEL "com.datadoghq.ad.instances"='[{"server": "%%host%%", "username": "datadog","password": "<UNIQUEPASSWORD>"}]' | ||||||
``` | ||||||
|
||||||
For TiDB instances, add the appropriate configuration options: | ||||||
|
||||||
```yaml | ||||||
LABEL "com.datadoghq.ad.check_names"='["mysql"]' | ||||||
LABEL "com.datadoghq.ad.init_configs"='[{}]' | ||||||
LABEL "com.datadoghq.ad.instances"='[{"server": "%%host%%", "username": "datadog", "password": "<UNIQUEPASSWORD>", "port": 4000, "options": {"disable_innodb_metrics": true, "extra_performance_metrics": false}}]' | ||||||
``` | ||||||
|
||||||
See [Autodiscovery template variables][12] for details on using `<UNIQUEPASSWORD>` as an environment variable instead of a label. | ||||||
|
||||||
#### Log collection | ||||||
|
@@ -551,6 +598,24 @@ The check does not collect all metrics by default. Set the following boolean con | |||||
| ---------------------- | ----------- | | ||||||
| mysql.info.schema.size | GAUGE | | ||||||
|
||||||
#### TiDB limitations | ||||||
|
||||||
When using this integration with TiDB, be aware of the following limitations: | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Which integration is this referencing? If it is the InnoDB integration, would this change work:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this might not be satisfy your request. but fixed for some. In fact I don't mention for the specific integration... |
||||||
|
||||||
- **InnoDB metrics**: TiDB doesn't use the InnoDB storage engine, so all InnoDB-related metrics are unavailable | ||||||
- **Performance Schema**: TiDB doesn't have MySQL's `performance_schema`, so performance metrics requiring it are unavailable | ||||||
- **Replication metrics**: TiDB uses a different replication mechanism (Raft consensus), so traditional MySQL replication metrics don't apply | ||||||
- **MyISAM metrics**: TiDB doesn't support MyISAM, so key cache metrics are unavailable | ||||||
- **Binary log metrics**: TiDB has a different binlog implementation, so traditional MySQL binlog metrics may not be accurate | ||||||
- **Statement metrics**: TiDB uses `information_schema.cluster_statements_summary` instead of `performance_schema.events_statements_summary_by_digest` | ||||||
- **Activity monitoring**: TiDB uses `information_schema.cluster_processlist` instead of `performance_schema.events_statements_current` | ||||||
|
||||||
For Database Monitoring features: | ||||||
- Query samples and explain plans are collected from `cluster_statements_summary` with some approximations | ||||||
- Wait events are not available as TiDB doesn't track them in the same way as MySQL | ||||||
- Some query metrics are approximated (e.g., rows examined is estimated from keys processed) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thanks, applied in |
||||||
- TiDB explain plans are retrieved from the `PLAN` column in `information_schema.cluster_statements_summary` table, which contains pre-collected execution plans in text format with embedded execution statistics | ||||||
|
||||||
### Events | ||||||
|
||||||
The MySQL check does not include any events. | ||||||
|
@@ -571,6 +636,15 @@ See [service_checks.json][22] for a list of service checks provided by this inte | |||||
- [Database user lacks privileges][29] | ||||||
- [How to collect metrics with a SQL Stored Procedure?][30] | ||||||
|
||||||
### TiDB-specific troubleshooting | ||||||
|
||||||
**Missing metrics**: If you see warnings about missing InnoDB or performance_schema metrics when monitoring TiDB: | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||
- This is expected behavior. Set `disable_innodb_metrics: true` and `extra_performance_metrics: false` in your configuration. | ||||||
|
||||||
**Connection issues**: TiDB typically runs on port 4000 instead of MySQL's default 3306. Make sure to specify the correct port in your configuration. | ||||||
|
||||||
**High metric collection time**: The `CLUSTER_*` tables in TiDB aggregate data from all TiDB nodes, which can be slow in large clusters. Consider increasing the collection interval if needed. | ||||||
|
||||||
## Further Reading | ||||||
|
||||||
Additional helpful documentation, links, and articles: | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Implement TiDB database monitoring |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you clarify what the set up is similar to? Is it to other Databases?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll add
similart to other databases like MySQL, MariaDB, and so on.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clarified in
48bec2a