TCollector
TCollector is part of openTSDB, used for collecting client logs and sending them to the database.
Simply modify the TCollector configuration to point to the server domain name (or IP address) and corresponding port where taosAdapter is running to store the data collected by TCollector into TDengine, fully utilizing TDengine's efficient storage and query performance and cluster processing capabilities for time-series data.
Prerequisites
To write TCollector data into TDengine, the following preparations are needed:
- TDengine cluster is deployed and running normally
- taosAdapter is installed and running normally. For details, please refer to taosAdapter user manual
- TCollector is installed. For TCollector installation, please refer to the official documentation
Configuration Steps
Configuring taosAdapter
To configure taosAdapter to receive data from TCollector:
- Enable the configuration in the taosAdapter configuration file (default location /etc/taos/taosadapter.toml)
...
[opentsdb_telnet]
enable = true
maxTCPConnections = 250
tcpKeepAlive = false
dbs = ["opentsdb_telnet", "collectd", "icinga2", "tcollector"]
ports = [6046, 6047, 6048, 6049]
user = "root"
password = "taosdata"
...
The default database name that taosAdapter writes to is tcollector
, but you can specify a different name by modifying the dbs option in the taosAdapter configuration file. Fill in the user and password with the actual values configured in TDengine. After modifying the configuration file, taosAdapter needs to be restarted.
- You can also use taosAdapter command line arguments or set environment variables to enable the taosAdapter to receive tcollector data. For more details, please refer to the taosAdapter reference manual.
Configuring TCollector
To use TCollector, download its source code. Its configuration options are in its source code. Note: There are significant differences between different versions of TCollector; this only refers to the latest code in the current master branch (git commit: 37ae920).
Modify the contents of collectors/etc/config.py
and tcollector.py
. Change the original address pointing to the OpenTSDB host to the domain name or IP address where taosAdapter is deployed, and change the port to the corresponding port supported by taosAdapter for TCollector use (default is 6049).
Example of git diff output for source code modifications:
index e7e7a1c..ec3e23c 100644
--- a/collectors/etc/config.py
+++ b/collectors/etc/config.py
@@ -59,13 +59,13 @@ def get_defaults():
'http_password': False,
'reconnectinterval': 0,
'http_username': False,
- 'port': 4242,
+ 'port': 6049,
'pidfile': '/var/run/tcollector.pid',
'http': False,
'http_api_path': "api/put",
'tags': [],
'remove_inactive_collectors': False,
- 'host': '',
+ 'host': '127.0.0.1',
'logfile': '/var/log/tcollector.log',
'cdir': default_cdir,
'ssl': False,
diff --git a/tcollector.py b/tcollector.py
index 21f9b23..4c71ba2 100755
--- a/tcollector.py
+++ b/tcollector.py
@@ -64,7 +64,7 @@ ALIVE = True
# exceptions, something is not right and tcollector will shutdown.
# Hopefully some kind of supervising daemon will then restart it.
MAX_UNCAUGHT_EXCEPTIONS = 100
-DEFAULT_PORT = 4242
+DEFAULT_PORT = 6049
MAX_REASONABLE_TIMESTAMP = 2209212000 # Good until Tue 3 Jan 14:00:00 GMT 2040
# How long to wait for datapoints before assuming
# a collector is dead and restarting it
@@ -943,13 +943,13 @@ def parse_cmdline(argv):
'http_password': False,
'reconnectinterval': 0,
'http_username': False,
- 'port': 4242,
+ 'port': 6049,
'pidfile': '/var/run/tcollector.pid',
'http': False,
'http_api_path': "api/put",
'tags': [],
'remove_inactive_collectors': False,
- 'host': '',
+ 'host': '127.0.0.1',
'logfile': '/var/log/tcollector.log',
'cdir': default_cdir,
'ssl': False,
Verification Method
Restart taosAdapter:
sudo systemctl restart taosadapter
Manually execute sudo ./tcollector.py
After waiting a few seconds, use the TDengine CLI to query whether TDengine has created the corresponding database and written data.
taos> show databases;
name |
=================================
information_schema |
performance_schema |
tcollector |
Query OK, 3 rows in database (0.001647s)
taos> use tcollector;
Database changed.
taos> show stables;
name |
=================================
proc.meminfo.hugepages_rsvd |
proc.meminfo.directmap1g |
proc.meminfo.vmallocchunk |
proc.meminfo.hugepagesize |
tcollector.reader.lines_dro... |
proc.meminfo.sunreclaim |
proc.stat.ctxt |
proc.meminfo.swaptotal |
proc.uptime.total |
tcollector.collector.lines_... |
proc.meminfo.vmallocused |
proc.meminfo.memavailable |
sys.numa.foreign_allocs |
proc.meminfo.committed_as |
proc.vmstat.pswpin |
proc.meminfo.cmafree |
proc.meminfo.mapped |
proc.vmstat.pgmajfault |
...
- TDengine by default generates subtable names based on a rule-generated unique ID value.