diff --git a/REPORT.md b/REPORT.md new file mode 100644 index 0000000..f4e82ea --- /dev/null +++ b/REPORT.md @@ -0,0 +1,326 @@ +# Шаг 1: Разработка Simulator для генерации данных + +В файле `sensor.py` создаем четвертый тип датчиков *Radiation*, предназначенный для замеров уровня радиационного фона окружающего пространства. + +```python +class Radiation(Sensor): + step = 0 + + def __init__(self, name): + super().__init__(name) + self.type = "radiation" + + def generate_new_value(self): + self.value = math.sin(self.step) + self.step = self.step + 0.1 +``` + +Далее в файле `main.py` реализовуем клиента, который подключается к mqtt брокеру и публикует сообщения. + + +```python +import paho.mqtt.client as paho +from os import environ +import time + +from entity.sensor import * + +broker = "localhost" if "SIM_HOST" not in environ.keys() else environ["SIM_HOST"] +port = 1883 if "SIM_PORT" not in environ.keys() else environ["SIM_PORT"] +name = "sensor" if "SIM_NAME" not in environ.keys() else environ["SIM_NAME"] +period = 1 if "SIM_PERIOD" not in environ.keys() else int(environ["SIM_PERIOD"]) +type_sim = "temperature" if "SIM_TYPE" not in environ.keys() else environ["SIM_TYPE"] + +sensors = {"temperature": Temperature, "pressure": Pressure, "radiation": Radiation, "current": Current} + + +def on_publish(client, userdata, result): # create function for callback + print(f"data published {userdata}") + pass + + +sensor = sensors[type_sim](name=name) +client1 = paho.Client(sensor.name) # create client object +client1.on_publish = on_publish # assign function to callback +client1.connect(broker, port) # establish connection +while True: + sensor.generate_new_value() + ret = client1.publish("sensors/" + sensor.type + "/" + sensor.name, sensor.get_data()) # publish + time.sleep(period) +``` + + +В `Dockerfile`, необходимом для того, что создать образ, указываем следуюещие инструкции: + +``` Dockerfile +FROM python:alpine3.19 +WORKDIR /app +COPY requirements.txt . +RUN pip install -r requirements.txt +COPY . . +CMD ["python", "main.py"] +``` + +Инструкция `FROM` инициализирует новый этап сборки и устанавливает базовый образ для последующих инструкций. `WORKDIR` создает рабочий каталог для последующих инструкций `Dockerfile`. Инструкция `COPY` копирует файл *requirements.txt* из источника в указанное место внутри образа. +Инструкция `RUN`задает команды, которые следует выполнить и поместить в новый образ контейнера. `RUN` описывает команду с аргументами, которую нужно выполнить когда контейнер будет запущен. + +Содержимое файла *requirements.txt* приведено ниже: +`paho_mqtt==1.6.1` + +*paho_mqtt* предоставляет клиентский класс, который позволяет приложениям подключаться к MQTT-брокеру для публикации сообщений. + +После проделанных выше опреаций можно создать образ командой: + +`docker build -t rusjkh/data-simulator . ` + +Таким образом мы создали образ, из которого можно развернуть контейнер. + +

+ +

+ +Собтвенно запустив контейнер через + +`docker run -e SIM_HOST=192.168.0.11 -e SIM_TYPE=temperature --name test -d rusjkh/data-simulator` + +Получим ошибку, т.к. брокер еще не настроен. + +

+ +

+ + +# Шаг 2: Запуск Mosquitto брокера + +Для настройки протокола MQTT необходимо создать конфигурационный файл *mosquitto.conf* со следующим содержимымы: + +```c +listener 1883 +allow_anonymous true +``` +Для более удобного запуска брокера создадим файл *docker-compose.yml* со следующим содержимым: + +```yml +version: "3" +services: + broker: + image: eclipse-mosquitto + container_name: broker + volumes: + - ./mosquitto/mosquitto.conf:/mosquitto/config/mosquitto.conf + ports: + - "1883:1883" +``` + +Теперь создав контейнер (из Шага 1), получим следующее: + +

+ +

+ +Логи контейнера пустуют, т.к. compose-файл на данный момент пуст и передать в брокера просто нечего. + +Брокер же отображает присоединившегося клиента. + +

+ +

+ +Теперь можно запустить несколько датчиков. Но перед этим необходимо прописать *docker-compose.yml*: + +```yml +version: "3" + +services: + temp_sensor: + image: rusjkh/data-simulator + environment: + - SIM_HOST=192.168.0.11 + - SIM_NAME=TEMP1 + - SIM_PERIOD=2 + - SIM_TYPE=temperature + pressure_sensor: + image: rusjkh/data-simulator + environment: + - SIM_HOST=192.168.0.11 + - SIM_NAME=PRESS1 + - SIM_PERIOD=2 + - SIM_TYPE=pressure + current_sensor: + image: rusjkh/data-simulator + environment: + - SIM_HOST=192.168.0.11 + - SIM_NAME=CURRENT1 + - SIM_PERIOD=2 + - SIM_TYPE=current + radiation_sensor: + image: rusjkh/data-simulator + environment: + - SIM_HOST=192.168.0.11 + - SIM_NAME=RAD1 + - SIM_PERIOD=2 + - SIM_TYPE=radiation + temp_sensor_2: + image: rusjkh/data-simulator + environment: + - SIM_HOST=192.168.0.11 + - SIM_NAME=TEMP2 + - SIM_PERIOD=4 + - SIM_TYPE=temperature + co_sensor_2: + image: rusjkh/data-simulator + environment: + - SIM_HOST=192.168.0.11 + - SIM_NAME=RAD2 + - SIM_PERIOD=6 + - SIM_TYPE=radiation +``` +С помощью команды `docker compose up` запустим одноврменно 6 контейнеров: + +

+ +

+ +При этом брокер отображает: +

+ +

+ +# Шаг 3: Получение данных от симулятора +Первоначально необходимо настроить Telegraf, который подписывается на MQTT, где датчики публикуют данные. Данные будут сохраняться в InfluxDB. Отображение информации с датчиков будет происходить при помощи Grafana. + +## Telegraf +Перед использованием Telegram необходимо настроить его. +Для этого откроем конфигурационный файл *telegraf.conf* и в разделе `[[inputs.mqtt_consumer]]`пропишем следующее: + +```c +servers = ["tcp://192.168.0.11:1883"] # адрес vm с mqtt-брокером +topics = [ + "sensors/#" +] +data_format = "value" +data_type = "float" +``` +Тем самым мы настраиваем Telegraf на чтение данных с машины IP адрес которой 192.168.0.11 через порт 1883. + +Также настроим разедл вывода `[[outputs.influxdb]]`: +```c +urls = ["http://influxdb:8086"] +database = "sensors" +skip_database_creation = true +username = "telegraf" +password = "telegraf" +``` +Настройка Telegraf на этом завршена. + +## InfluDB + +Для создания базы данных необходимо в конфигурационном файле *influxdb-init.iql* прописать следующее: +```sql +CREATE database sensors +CREATE USER telegraf WITH PASSWORD 'telegraf' WITH ALL PRIVILEGES +``` + +## Grafana + +Данные для отображения датчиков берутся из InfluxDB. +Для настройки в конфигурационном файле необходимо прописать следующее: +```yaml +apiVersion: 1 + +datasources: + - name: InfluxDB_v1 + type: influxdb + access: proxy + database: sensors + user: telegraf + url: http://influxdb:8086 + jsonData: + httpMode: GET + secureJsonData: + password: telegraf +``` + +Для запуска всех трех контенйеров воспользуемся docker-compose. + +В *docker-compose.yml* пропишем следующее: + +```yml +version: "3" +services: + influxdb: + image: influxdb:1.8 + container_name: influxdb + volumes: + - ./influxdb/scripts:/docker-entrypoint-initdb.d + - influx_data:/var/lib/influxdb + networks: + - server-net + telegraf: + image: telegraf + container_name: telegraf + volumes: + - ./telegraf:/etc/telegraf:ro + restart: unless-stopped + networks: + - server-net + grafana: + image: grafana/grafana + container_name: grafana + volumes: + - grafana_data:/var/lib/grafana + - ./grafana/:/etc/grafana/ + + environment: + - GF_SECURITY_ADMIN_USER=admin + - GF_SECURITY_ADMIN_PASSWORD=admin + - GF_USERS_ALLOW_SIGN_UP=false + restart: unless-stopped + ports: + - 3000:3000 + networks: + - server-net + +volumes: + influx_data: {} + grafana_data: {} + +networks: + server-net: {} +``` + +После чего можно выполнить команду `docker compose up` + +

+ +

+ +# Настройка дашборда +После запуска всех необходимых контейнеров, в раузере переходим по `192.168.0.11:3000` + +

+ +

+ +Для проверки соединения перейдем в Menu -> Connections -> Data sources. Находим в истончиках InfluxDB и проверяем подключение: +

+ +

+ +После переходим через Меню в раздел Dashboards, где создаем собственный дашбоард. + +Для отображения информации с датчиков необходимо создать запрос (query). + +

+ +

+ +После создания необходимо количества графиков, отображающих инфомрацию с Simluator, экспортируем дашборд как JSON-файл. + +Для этого находим функцию `Share` -> ``Export` -> `Save to file`. Сохраненный файл помещаем в папку `vms\server\infra\grafana\provisioning\dashboards\mqtt.json` + +# Пример выполненной работы + +

+ +

\ No newline at end of file diff --git a/pics/1.PNG b/pics/1.PNG new file mode 100644 index 0000000..7582929 Binary files /dev/null and b/pics/1.PNG differ diff --git a/pics/10.PNG b/pics/10.PNG new file mode 100644 index 0000000..cc6b011 Binary files /dev/null and b/pics/10.PNG differ diff --git a/pics/11.PNG b/pics/11.PNG new file mode 100644 index 0000000..5861453 Binary files /dev/null and b/pics/11.PNG differ diff --git a/pics/2.PNG b/pics/2.PNG new file mode 100644 index 0000000..9f89293 Binary files /dev/null and b/pics/2.PNG differ diff --git a/pics/3.PNG b/pics/3.PNG new file mode 100644 index 0000000..8150aeb Binary files /dev/null and b/pics/3.PNG differ diff --git a/pics/4.PNG b/pics/4.PNG new file mode 100644 index 0000000..04d1495 Binary files /dev/null and b/pics/4.PNG differ diff --git a/pics/5.PNG b/pics/5.PNG new file mode 100644 index 0000000..97c2e9a Binary files /dev/null and b/pics/5.PNG differ diff --git a/pics/6.PNG b/pics/6.PNG new file mode 100644 index 0000000..001b00d Binary files /dev/null and b/pics/6.PNG differ diff --git a/pics/7.PNG b/pics/7.PNG new file mode 100644 index 0000000..21ce029 Binary files /dev/null and b/pics/7.PNG differ diff --git a/pics/8.PNG b/pics/8.PNG new file mode 100644 index 0000000..741d1b6 Binary files /dev/null and b/pics/8.PNG differ diff --git a/pics/9.PNG b/pics/9.PNG new file mode 100644 index 0000000..0ba5317 Binary files /dev/null and b/pics/9.PNG differ diff --git a/vms/client/simulator/docker-compose.yml b/vms/client/simulator/docker-compose.yml index b9e08bb..ee3f26c 100644 --- a/vms/client/simulator/docker-compose.yml +++ b/vms/client/simulator/docker-compose.yml @@ -2,23 +2,44 @@ version: "3" services: temp_sensor: - image: antonaleks/data-simulator + image: rusjkh/data-simulator environment: - - SIM_HOST=192.168.1.1 - - SIM_NAME=TIRCAHL24 - - SIM_PERIOD=5 + - SIM_HOST=192.168.0.11 + - SIM_NAME=TEMP1 + - SIM_PERIOD=2 - SIM_TYPE=temperature pressure_sensor: - image: antonaleks/data-simulator + image: rusjkh/data-simulator environment: - - SIM_HOST=192.168.1.1 - - SIM_NAME=PIRCAHL11 - - SIM_PERIOD=10 + - SIM_HOST=192.168.0.11 + - SIM_NAME=PRESS1 + - SIM_PERIOD=2 - SIM_TYPE=pressure current_sensor: - image: antonaleks/data-simulator + image: rusjkh/data-simulator environment: - - SIM_HOST=192.168.1.1 - - SIM_NAME=A0_CURRENT - - SIM_PERIOD=1 + - SIM_HOST=192.168.0.11 + - SIM_NAME=CURRENT1 + - SIM_PERIOD=2 - SIM_TYPE=current + radiation_sensor: + image: rusjkh/data-simulator + environment: + - SIM_HOST=192.168.0.11 + - SIM_NAME=RAD1 + - SIM_PERIOD=2 + - SIM_TYPE=radiation + temp_sensor_2: + image: rusjkh/data-simulator + environment: + - SIM_HOST=192.168.0.11 + - SIM_NAME=TEMP2 + - SIM_PERIOD=4 + - SIM_TYPE=temperature + co_sensor_2: + image: rusjkh/data-simulator + environment: + - SIM_HOST=192.168.0.11 + - SIM_NAME=RAD2 + - SIM_PERIOD=6 + - SIM_TYPE=radiation \ No newline at end of file diff --git a/vms/client/simulator/entity/sensor.py b/vms/client/simulator/entity/sensor.py index 922fea5..9b7a5e1 100644 --- a/vms/client/simulator/entity/sensor.py +++ b/vms/client/simulator/entity/sensor.py @@ -1,4 +1,5 @@ import random +import math class Sensor: @@ -41,6 +42,20 @@ def generate_new_value(self): self.value = random.random() + self.step - 56.48 + 25 * 7 +# создадим новый класс + +class Radiation(Sensor): + step = 0 + + def __init__(self, name): + super().__init__(name) + self.type = "radiation" + + def generate_new_value(self): + self.value = math.sin(self.step) + self.step = self.step + 0.1 + + class Current(Sensor): step = 0 diff --git a/vms/client/simulator/main.py b/vms/client/simulator/main.py index 4d17730..f30bc4a 100644 --- a/vms/client/simulator/main.py +++ b/vms/client/simulator/main.py @@ -9,7 +9,7 @@ name = "sensor" if "SIM_NAME" not in environ.keys() else environ["SIM_NAME"] period = 1 if "SIM_PERIOD" not in environ.keys() else int(environ["SIM_PERIOD"]) type_sim = "temperature" if "SIM_TYPE" not in environ.keys() else environ["SIM_TYPE"] -sensors = {"temperature": Temperature, "pressure": Pressure, "current": Current} +sensors = {"temperature": Temperature, "pressure": Pressure, "radiation": Radiation, "current": Current} def on_publish(client, userdata, result): # create function for callback diff --git a/vms/client/simulator/mosquitto.conf b/vms/client/simulator/mosquitto.conf new file mode 100644 index 0000000..c8348ac --- /dev/null +++ b/vms/client/simulator/mosquitto.conf @@ -0,0 +1,2 @@ +listener 1883 +allow_anonymous true diff --git a/vms/gateway/docker-compose.yml b/vms/gateway/docker-compose.yml new file mode 100644 index 0000000..869e743 --- /dev/null +++ b/vms/gateway/docker-compose.yml @@ -0,0 +1,9 @@ +version: "3" +services: + broker: + image: eclipse-mosquitto + container_name: broker + volumes: + - ./mosquitto/mosquitto.conf:/mosquitto/config/mosquitto.conf + ports: + - "1883:1883" \ No newline at end of file diff --git a/vms/server/infra/docker-compose.yml b/vms/server/infra/docker-compose.yml index 94e705e..ff420db 100644 --- a/vms/server/infra/docker-compose.yml +++ b/vms/server/infra/docker-compose.yml @@ -33,7 +33,6 @@ services: networks: - server-net - volumes: influx_data: {} grafana_data: {} diff --git a/vms/server/infra/grafana/provisioning/dashboards/mqtt.json b/vms/server/infra/grafana/provisioning/dashboards/mqtt.json index ec65ac0..ca8d243 100644 --- a/vms/server/infra/grafana/provisioning/dashboards/mqtt.json +++ b/vms/server/infra/grafana/provisioning/dashboards/mqtt.json @@ -3,7 +3,10 @@ "list": [ { "builtIn": 1, - "datasource": "-- Grafana --", + "datasource": { + "type": "datasource", + "uid": "grafana" + }, "enable": true, "hide": true, "iconColor": "rgba(0, 211, 255, 1)", @@ -21,9 +24,160 @@ "editable": true, "fiscalYearStartMonth": 0, "graphTooltip": 0, + "id": 1, "links": [], "liveNow": false, "panels": [ + { + "datasource": { + "type": "influxdb", + "uid": "P4B5EB7AC8565B06F" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 0 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 24, + "x": 0, + "y": 0 + }, + "id": 4, + "options": { + "minVizHeight": 75, + "minVizWidth": 75, + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "showThresholdLabels": false, + "showThresholdMarkers": true, + "sizing": "auto" + }, + "pluginVersion": "10.4.3", + "targets": [ + { + "alias": "Rads (inside)", + "datasource": { + "type": "influxdb", + "uid": "P4B5EB7AC8565B06F" + }, + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "measurement": "mqtt_consumer", + "orderByTime": "ASC", + "policy": "default", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [ + { + "key": "topic::tag", + "operator": "=", + "value": "sensors/radiation/RAD2" + } + ] + }, + { + "alias": "Rads (outside)", + "datasource": { + "type": "influxdb", + "uid": "P4B5EB7AC8565B06F" + }, + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "hide": false, + "measurement": "mqtt_consumer", + "orderByTime": "ASC", + "policy": "default", + "refId": "B", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [ + { + "key": "topic::tag", + "operator": "=", + "value": "sensors/radiation/RAD1" + } + ] + } + ], + "title": "Radiation levels", + "type": "gauge" + }, { "datasource": { "type": "influxdb", @@ -35,6 +189,9 @@ "mode": "palette-classic" }, "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, @@ -46,7 +203,8 @@ "tooltip": false, "viz": false }, - "lineInterpolation": "linear", + "insertNulls": false, + "lineInterpolation": "smooth", "lineWidth": 1, "pointSize": 5, "scaleDistribution": { @@ -80,30 +238,354 @@ "overrides": [] }, "gridPos": { - "h": 9, + "h": 7, "w": 12, "x": 0, - "y": 0 + "y": 8 }, "id": 2, "options": { "legend": { "calcs": [], "displayMode": "list", - "placement": "bottom" + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "alias": "Internal", + "datasource": { + "type": "influxdb", + "uid": "P4B5EB7AC8565B06F" + }, + "groupBy": [ + { + "params": [ + "10s" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "measurement": "mqtt_consumer", + "orderByTime": "ASC", + "policy": "default", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [ + { + "key": "topic::tag", + "operator": "=", + "value": "sensors/temp/TEMP1" + } + ] + }, + { + "alias": "External", + "datasource": { + "type": "influxdb", + "uid": "P4B5EB7AC8565B06F" + }, + "groupBy": [ + { + "params": [ + "10s" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "hide": false, + "measurement": "mqtt_consumer", + "orderByTime": "ASC", + "policy": "default", + "refId": "B", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [ + { + "key": "topic::tag", + "operator": "=", + "value": "sensors/temp/TEMP2" + } + ] + } + ], + "title": "Temperatures", + "type": "timeseries" + }, + { + "datasource": { + "type": "influxdb", + "uid": "P4B5EB7AC8565B06F" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 0 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 7, + "w": 12, + "x": 12, + "y": 8 + }, + "id": 1, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "alias": "Target variable", + "datasource": { + "type": "influxdb", + "uid": "P4B5EB7AC8565B06F" + }, + "groupBy": [ + { + "params": [ + "10s" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "measurement": "mqtt_consumer", + "orderByTime": "ASC", + "policy": "default", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [ + { + "key": "topic::tag", + "operator": "=", + "value": "sensors/current/CURRENT1" + } + ] + } + ], + "title": "Current (over time)", + "type": "timeseries" + }, + { + "datasource": { + "type": "influxdb", + "uid": "P4B5EB7AC8565B06F" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "dark-red", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 24, + "x": 0, + "y": 15 + }, + "id": 5, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true }, "tooltip": { "mode": "single", "sort": "none" } }, + "pluginVersion": "10.4.3", "targets": [ { + "alias": "Pressure", "datasource": { "type": "influxdb", "uid": "P4B5EB7AC8565B06F" }, - "groupBy": [], + "groupBy": [ + { + "params": [ + "10s" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], "measurement": "mqtt_consumer", "orderByTime": "ASC", "policy": "default", @@ -116,35 +598,40 @@ "value" ], "type": "field" + }, + { + "params": [], + "type": "mean" } ] ], "tags": [ { - "key": "topic", + "key": "topic::tag", "operator": "=", - "value": "sensors/current/A0_CURRENT" + "value": "sensors/pressure/PRESS1" } ] } ], - "title": "Panel Title", + "title": "Pressure", "type": "timeseries" } ], - "schemaVersion": 35, - "style": "dark", + "refresh": "", + "schemaVersion": 39, "tags": [], "templating": { "list": [] }, "time": { - "from": "now-5m", + "from": "now-15m", "to": "now" }, "timepicker": {}, "timezone": "", "title": "New dashboard", - "version": 0, + "uid": "fdmpyb3g9tz40b", + "version": 1, "weekStart": "" } \ No newline at end of file diff --git a/vms/server/infra/telegraf/telegraf.conf b/vms/server/infra/telegraf/telegraf.conf index ddd8b05..966f245 100644 --- a/vms/server/infra/telegraf/telegraf.conf +++ b/vms/server/infra/telegraf/telegraf.conf @@ -120,7 +120,7 @@ # Configuration for sending metrics to InfluxDB [[outputs.influxdb]] -urls = ["http://influxdb:8086"] # адрес докера с influxdb (указать alias при docker-compose, ip адрес для docker run) +urls = ["http://influxdb:8086"] database = "sensors" skip_database_creation = true username = "telegraf" @@ -8558,7 +8558,7 @@ password = "telegraf" # "telegraf/+/mem", # "sensors/#", # ] -servers = ["tcp://192.168.26.1:1883"] # адрес vm с mqtt-брокером +servers = ["tcp://192.168.0.11:1883"] # адрес vm с mqtt-брокером topics = [ "sensors/#" ]