14-taosKeeper.md 7.2 KB
Newer Older
D
danielclow 已提交
1 2 3
---
sidebar_label: taosKeeper
title: taosKeeper
D
danielclow 已提交
4
description: This document describes how to use taosKeeper, a tool for exporting TDengine monitoring metrics.
D
danielclow 已提交
5 6
---

7 8 9
import Tabs from "@theme/Tabs";
import TabItem from "@theme/TabItem";

D
danielclow 已提交
10 11 12 13 14 15
## Introduction

taosKeeper is a tool for TDengine that exports monitoring metrics. With taosKeeper, you can easily monitor the operational status of your TDengine deployment. taosKeeper uses the TDengine REST API. It is not necessary to install TDengine Client to use taosKeeper.

## Installation

16
There are two ways to install taosKeeper:
D
danielclow 已提交
17 18
Methods of installing taosKeeper:

19
- Installing the official TDengine installer will automatically install taosKeeper. Please refer to [TDengine installation](/operation/pkg-install) for details.
D
danielclow 已提交
20

21
- You can compile taosKeeper separately and install it. Please refer to the [taosKeeper](https://github.com/taosdata/taoskeeper) repository for details.
22
## Configuration and Launch
D
danielclow 已提交
23

24
### Configuration
D
danielclow 已提交
25

H
huolibo 已提交
26
taosKeeper needs to be executed on the terminal of the operating system, it supports three configuration methods: [Command-line arguments](#command-line-arguments-in-detail), [environment variable](#environment-variable-in-detail) and [configuration file](#configuration-file-parameters-in-detail). The precedence of those is Command-line, environment variable and configuration file.
D
danielclow 已提交
27

28 29 30 31 32 33 34 35
**Make sure that the TDengine cluster is running correctly before running taosKeeper.** Ensure that the monitoring service in TDengine has been started. At least the values of `monitor` and `monitorFqdn` need to be set in `taos.cfg`.

```shell
monitor 1
monitorFqdn localhost # taoskeeper's FQDN
```

For more information, see [TDengine Monitoring Configuration](../config/#monitoring).
D
danielclow 已提交
36

37
### Quick Launch
D
danielclow 已提交
38

39 40
<Tabs>
<TabItem label="Linux" value="linux">
D
danielclow 已提交
41

42 43 44 45
After the installation is complete, run the following command to start the taoskeeper service:

```bash
systemctl start taoskeeper
D
danielclow 已提交
46
```
H
huolibo 已提交
47

48 49 50 51 52 53 54
Run the following command to confirm that taoskeeper is running normally:

```bash
systemctl status taoskeeper
```

Output similar to the following indicates that taoskeeper is running normally:
H
huolibo 已提交
55 56

```
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
Active: active (running)
```

Output similar to the following indicates that taoskeeper has not started successfully:

```
Active: inactive (dead)
```

The following `systemctl` commands can help you manage taoskeeper service:

- Start taoskeeper Server: `systemctl start taoskeeper`

- Stop taoskeeper Server: `systemctl stop taoskeeper`

- Restart taoskeeper Server: `systemctl restart taoskeeper`

- Check taoskeeper Server status: `systemctl status taoskeeper`

:::info

- The `systemctl` command requires _root_ privileges. If you are not logged in as the _root_ user, use the `sudo` command.
- The `systemctl stop taoskeeper` command will instantly stop taoskeeper Server.
- If your system does not include `systemd`, you can run `/usr/local/taos/bin/taoskeeper` to start taoskeeper manually.

:::
</TabItem>

<TabItem label="macOS" value="macos">

After the installation is complete, run `launchctl start com.tdengine.taoskeeper` to start taoskeeper Server.

The following `launchctl` commands can help you manage taoskeeper service:

- Start taoskeeper Server: `sudo launchctl start com.tdengine.taoskeeper`

- Stop taoskeeper Server: `sudo launchctl stop com.tdengine.taoskeeper`

- Check taoskeeper Server status: `sudo launchctl list | grep taoskeeper`

:::info
- Please use `sudo` to run `launchctl` to manage _com.tdengine.taoskeeper_ with administrator privileges.
- The administrator privilege is required for service management to enhance security.
- Troubleshooting:
- The first column returned by the command `launchctl list | grep taoskeeper` is the PID of the program. If it's `-`, that means the taoskeeper service is not running.
- If the service is abnormal, please check the `launchd.log` file from the system log.

:::
H
huolibo 已提交
105

106 107
</TabItem>
</Tabs>
H
huolibo 已提交
108

109
#### Launch With Configuration File
D
danielclow 已提交
110

111
You can quickly launch taosKeeper with the following commands. If you do not specify a configuration file, `/etc/taos/keeper.toml` is used by default. If this file does not specify configurations, the default values are used.
D
danielclow 已提交
112 113

```shell
H
huolibo 已提交
114
$ taoskeeper -c <keeper config file>
D
danielclow 已提交
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182
```

**Sample configuration files**
```toml
# enable debug in gin framework
debug = false

# listen to server port, default 6043
port = 6043

# set log level to panic, error, info, debug, or trace
loglevel = "info"

# set pool size
gopoolsize = 50000

# query rotation period for TDengine monitoring data
RotationInterval = "15s"

[tdengine]
host = "127.0.0.1"
port = 6041
username = "root"
password = "taosdata"

# set taosAdapter to monitor
[taosAdapter]
address = ["127.0.0.1:6041","192.168.1.95:6041"]

[metrics]
# monitoring metric prefix
prefix = "taos"

# cluster data identifier
cluster = "production"

# database to store monitoring data
database = "log"

# standard tables to monitor
tables = ["normal_table"]
```

### Obtain Monitoring Metrics

taosKeeper records monitoring metrics generated by TDengine in a specified database and provides an interface through which you can export the data.

#### View Monitoring Results

```shell
$ taos
# the log database is used in this example
> use log;
> select * from cluster_info limit 1;
```

Example result set:

```shell
           ts            |            first_ep            | first_ep_dnode_id |   version    |    master_uptime     | monitor_interval |  dbs_total  |  tbs_total  | stbs_total  | dnodes_total | dnodes_alive | mnodes_total | mnodes_alive | vgroups_total | vgroups_alive | vnodes_total | vnodes_alive | connections_total |  protocol   |           cluster_id           |
===============================================================================================================================================================================================================================================================================================================================================================================
 2022-08-16 17:37:01.629 | hlb:6030                       |                 1 | 3.0.0.0      |              0.27250 |               15 |           2 |          27 |          38 |            1 |            1 |            1 |            1 |             4 |             4 |            4 |            4 |                14 |           1 | 5981392874047724755            |
Query OK, 1 rows in database (0.036162s)
```

#### Export Monitoring Metrics

```shell
H
huolibo 已提交
183
$ curl http://127.0.0.1:6043/metrics
D
danielclow 已提交
184 185 186 187 188
```

Sample result set (excerpt):

```shell
189
# HELP taos_cluster_info_connections_total
D
danielclow 已提交
190 191
# TYPE taos_cluster_info_connections_total counter
taos_cluster_info_connections_total{cluster_id="5981392874047724755"} 16
192
# HELP taos_cluster_info_dbs_total
D
danielclow 已提交
193 194
# TYPE taos_cluster_info_dbs_total counter
taos_cluster_info_dbs_total{cluster_id="5981392874047724755"} 2
195
# HELP taos_cluster_info_dnodes_alive
D
danielclow 已提交
196 197
# TYPE taos_cluster_info_dnodes_alive counter
taos_cluster_info_dnodes_alive{cluster_id="5981392874047724755"} 1
198
# HELP taos_cluster_info_dnodes_total
D
danielclow 已提交
199 200
# TYPE taos_cluster_info_dnodes_total counter
taos_cluster_info_dnodes_total{cluster_id="5981392874047724755"} 1
201
# HELP taos_cluster_info_first_ep
D
danielclow 已提交
202 203
# TYPE taos_cluster_info_first_ep gauge
taos_cluster_info_first_ep{cluster_id="5981392874047724755",value="hlb:6030"} 1
204
```