mirror of
https://github.com/tcivie/meshtastic-metrics-exporter.git
synced 2025-03-05 20:52:02 -08:00
Added PAX counter reported metrics to prometheus
This commit is contained in:
parent
ae6f8b4160
commit
60002b20e9
14
.env
14
.env
|
@ -8,13 +8,13 @@ PROMETHEUS_COLLECTOR_PORT=9464
|
|||
PROMETHEUS_JOB=meshtastic
|
||||
|
||||
# MQTT connection details
|
||||
MQTT_HOST=mqtt.meshtastic.org
|
||||
MQTT_PORT=1883
|
||||
MQTT_USERNAME=meshdev
|
||||
MQTT_PASSWORD=large4cats
|
||||
MQTT_KEEPALIVE=60
|
||||
MQTT_TOPIC='msh/EU_868/#,msh/US/#'
|
||||
MQTT_IS_TLS=false
|
||||
#MQTT_HOST=mqtt.meshtastic.org
|
||||
#MQTT_PORT=1883
|
||||
#MQTT_USERNAME=meshdev
|
||||
#MQTT_PASSWORD=large4cats
|
||||
#MQTT_KEEPALIVE=60
|
||||
#MQTT_TOPIC='msh/EU_868/#,msh/US/#'
|
||||
#MQTT_IS_TLS=false
|
||||
|
||||
# MQTT protocol version (default: MQTTv5) the public MQTT server supports MQTTv311
|
||||
# Options: MQTTv311, MQTTv31, MQTTv5
|
||||
|
|
|
@ -9,5 +9,6 @@
|
|||
</component>
|
||||
<component name="PackageRequirementsSettings">
|
||||
<option name="versionSpecifier" value="Greater or equal (>=x.y.z)" />
|
||||
<option name="keepMatchingSpecifier" value="false" />
|
||||
</component>
|
||||
</module>
|
|
@ -192,6 +192,9 @@ Label Notation:
|
|||
| mesh_packet_ids | Unique packet IDs | Counter | 🏷️ (source), 🏷️ (destination), packet_id |
|
||||
| mesh_packet_channel | Packet channel | Counter | 🏷️ (source), 🏷️ (destination), channel |
|
||||
| mesh_packet_rx_rssi | Packet receive RSSI | Gauge | 🏷️ (source), 🏷️ (destination) |
|
||||
| pax_wifi | Number of Wifi devices (PAX) | Gauge | 🏷 |
|
||||
| pax_ble | Number of Bluetooth devices (PAX) | Gauge | 🏷 |
|
||||
| pax_uptime | PAX device uptime | Gauge | 🏷 |
|
||||
|
||||
## Configuration
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
from datetime import datetime
|
||||
|
||||
from prometheus_client import CollectorRegistry, Counter, Gauge
|
||||
|
||||
from exporter.client_details import ClientDetails
|
||||
|
@ -35,6 +36,7 @@ class Metrics:
|
|||
self._init_metrics_telemetry_air_quality()
|
||||
self._init_metrics_telemetry_power()
|
||||
self._init_route_discovery_metrics()
|
||||
self._init_pax_counter_metrics()
|
||||
|
||||
def update_metrics_position(self, latitude, longitude, altitude, precision, client_details: ClientDetails):
|
||||
# Could be used to calculate more complex data (Like distances etc..)
|
||||
|
@ -328,3 +330,23 @@ class Metrics:
|
|||
self._get_common_labels() + ['response_type'],
|
||||
registry=self._registry
|
||||
)
|
||||
|
||||
def _init_pax_counter_metrics(self):
|
||||
self.pax_wifi_gauge = Gauge(
|
||||
'pax_wifi',
|
||||
'Number of WiFi devices',
|
||||
self._get_common_labels(),
|
||||
registry=self._registry
|
||||
)
|
||||
self.pax_ble_gauge = Gauge(
|
||||
'pax_ble',
|
||||
'Number of BLE devices',
|
||||
self._get_common_labels(),
|
||||
registry=self._registry
|
||||
)
|
||||
self.pax_uptime_gauge = Gauge(
|
||||
'pax_uptime',
|
||||
'Uptime of the device',
|
||||
self._get_common_labels(),
|
||||
registry=self._registry
|
||||
)
|
||||
|
|
|
@ -267,6 +267,16 @@ class PaxCounterAppProcessor(Processor):
|
|||
except Exception as e:
|
||||
logger.error(f"Failed to parse PAXCOUNTER_APP packet: {e}")
|
||||
return
|
||||
self.metrics.pax_wifi_gauge.labels(
|
||||
**client_details.to_dict()
|
||||
).set(paxcounter.wifi)
|
||||
self.metrics.pax_ble_gauge.labels(
|
||||
**client_details.to_dict()
|
||||
).set(paxcounter.ble)
|
||||
self.metrics.pax_uptime_gauge.labels(
|
||||
**client_details.to_dict()
|
||||
).set(paxcounter.uptime)
|
||||
|
||||
|
||||
|
||||
@ProcessorRegistry.register_processor(PortNum.SERIAL_APP)
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
paho-mqtt~=2.1.0
|
||||
python-dotenv~=1.0.1
|
||||
prometheus_client~=0.20.0
|
||||
paho-mqtt>=2.1.0
|
||||
python-dotenv>=1.0.1
|
||||
prometheus_client>=0.21.1
|
||||
unishox2-py3~=1.0.0
|
||||
cryptography~=44.0.1
|
||||
psycopg~=3.1.19
|
||||
cryptography>=44.0.1
|
||||
psycopg>=3.2.5
|
||||
psycopg_pool~=3.2.2
|
||||
psycopg-binary~=3.1.20
|
||||
geopy>=2.4.1
|
||||
psycopg-pool>=3.2.2
|
||||
APScheduler>=3.10.4
|
||||
psycopg-pool>=3.2.5
|
||||
APScheduler>=3.11.0
|
||||
|
||||
# Meshtastic Protocol Buffers
|
||||
meshtastic-protobufs-protocolbuffers-python==29.3.0.1.20241006120827+cc36fd21e859
|
||||
|
|
Loading…
Reference in a new issue