— Raspberry Pi — 1 min read
Fluent Bitで収集したデータを時系列データベースInfluxDBに蓄積して、Grafanaで収集したデータの可視化することを目指します。
$ cat /proc/device-tree/modelRaspberry Pi 3 Model B Rev 1.2$ lsb_release -aNo LSB modules are available.Distributor ID: RaspbianDescription: Raspbian GNU/Linux 10 (buster)Release: 10Codename: busterFluentdだとメモリを食うので、Raspberry Piで動かすためによりシンプルなFluent Bitを選択。
(参考: Fluentd & Fluent Bit)
https://docs.fluentbit.io/manual/v/master/installation/linux/raspbian-raspberry-pi
を参考にインストール。
Fluent Bitは、Raspbianではtd-agent-bitパッケージとして配布されている。
リポジトリのGPGキーを取得する。
$ wget -qO - https://packages.fluentbit.io/fluentbit.key | sudo apt-key add -/etc/apt/sources.list.dにリポジトリを追加。
$ echo "deb https://packages.fluentbit.io/raspbian/buster buster main" | sudo tee /etc/apt/souces.list.d/fluentdbit.list追加したリポジトリをupdateしてから、td-agent-bitをインストール。
$ sudo apt update$ sudo apt install td-agent-bittd-agent-bitを起動。
$ sudo service td-agent-bit startInfluxDBは時系列データベースで、可視化ツールGrafanaと連携することで、様々な時系列データの見える化が可能。
リポジトリのGPGキーを取得。
$ wget -qO - https://repos.influxdata.com/influxdb.key | sudo apt-key add -/etc/apt/sources.list.dにリポジトリを追加。
$ echo "deb https://repos.influxdata.com/debian buster stable" | sudo tee /etc/apt/sources.list.d/influxdb.listリポジトリをupdateしてから、influxdbをインストール。
$ sudo apt update$ sudo apt install influxdbInfluxDBのサービスを起動。
$ sudo service influxdb start試しに、influxコマンドを入力。終了するには、quitを入力。
$ influxConnected to http://localhost:8086 version 1.8.1InfluxDB shell version: 1.8.1> helpUsage: connect <host:port> connects to another node specified by host:port auth prompts for username and password pretty toggles pretty print for the json format chunked turns on chunked responses from server chunk size <size> sets the size of the chunked responses. Set to 0 to reset to the default chunked size use <db_name> sets current database format <format> specifies the format of the server responses: json, csv, or column precision <format> specifies the format of the timestamp: rfc3339, h, m, s, ms, u or ns consistency <level> sets write consistency level: any, one, quorum, or all history displays command history settings outputs the current settings for the shell clear clears settings such as database or retention policy. run 'clear' for help exit/quit/ctrl+d quits the influx shell show databases show database names show series show series information show measurements show measurement information show tag keys show tag key information show field keys show field key information A full list of influxql commands can be found at: https://docs.influxdata.com/influxdb/latest/query_language/spec/> quit$リポジトリのGPGキーを取得。
$ wget -qO - https://packages.grafana.com/gpg.key | sudo apt-key add -/etc/apt/sources.list.dにリポジトリを追加。
$ echo "deb https://packages.grafana.com/oss/deb stable main" | sudo tee /etc/apt/sources.list.d/grafana.listリポジトリを更新し、grafanaをインストール。
$ sudo apt update$ sudo apt install grafana今回はとりあえずインストールまで。