-
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?
Implement TiDB database monitoring #20826
Conversation
|
|
04ae784
to
27e20c0
Compare
Codecov Report❌ Patch coverage is Additional details and impacted files
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
ec97801
to
1a9eab2
Compare
please tell me if it's better not to devide files for tidb. |
sorry, I want to add some function so I changed state to draft once. |
6fe482f
to
cdb5120
Compare
a119005
to
8a29ca0
Compare
This comment was marked as resolved.
This comment was marked as resolved.
dcfe488
to
a8c9bbd
Compare
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.
Hi there, thanks for this PR. I have added some suggestions here. Let us know if you have any questions.
mysql/README.md
Outdated
@@ -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: |
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.
For TiDB databases, the user setup is similar but with some differences: | |
For TiDB databases, the user setup is similar but with some differences: |
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
mysql/README.md
Outdated
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
##### TiDB Configuration | |
##### TiDB configuration |
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.
fixed in
48bec2a
mysql/README.md
Outdated
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
When using this integration with TiDB, be aware of the following limitations: | |
When using this integration with TiDB, be aware of the following limitations: |
Which integration is this referencing? If it is the InnoDB integration, would this change work:
When using he InnoDB integration with TiDB, be aware of the following limitations:
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.
this might not be satisfy your request. but fixed for some.
In fact I don't mention for the specific integration...
thanks for the review
mysql/README.md
Outdated
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 comment
The reason will be displayed to describe this comment to others. Learn more.
- Some query metrics are approximated (e.g., rows examined is estimated from keys processed) | |
- Some query metrics are approximated (for example, rows examined is estimated from keys processed) |
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.
thanks, applied in
48bec2a
mysql/README.md
Outdated
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
**Missing metrics**: If you see warnings about missing InnoDB or performance_schema metrics when monitoring TiDB: | |
**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 comment
The reason will be displayed to describe this comment to others. Learn more.
please tell me if it's better not to devide files for tidb. |
self._log.debug("Failed to parse TiDB plan to JSON: %s", e) | ||
return json.dumps({"raw_plan": plan_text, "parse_error": str(e)}) | ||
|
||
def _convert_tidb_plan_to_mysql_format(self, tidb_plan_json): |
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 will fix some to this function. It turned out this does not cover some cases.
bd3ecca
to
5ea69a1
Compare
- Map all TiDB operator types to MySQL-compatible access types - Add support for additional TiDB operators: - Batch_Point_Get → const (multiple point lookups) - TableRowIDScan → ref (rowid lookup) - TableScan/IndexScan → ALL/index (generic scans) - IndexLookUp → ref (non-unique index lookup) - Improve mapping accuracy for better MySQL compatibility 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
e72fbe8
to
dadcf97
Compare
@iadjivon I'm ready again. Would you please review the doc again? |
What does this PR do?
extend part of MySQL database monitoring capability to TiDB.
#20811
note: wait event etc. does not work for TiDB
Motivation
database monitoring is very useful tool and we will use it with other metrics with MCP server.
If we have query baseline information in datadog, we are very happy.
Review checklist (to be filled by reviewers)
qa/skip-qa
label if the PR doesn't need to be tested during QA.backport/<branch-name>
label to the PR and it will automatically open a backport PR once this one is mergedDiscussion and Some Review Point
Overview
metric collection adjustments
* InnoDB metrics - TiDB uses TiKV storage engine, no information_schema.innodb_* tables
* MySQL replication metrics - TiDB uses Raft consensus, no SHOW SLAVE STATUS
* MyISAM key cache metrics - TiDB doesn't support MyISAM, no Key_* status variables
* Binary log metrics - TiDB has different binlog implementation
compatibility with existing MySQL
access_type
should be MySQL compatible one (e.g. const, ref, range, index... not Point_Get, Batch_Point_Get) for current datadog server implementation, so we are converting access_type for now.TiDB also have EXPLAIN format=tidb_json, but we need to original query for it and cost higher, so I use statement_summary plan information. note that which is not realtime, and detected plan for the period. (default 30min)
https://docs.pingcap.com/tidb/stable/sql-statement-explain/