Skip to content

Commit ff11399

Browse files
authored
Update influxdb for fluent-package (#553)
Signed-off-by: Kentaro Hayashi <hayashi@clear-code.com>
1 parent 5395e91 commit ff11399

File tree

1 file changed

+54
-67
lines changed

1 file changed

+54
-67
lines changed

how-to-guides/syslog-influxdb.md

Lines changed: 54 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,101 +1,74 @@
11
# Send Syslog Data to InfluxDB
22

3-
This article shows how to collect `syslog` data into [InfluxDB](http://github.com/influxdb/influxdb) using Fluentd.
3+
This article shows how to collect `syslog` data into [InfluxDB](https://github.com/influxdata/influxdb) using Fluentd.
44

55
![Syslog + Fluentd + InfluxDB](../.gitbook/assets/syslog-fluentd-influxdb.png)
66

77
## Prerequisites
88

9-
* A basic understanding of Fluentd
9+
* A basic understanding of [Fluentd](https://www.fluentd.org/)
1010
* A running instance of `rsyslogd`
11+
* [InfluxDB](https://www.influxdata.com/)
12+
* Your InfluxDB access token
13+
* [Chronograf](https://www.influxdata.com/time-series-platform/chronograf/)
1114

12-
**In this guide, we assume we are running `td-agent` \(Fluentd package for Linux and macOS\) on Ubuntu Xenial.**
15+
You can install Fluentd via major packaging systems.
1316

14-
## Step 1: Install InfluxDB
15-
16-
InfluxDB supports Ubuntu, RedHat and macOS \(via `brew`\).
17+
* [Installation](../installation/)
1718

18-
For more details, see [here](http://influxdb.com/download/).
19+
## Step 1: Install InfluxDB
1920

20-
Since we are assumed to be on Ubuntu, the following two lines install InfluxDB:
21+
You can install InfluxDB via major packaging systems.
2122

22-
```text
23-
$ wget https://dl.influxdata.com/influxdb/releases/influxdb_1.7.3_amd64.deb
24-
$ sudo dpkg -i influxdb_1.7.3_amd64.deb
25-
```
23+
* [Install InfluxDB OSS v2](https://docs.influxdata.com/influxdb/v2/install/)
2624

2725
Once it is installed, you can run it with:
2826

2927
```text
3028
$ sudo systemctl start influxdb
3129
```
3230

33-
Then, you can verify that InfluxDB is running:
34-
35-
```text
36-
$ curl "http://localhost:8086/query?q=show+databases"
37-
```
38-
39-
If InfluxDB is running normally, you will see an object that contains the `_internal` database:
40-
41-
```javascript
42-
{"results":[{"statement_id":0,"series":[{"name":"databases","columns":["name"],"values":[["_internal"]]}]}]}
43-
```
44-
45-
Also, the following two lines install Chronograf:
46-
47-
```text
48-
$ wget https://dl.influxdata.com/chronograf/releases/chronograf_1.7.7_amd64.deb
49-
$ sudo dpkg -i chronograf_1.7.7_amd64.deb
50-
```
51-
52-
Once it is installed, you can run it with:
31+
Then, run the initial setup process and create/configure the following:
5332

54-
```text
55-
$ sudo systemctl start chronograf
56-
```
33+
* Create `influxdb` user
34+
* Create proper operation token
35+
* Set `fluent` organization
36+
* Create `test` bucket
37+
* Crete access API token
5738

58-
Then, go to localhost:8888 \(or wherever you are hosting Chronograf\) to access Chronograf's web console which is the successor to InfluxDB's web console.
39+
See [Set up InfluxDB](https://docs.influxdata.com/influxdb/v2/get-started/setup/).
5940

60-
Create a database called `test`. This is where we will be storing `syslog` data:
41+
Then, you can verify that InfluxDB is running:
6142

6243
```text
63-
$ curl -i -XPOST http://localhost:8086/query --data-urlencode "q=CREATE DATABASE test"
44+
$ curl --header "Authorization: Token (INFLUXDB_ACCESS_TOKEN_HERE)" "http://localhost:8086/query?q=show+databases"
6445
```
6546

66-
If you prefer command line or cannot access port 8083 from your local machine, running the following command creates a database called `test`:
47+
If InfluxDB is running normally, you will see an object that contains the `_monitoring`, `_tasks` and `test` database:
6748

68-
```text
69-
$ curl -i -X POST 'http://localhost:8086/write?db=test' --data-binary 'task,host=server01,region=us-west value=1 1434055562000000000'
49+
```javascript
50+
{"results":[{"statement_id":0,"series":[{"name":"databases","columns":["name"],"values":[["_monitoring"],["_tasks"],["test"]]}]}]}
7051
```
7152

7253
We are done for now.
7354

7455
## Step 2: Install Fluentd and the InfluxDB plugin
7556

76-
On your aggregator server, set up Fluentd.
77-
78-
For more details, see [here](https://www.fluentd.org/download).
57+
You can install Fluentd via major packaging systems.
7958

80-
```text
81-
$ curl -L https://toolbelt.treasuredata.com/sh/install-ubuntu-xenial-td-agent3.sh | sh
82-
```
59+
* [Installation](../installation/)
8360

8461
Next, install the InfluxDB output plugin:
8562

86-
```text
87-
/usr/sbin/td-agent-gem install fluent-plugin-influxdb
88-
```
89-
90-
For the vanilla Fluentd, run:
63+
If [`out_influxdb`](https://github.com/influxdata/influxdb-plugin-fluent) (fluent-plugin-influxdb-v2) is not installed yet, please install it manually.
9164

92-
```text
93-
fluent-gem install fluent-plugin-influxdb
94-
```
65+
See [Plugin Management](..//installation/post-installation-guide#plugin-management) section how to install fluent-plugin-influxdb-v2 on your environment.
9566

96-
You might need `sudo` to install the plugin.
67+
{% hint style='warning' %}
68+
Do not install fluent-plugin-influxdb, it does not support for InfluxDB v2.
69+
{% endhint %}
9770

98-
Finally, configure `/etc/td-agent/td-agent.conf` as follows:
71+
Finally, configure `/etc/fluent/fluentd.conf` as follows:
9972

10073
```text
10174
<source>
@@ -106,24 +79,28 @@ Finally, configure `/etc/td-agent/td-agent.conf` as follows:
10679
10780
<match system.*.*>
10881
@type influxdb
109-
dbname test
110-
flush_interval 10s # for testing
111-
host YOUR_INFLUXDB_HOST # default: localhost
112-
port YOUR_INFLUXDB_PORT # default: 8086
82+
url http://localhost:8086
83+
org fluent
84+
bucket test
85+
token "ACCESS_TOKEN_HERE"
86+
use_ssl false
87+
<buffer>
88+
flush_interval 10s # for testing
89+
<buffer>
11390
</match>
11491
```
11592

116-
Restart `td-agent` with `sudo service td-agent restart`.
93+
Restart `fluentd` with `sudo systemctl restart fluentd`.
11794

11895
## Step 3: Configure `rsyslogd`
11996

120-
If remote `rsyslogd` instances are already collecting data into the aggregator `rsyslogd`, the settings for `rsyslog` should remain unchanged. However, if this is a brand new setup, start forward `syslog` output by adding the following line to `/etc/rsyslogd.conf`:
97+
If remote `rsyslogd` instances are already collecting data into the aggregator `rsyslogd`, the settings for `rsyslog` should remain unchanged. However, if this is a brand new setup, create `/etc/rsyslogd.d/90-fluentd.conf` and append the following line:
12198

12299
```text
123-
*.* @182.39.20.2:42185
100+
*.* @localhost:42185
124101
```
125102

126-
You should replace `182.39.20.2` with the IP address of your aggregator server. Also, there is nothing special about port `42185` \(do make sure this port is open though\).
103+
You should replace `localhost` with the IP address of your aggregator server. Also, there is nothing special about port `42185` \(do make sure this port is open though\).
127104

128105
Now, restart `rsyslogd`:
129106

@@ -135,13 +112,23 @@ $ sudo systemctl restart rsyslog
135112

136113
Your `syslog` data should be flowing into InfluxDB every 10 seconds \(this is configured by `flush_interval`\).
137114

138-
Clicking on `Explore` brings up the query interface that **lets you write SQL queries against your log data**.
115+
For visualizing incoming data, you can use the InfluxDB UI by default and as an option, you can use `Chronograf` with InfluxDB v2.
116+
117+
You can install Chronograf via major packaging systems.
118+
119+
* [Install Chronograf](https://docs.influxdata.com/chronograf/v1/introduction/installation/)
120+
121+
{% hint style='info' %}
122+
Setup Chronograf "InfluxDB v2 Auth" to connect with InfludDB v2. See [Use Chronograf with InfluxDB OSS](https://docs.influxdata.com/influxdb/v2/tools/chronograf/).
123+
{% endhint %}
124+
125+
Then, go to http://localhost:8888 and clicking on `Explore` brings up the query interface that **lets you write SQL queries against your log data**.
139126

140127
And then click `Visualization` and select the line chart:
141128

142129
![Chronograf: Explore Data](../.gitbook/assets/chronograf-explore-data.png)
143130

144-
Now, to count the number of lines of `syslog` messages per facility/priority:
131+
Now, switch to `Queries` to count the number of lines of `syslog` messages per facility/priority:
145132

146133
```sql
147134
SELECT COUNT(ident) FROM test.autogen./^system\./ GROUP BY time(1s)

0 commit comments

Comments
 (0)