@5to3/influx-firehose-forwarder 中文文档教程
influx-firehose-forwarder
一个简单的转发器,充当 InfluxDB 订阅者,将每个写入转发到 AWS Firehose 溪流。 如果您想及时备份对 InfluxDB 的写入,此转发器很有用。 它充当订阅者,在每次写入时由 InfluxDB 调用。 由于 InfluxDB 重试 发送失败,此代码不包含任何排队或重试逻辑。
在 5to3,我们在我们实验室的 Raspberry Pi 上运行它。 它从多个传感器收集数据 并将其存储在 InfluxDB 中。 为了避免最坏情况下的数据丢失,我们直接 使用 S3 后端将每个测量值发送到 Firehose 流。
Installation
最简单的方法是通过 NPM 全局安装这个包:
$ npm -i -g influx-firehose-forwarder
Running
$ FH_DELIVERY_STREAM=test influx-firehose-forwarder
How to keep it running
如果你在带有 systemd 的操作系统上运行转发器,你可以轻松地将它作为一个单元添加 使其保持运行并在出现错误时自动重启。 只需使用以下 示例单元作为您自己配置的起点。
[Unit]
Description=InfluxDB Firehose forwarder
[Service]
ExecStart=/usr/local/bin/node /opt/firehose/app.js
Restart=always
RestartSec=10
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=influx-firehose-forwarder
User=someuser
Group=somegroup
Environment=NODE_ENV=production
Environment=FH_HOST=localhost
Environment=FH_PORT=3000
Environment=FH_DELIVERY_STREAM=test
[Install]
WantedBy=multi-user.target
Adding the forwarder as a subscriber to InfluxDB
使用 Influx shell 将转发器添加为新订阅者:
$ influx
> CREATE SUBSCRIPTION "sub0" ON "your_db"."autogen" DESTINATIONS ALL 'http://127.0.0.1:3000'
> SHOW SUBSCRIPTIONS
name: your_db
retention_policy name mode destinations
---------------- ---- ---- ------------
autogen sub0 ALL [http://127.0.0.1:3000]
influx-firehose-forwarder
A simple forwarder that acts as an InfluxDB subscriber, forwarding each write to an AWS Firehose stream. This forwarder is useful if you want to do just in time backups of writes to an InfluxDB. It acts as a subscriber that is called by InfluxDB upon every single write. Since InfluxDB retries failed sends, this code doesn't include any queing or retry logic.
At 5to3 we're running this on a Raspberry Pi in our lab. It collects data from multiple sensors and stores it in InfluxDB. To avoid data loss in the worst-case-scenario, we're directly shipping off each measurement to a Firehose stream with S3 backend.
Installation
The easiest way is to install this package globally through NPM:
$ npm -i -g influx-firehose-forwarder
Running
$ FH_DELIVERY_STREAM=test influx-firehose-forwarder
How to keep it running
If you're running the forwarder on an OS with systemd, you can easily add it as a unit to keep it running and automatically restarting in case of an error. Simply use the following example unit as a starting point for your own configuration.
[Unit]
Description=InfluxDB Firehose forwarder
[Service]
ExecStart=/usr/local/bin/node /opt/firehose/app.js
Restart=always
RestartSec=10
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=influx-firehose-forwarder
User=someuser
Group=somegroup
Environment=NODE_ENV=production
Environment=FH_HOST=localhost
Environment=FH_PORT=3000
Environment=FH_DELIVERY_STREAM=test
[Install]
WantedBy=multi-user.target
Adding the forwarder as a subscriber to InfluxDB
Use the Influx shell to add the forwarder as a new subscriber:
$ influx
> CREATE SUBSCRIPTION "sub0" ON "your_db"."autogen" DESTINATIONS ALL 'http://127.0.0.1:3000'
> SHOW SUBSCRIPTIONS
name: your_db
retention_policy name mode destinations
---------------- ---- ---- ------------
autogen sub0 ALL [http://127.0.0.1:3000]