Grafana: различия между версиями
Строка 30: | Строка 30: | ||
</gallery> | </gallery> | ||
=== Установка и настройка Telegraf на контроллер Wiren Board | === Установка и настройка Telegraf === | ||
Telegraf — это сервис, который устанавливается на контроллер Wiren Board и отправляет данные в базу данных Grafana Cloud. | |||
# Установите | Установка Telegraf: | ||
#: <syntaxhighlight lang="bash"> | # Установите дополнительные пакеты: | ||
#:<syntaxhighlight lang="bash"> | |||
apt update && apt install apt-transport-https | apt update && apt install apt-transport-https | ||
wget -qO- https://repos.influxdata.com/influxdb.key | | </syntaxhighlight> | ||
source /etc/os-release | # Добавьте ключ репозитория telegraf: | ||
#:<syntaxhighlight lang="bash"> | |||
wget -qO- https://repos.influxdata.com/influxdb.key | apt-key add - | |||
test $VERSION_ID = "9" && echo "deb https://repos.influxdata.com/debian stretch stable" | | </syntaxhighlight> | ||
# Добавьте в список apt-репозиториев ссылку на репозиторий telegraf: | |||
#*<syntaxhighlight lang="bash"> | |||
source /etc/os-release | |||
</syntaxhighlight> | |||
#* Здесь <code>$VERSION_ID = "9"</code> и <code>stretch</code> — версия ОС: | |||
#*:<syntaxhighlight lang="bash"> | |||
test $VERSION_ID = "9" && echo "deb https://repos.influxdata.com/debian stretch stable" | tee /etc/apt/sources.list.d/influxdb.list | |||
</syntaxhighlight> | |||
# Обновите список пакетов и установите telegraf: | |||
#:<syntaxhighlight lang="bash"> | |||
apt update && apt install telegraf | apt update && apt install telegraf | ||
</syntaxhighlight> | </syntaxhighlight> | ||
# | # Запустите установленный сервис: | ||
#:<syntaxhighlight lang="bash"> | |||
service telegraf start | |||
</syntaxhighlight> | |||
Отредактируйте файл <code>/etc/telegraf/telegraf.conf</code>: | |||
* Секция '''inputs.mqtt_consumer''', поля ''servers'', ''topics'', ''data_format'' и ''data_type'': | |||
*: <syntaxhighlight lang="bash"> | |||
[[inputs.mqtt_consumer]] | [[inputs.mqtt_consumer]] | ||
## Broker URLs for the MQTT server or cluster. To connect to multiple | ## Broker URLs for the MQTT server or cluster. To connect to multiple | ||
Строка 113: | Строка 129: | ||
data_type = "float" | data_type = "float" | ||
</syntaxhighlight> | </syntaxhighlight> | ||
* Секция '''outputs.http''', поля ''url'', ''username'', ''password'', ''data_format'' и ''[outputs.http.headers]''. Ссылку и логин с паролем мы сохраняли в разделе про регистрацию. | |||
*:<syntaxhighlight lang="bash"> | |||
[[outputs.http]] | [[outputs.http]] | ||
## URL is the address to send metrics to | ## URL is the address to send metrics to | ||
Строка 131: | Строка 148: | ||
X-Prometheus-Remote-Write-Version = "0.1.0" | X-Prometheus-Remote-Write-Version = "0.1.0" | ||
</syntaxhighlight> | </syntaxhighlight> | ||
## | Проверьте, что Telegraf работает без ошибок: | ||
# Остановите сервис: | |||
telegraf - | #:<syntaxhighlight lang="bash"> | ||
service telegraf stop | |||
</syntaxhighlight> | |||
# Запустите сервис в режиме отладки и убедитесь, что данные отправляются: | |||
#:<syntaxhighlight lang="console" highlight="15-19"> | |||
# telegraf -debug | |||
2021-11-29T16:47:13Z I! Starting Telegraf 1.20.4 | |||
2021-11-29T16:47:13Z I! Using config file: /etc/telegraf/telegraf.conf | |||
2021-11-29T16:47:13Z I! Loaded inputs: cpu disk diskio kernel mem mqtt_consumer processes swap system | |||
2021-11-29T16:47:13Z I! Loaded aggregators: | |||
2021-11-29T16:47:13Z I! Loaded processors: | |||
2021-11-29T16:47:13Z I! Loaded outputs: http | |||
2021-11-29T16:47:13Z I! Tags enabled: host=wirenboard-AWQBNTYP | |||
2021-11-29T16:47:13Z I! [agent] Config: Interval:10s, Quiet:false, Hostname:"wirenboard-AWQBNTYP", Flush Interval:10s | |||
2021-11-29T16:47:13Z D! [agent] Initializing plugins | |||
2021-11-29T16:47:13Z D! [agent] Connecting outputs | |||
2021-11-29T16:47:13Z D! [agent] Attempting connection to [outputs.http] | |||
2021-11-29T16:47:13Z D! [agent] Successfully connected to outputs.http | |||
2021-11-29T16:47:13Z D! [agent] Starting service inputs | |||
2021-11-29T16:47:13Z I! [inputs.mqtt_consumer] Connected [tcp://127.0.0.1:1883] | |||
2021-11-29T16:47:24Z D! [outputs.http] Wrote batch of 31 metrics in 696.002545ms | |||
2021-11-29T16:47:24Z D! [outputs.http] Buffer fullness: 1 / 10000 metrics | |||
2021-11-29T16:47:33Z D! [outputs.http] Wrote batch of 34 metrics in 129.098071ms | |||
2021-11-29T16:47:33Z D! [outputs.http] Buffer fullness: 0 / 10000 metrics | |||
</syntaxhighlight> | </syntaxhighlight> | ||
# Если ошибок нет, то остановите команду клавишами <kbd>Ctrl</kbd>+<kbd>C</kbd>. | |||
# Запустите сервис в автоматическом режиме: | |||
#:<syntaxhighlight lang="bash"> | |||
service telegraf start | |||
</syntaxhighlight> | </syntaxhighlight> | ||