06-statsd.md 2.3 KB
Newer Older
1
---
2
title: StatsD Writing
D
danielclow 已提交
3 4
sidebar_label: StatsD
description: This document describes how to integrate TDengine with StatsD.
5 6 7 8 9 10
---

import StatsD from "../14-reference/_statsd.mdx"

StatsD is a simple daemon for aggregating application metrics, which has evolved rapidly in recent years into a unified protocol for collecting application performance metrics.

11
You can write StatsD data to TDengine by simply modifying the configuration file of StatsD with the domain name (or IP address) of the server running taosAdapter and the corresponding port. It can take full advantage of TDengine's efficient storage query performance and clustering capabilities for time-series data.
12 13 14 15

## Prerequisites

To write StatsD data to TDengine requires the following preparations.
16 17
1. The TDengine cluster is deployed and functioning properly
2. taosAdapter is installed and running properly. Please refer to the taosAdapter manual for details.
18 19 20 21 22 23 24 25 26 27 28 29
- StatsD has been installed. To install StatsD, please refer to [official documentation](https://github.com/statsd/statsd)

## Configuration steps
<StatsD />

## Verification method

Start StatsD:

```
$ node stats.js config.js &
[1] 8546
30
$ 20 Apr 09:54:41 - [8546] reading config file: config.js
31 32 33 34 35 36 37 38 39 40 41 42
20 Apr 09:54:41 - server is up INFO
```

Using the utility software `nc` to write data for test:

```
$ echo "foo:1|c" | nc -u -w0 127.0.0.1 8125
```

Use the TDengine CLI to verify that StatsD data is written to TDengine and can read out correctly.

```
43
taos> show databases;
44 45 46 47 48 49
              name              |
=================================
 information_schema             |
 performance_schema             |
 statsd                         |
Query OK, 3 row(s) in set (0.003142s)
50 51 52 53 54

taos> use statsd;
Database changed.

taos> show stables;
55 56 57
              name              |
=================================
 foo                            |
58 59 60 61 62 63 64 65 66 67
Query OK, 1 row(s) in set (0.002161s)

taos> select * from foo;
              ts               |         value         |         metric_type          |
=======================================================================================
 2022-04-20 09:54:51.219614235 |                     1 | counter                      |
Query OK, 1 row(s) in set (0.004179s)

taos>
```
68 69 70 71 72

:::note

- TDengine will automatically create unique IDs for sub-table names by the rule.
:::