docs/en/14-reference/01-components/12-tdinsight.md
import Tabs from '@theme/Tabs' import TabItem from '@theme/TabItem'
TDinsight is a monitoring solution for TDengine using [Grafana].
TDengine writes information such as server CPU, memory, disk space, bandwidth, request count, disk read/write speed, and slow queries into a specified database periodically through taosKeeper. By using Grafana and the TDengine data source plugin, TDinsight visualizes cluster status, node information, insert and query requests, and resource usage, providing developers with the convenience to monitor the operational status of the TDengine cluster in real-time. This document will guide users on how to install the TDengine data source plugin and deploy the TDinsight visualization dashboard.
First, check the following services:
TDengine is installed and running normally. This dashboard requires TDengine 3.0.0.0 or above, and monitoring reporting configuration enabled. For specific configurations, please refer to: TDengine Monitoring Configuration.
taosAdapter is installed and running normally. For details, please refer to: taosAdapter Reference Manual
taosKeeper is installed and running normally. For details, please refer to: taosKeeper Reference Manual
Grafana service is installed and running normally. We recommend using the latest version of Grafana, TDInsight supports Grafana 8.0 and above. :::info
In the following description, we use Grafana v11.0.0 as an example. Other versions may differ in functionality, please refer to Grafana Official Website.
:::
Then record the following information:
http://localhost:6041.For steps on installing the Grafana TDengine data source plugin and configuring the data source, please refer to: Integration with Grafana
Recommended Method: After configuring the data source, click "Dashboards" next to "Settings" — this will display the dashboard built into the data source. Then select "Import" next to "TDengine for 3.x" to import it.
Import via Dashboard ID: On the left side of the Grafana main interface, click the "Dashboards" Tab, then select "Import" under the "New" option in the top right corner. Enter the Dashboard ID 18180 for the "TDengine for 3.x" dashboard to complete the import.
Import via JSON Configuration:
After successful import, you can access this dashboard. In the "Log from" option in the top left corner, select the database set in taosKeeper for recording monitoring metrics to view the monitoring results.
The TDinsight dashboard aims to provide information on the usage and status of TDengine-related resources, such as dnodes, mnodes, vnodes, and databases. It mainly includes Cluster Status, DNodes Overview, MNode Overview, Requests, Databases, DNode Resource Usage, and taosAdapter Monitoring Information. Below, we will explain each in detail.
This section includes current information and status of the cluster.
Metric details (from top to bottom, left to right):
firstEp setting in the current TDengine cluster.This section includes basic information about the cluster's dnodes.
Metric details:
show dnodes.This section includes basic information about the cluster's mnode.
Metric details:
show mnodes.DNodes Number, changes in the number of MNodes.This section includes statistical metrics for SQL execution in the cluster.
Metric details:
This section includes statistical metrics for tables in the cluster.
Metric details:
This section includes a display of resource usage for all data nodes in the cluster, with each data node shown as a Row.
Metric details (from top to bottom, left to right):
This section includes detailed statistics for taosAdapter rest and websocket requests.
Metric details:
There are also line charts for the above categories.
After summarizing user experience, 14 commonly used alert rules are sorted out. These alert rules can monitor key indicators of the TDengine cluster and report alerts, such as abnormal and exceeded indicators.
Starting from TDengine-Server 3.3.4.3 (TDengine-datasource 3.6.3), TDengine Datasource supports automatic import of preconfigured alert rules. You can import 14 alert rules to Grafana (version 11 or later) with one click.
In the TDengine-datasource setting interface, turn on the "Load TDengine Alert" switch, click the "Save & test" button, the plugin will automatically load the mentioned 14 alert rules. The rules will be placed in the Grafana alerts directory. If not required, turn off the "Load TDengine Alert" switch, and click the button next to "Clear TDengine Alert" to clear all the alert rules imported into this data source.
After importing, click on "Alert rules" on the left side of the Grafana interface to view all current alert rules. By configuring contact points, users can receive alert notifications.
The specific configuration of the 14 alert rules is as follows:
| alert rule | Rule threshold | Behavior when no data | Data scanning interval | Duration | SQL |
|---|---|---|---|---|---|
| CPU load of dnode node | average > 80% | Trigger alert | 5 minutes | 5 minutes | select now(), dnode_ep, last(cpu_system) as cpu_use from log.taosd_dnodes_info where _ts >= (now- 5m) and _ts < now partition by dnode_ep |
| Memory of dnode node | average > 60% | Trigger alert | 5 minutes | 5 minutes | select now(), dnode_ep, last(mem_engine) / last(mem_total) * 100 as taosd from log.taosd_dnodes_info where _ts >= (now- 5m) and _ts <now partition by dnode_ep |
| Disk capacity occupancy of dnode nodes | > 80% | Trigger alert | 5 minutes | 5 minutes | select now(), dnode_ep, data_dir_level, data_dir_name, last(used) / last(total) * 100 as used from log.taosd_dnodes_data_dirs where _ts >= (now - 5m) and _ts < now partition by dnode_ep, data_dir_level, data_dir_name |
| Authorization expires | < 60 days | Trigger alert | 1 day | 0 0 seconds | select now(), cluster_id, last(grants_expire_time) / 86400 as expire_time from log.taosd_cluster_info where _ts >= (now - 24h) and _ts < now partition by cluster_id having first(_ts) > 0 |
| The used measurement points has reached the authorized number | >= 90% | Trigger alert | 1 day | 0 seconds | select now(), cluster_id, CASE WHEN max(grants_timeseries_total) > 0.0 THEN max(grants_timeseries_used) /max(grants_timeseries_total) * 100.0 ELSE 0.0 END AS result from log.taosd_cluster_info where _ts >= (now - 30s) and _ts < now partition by cluster_id having timetruncate(first(_ts), 1m) > 0 |
| Number of concurrent query requests | > 100 | Do not trigger alert | 1 minute | 0 seconds | select now() as ts, count(*) as slow_count from performance_schema.perf_queries |
| Maximum time for slow query execution (no time window) | > 300 seconds | Do not trigger alert | 1 minute | 0 seconds | select now() as ts, count(*) as slow_count from performance_schema.perf_queries where exec_usec>300000000 |
| dnode offline | total != alive | Trigger alert | 30 seconds | 0 seconds | select now(), cluster_id, last(dnodes_total) - last(dnodes_alive) as dnode_offline from log.taosd_cluster_info where _ts >= (now -30s) and _ts < now partition by cluster_id having first(_ts) > 0 |
| vnode offline | total != alive | Trigger alert | 30 seconds | 0 seconds | select now(), cluster_id, last(vnodes_total) - last(vnodes_alive) as vnode_offline from log.taosd_cluster_info where _ts >= (now - 30s) and _ts < now partition by cluster_id having first(_ts) > 0 |
| Number of data deletion requests | > 0 | Do not trigger alert | 30 seconds | 0 seconds | select now(), sum(count) asdelete_countfrom log.taos_sql_req where sql_type = 'delete' and _ts >= (now -30s) and _ts < now |
| Adapter RESTful request fail | > 5 | Do not trigger alert | 30 seconds | 0 seconds | select now(), sum(fail) asFailedfrom log.adapter_requests where req_type=0 and ts >= (now -30s) and ts < now |
| Adapter WebSocket request fail | > 5 | Do not trigger alert | 30 seconds | 0 seconds | select now(), sum(fail) asFailedfrom log.adapter_requests where req_type=1 and ts >= (now -30s) and ts < now |
| Dnode data reporting is missing | < 3 | Trigger alert | 180 seconds | 0 seconds | select now(), cluster_id, count(*) as dnode_report from log.taosd_cluster_info where _ts >= (now -180s) and _ts < now partition by cluster_id having timetruncate(first(_ts), 1h) > 0 |
| Restart dnode | max(update_time) > last(update_time) | Trigger alert | 90 seconds | 0 seconds | select now(), dnode_ep, max(uptime) - last(uptime) as dnode_report from log.taosd_dnodes_info where _ts >= (now - 90s) and _ts < now partition by dnode_ep |
TDengine users can modify and improve these alert rules according to their own business needs.
The following three methods can be used for upgrading:
TDinsight.sh script.For different installation methods, when uninstalling:
TDinsight.sh script, you can use the command line TDinsight.sh -R to clean up related resources.tdengine-datasource plugin from the plugin installation directory.Below is a detailed explanation of the usage of TDinsight.sh:
Usage:
./TDinsight.sh
./TDinsight.sh -h|--help
./TDinsight.sh -n <ds-name> -a <api-url> -u <user> -p <password>
Install and configure TDinsight dashboard in Grafana on Ubuntu 18.04/20.04 system.
-h, -help, --help Display help
-V, -verbose, --verbose Run script in verbose mode. Will print out each step of execution.
-v, --plugin-version <version> TDengine datasource plugin version, [default: latest]
-P, --grafana-provisioning-dir <dir> Grafana provisioning directory, [default: /etc/grafana/provisioning/]
-G, --grafana-plugins-dir <dir> Grafana plugins directory, [default: /var/lib/grafana/plugins]
-O, --grafana-org-id <number> Grafana organization id. [default: 1]
-n, --tdengine-ds-name <string> TDengine datasource name, no space. [default: TDengine]
-a, --tdengine-api <url> TDengine REST API endpoint. [default: http://127.0.0.1:6041]
-u, --tdengine-user <string> TDengine user name. [default: root]
-p, --tdengine-password <string> TDengine password. [default: taosdata]
-i, --tdinsight-uid <string> Replace with a non-space ASCII code as the dashboard id. [default: tdinsight]
-t, --tdinsight-title <string> Dashboard title. [default: TDinsight]
-e, --tdinsight-editable If the provisioning dashboard could be editable. [default: false]
Most command line options can also be achieved through environment variables.
| Short Option | Long Option | Environment Variable | Description |
|---|---|---|---|
| -v | --plugin-version | TDENGINE_PLUGIN_VERSION | TDengine datasource plugin version, default is latest. |
| -P | --grafana-provisioning-dir | GF_PROVISIONING_DIR | Grafana provisioning directory, default is /etc/grafana/provisioning/ |
| -G | --grafana-plugins-dir | GF_PLUGINS_DIR | Grafana plugins directory, default is /var/lib/grafana/plugins. |
| -O | --grafana-org-id | GF_ORG_ID | Grafana organization ID, default is 1. |
| -n | --tdengine-ds-name | TDENGINE_DS_NAME | TDengine datasource name, default is TDengine. |
| -a | --tdengine-api | TDENGINE_API | TDengine REST API endpoint. Default is http://127.0.0.1:6041. |
| -u | --tdengine-user | TDENGINE_USER | TDengine user name. [default: root] |
| -p | --tdengine-password | TDENGINE_PASSWORD | TDengine password. [default: taosdata] |
| -i | --tdinsight-uid | TDINSIGHT_DASHBOARD_UID | TDinsight dashboard uid. [default: tdinsight] |
| -t | --tdinsight-title | TDINSIGHT_DASHBOARD_TITLE | TDinsight dashboard title. [default: TDinsight] |
| -e | --tdinsight-editable | TDINSIGHT_DASHBOARD_EDITABLE | If the provisioning dashboard could be editable. [default: false] |
:::note
The new version of the plugin uses the Grafana unified alerting feature, the -E option is no longer supported.
:::
Assuming you start the TDengine database on the host tdengine with HTTP API port 6041, user root1, and password pass5ord. Execute the script:
./TDinsight.sh -a http://tdengine:6041 -u root1 -p pass5ord
If you want to monitor multiple TDengine clusters, you need to set up multiple TDinsight dashboards. Setting up a non-default TDinsight requires some changes: the -n -i -t options need to be changed to non-default names, and if using the built-in SMS alert feature, -N and -L should also be changed.
sudo ./TDengine.sh -n TDengine-Env1 -a http://another:6041 -u root -p taosdata -i tdinsight-env1 -t 'TDinsight Env1'
Please note that configuring the data source, notification channel, and dashboard in the frontend is not changeable. You should update the configuration again through this script or manually change the configuration files in the /etc/grafana/provisioning directory (this is the default directory for Grafana, change as needed using the -P option).
Especially, when using Grafana Cloud or other organizations, -O can be used to set the organization ID. -G can specify the Grafana plugin installation directory. -e parameter sets the dashboard to be editable.