An open API service indexing awesome lists of open source software.

https://github.com/plusmancn/node-telegraf-statsd

Generate telegraf statsd's inputs in NodeJs
https://github.com/plusmancn/node-telegraf-statsd

Last synced: 2 months ago
JSON representation

Generate telegraf statsd's inputs in NodeJs

Awesome Lists containing this project

README

        

# node-telegraf-statsd
> Abbr: tstatsd means t(telegraf)statsd
> Generate telegraf statsd's inputs in NodeJs

* According to https://github.com/influxdata/telegraf/tree/master/plugins/inputs/statsd
* Etsy Statsd: https://github.com/etsy/statsd/blob/master/docs/metric_types.md
* Inspired by https://github.com/dscape/lynx
* Node UDP/DataGram Doc: https://nodejs.org/dist/latest-v4.x/docs/api/dgram.html

## Usage
**Install**
```shell
npm install tstatsd --save
```
**Example**
```javascript
const Tstatsd = require('tstatsd');
let tstatsd = new Tstatsd('10.211.55.18');
tstatsd.timing('tstatsd.test.timing', 10);
```

## Api
**Kind**: global class

* [Tstatsd](#Tstatsd)
* [new Tstatsd(host, port)](#new_Tstatsd_new)
* [.gauge(key, value, operator)](#Tstatsd+gauge)
* [.counter(key, step, sample)](#Tstatsd+counter)
* [.set(key, value)](#Tstatsd+set)
* [.timing(key, value, unit, sample)](#Tstatsd+timing)
* [.send(str)](#Tstatsd+send)

### new Tstatsd(host, port)

| Param | Type | Description |
| --- | --- | --- |
| host | String | 主机IP |
| port | Integer | 服务端口 |

### tstatsd.gauge(key, value, operator)
gauge

**Kind**: instance method of [Tstatsd](#Tstatsd)

| Param | Type | Description |
| --- | --- | --- |
| key | String | |
| value | Integer | |
| operator | Enum | 操作符,可选 ['+', '-'] |

### tstatsd.counter(key, step, sample)
counter

**Kind**: instance method of [Tstatsd](#Tstatsd)

| Param | Type | Description |
| --- | --- | --- |
| key | String | |
| step | Integer | 步进 |
| sample | Float | 采样率,最后增量为 step/sample |

### tstatsd.set(key, value)
set

**Kind**: instance method of [Tstatsd](#Tstatsd)

| Param | Type | Description |
| --- | --- | --- |
| key | String | |
| value | String | 遇到不同值才会加一 |

### tstatsd.timing(key, value, unit, sample)
**Kind**: instance method of [Tstatsd](#Tstatsd)

| Param | Type | Description |
| --- | --- | --- |
| key | String | |
| value | Integer | 消耗时长 |
| unit | Enum | 计时单位, ms/h |
| sample | Float | 采样率,最后 counter=1/sample |

### tstatsd.send(str)
原生发送方法

**Kind**: instance method of [Tstatsd](#Tstatsd)

| Param | Type | Description |
| --- | --- | --- |
| str | String | statsd 定义的字符串 |