json_exporter doesn't read some values in the root path
Opened this issue · 0 comments
giuliomagnifico commented
Hi, sorry for the long message but I can't figure out why some metrics (like ram, file system, MAC address, etc.) aren't being read from the JSON exporter.
On the status page of the Shelly EM, the data are:
{
"wifi_sta":{
"connected":true,
"ssid":"Magnifico_IoT",
"ip":"192.168.50.217",
"rssi":-35
},
"cloud":{
"enabled":true,
"connected":true
},
"mqtt":{
"connected":false
},
"time":"09:37",
"unixtime":1723880257,
"serial":2419,
"has_update":false,
"mac":"ExxxxxE",
"cfg_changed_cnt":2,
"actions_stats":{
"skipped":0
},
"relays":[
{
"ison":false,
"has_timer":false,
"timer_started":0,
"timer_duration":0,
"timer_remaining":0,
"overpower":false,
"is_valid":true,
"source":"input"
}
],
"emeters":[
{
"power":779.42,
"reactive":477.09,
"pf":0.85,
"voltage":224.61,
"is_valid":true,
"total":80541.7,
"total_returned":0.0
},
{
"power":0.00,
"reactive":0.00,
"pf":0.00,
"voltage":224.61,
"is_valid":true,
"total":0.0,
"total_returned":0.0
}
],
"update":{
"status":"idle",
"has_update":false,
"new_version":"20230913-114150/v1.14.0-gcb84623",
"old_version":"20230913-114150/v1.14.0-gcb84623",
"beta_version":"20231107-164916/v1.14.1-rc1-g0617c15"
},
"ram_total":51064,
"ram_free":35564,
"fs_size":233681,
"fs_free":157879,
"uptime":376557
}
And here's my Json Exporter config:
modules:
shelly_em:
metrics:
# Metrics from the first emeter
- name: shelly_em_meter_0
type: object
path: '{ .emeters[0] }'
help: Shelly EM Meter 0 Data
labels:
phase: '0'
values:
Instant_Power: '{.power}'
Instant_Current: '{.current}'
Instant_Voltage: '{.voltage}'
Instant_PowerFactor: '{.pf}'
Energy_Consumed: '{.total}'
Energy_Produced: '{.total_returned}'
# Metrics from the second emeter
- name: shelly_em_meter_1
type: object
path: '{ .emeters[1] }'
help: Shelly EM Meter 1 Data
labels:
phase: '1'
values:
Instant_Power: '{.power}'
Instant_Voltage: '{.voltage}'
Instant_PowerFactor: '{.pf}'
Energy_Consumed: '{.total}'
Energy_Produced: '{.total_returned}'
# Wi-Fi status
- name: shelly_em_wifi
type: object
path: '{ .wifi_sta }'
help: Shelly EM Wi-Fi Status
labels:
Wifi_SSID: '{.ssid}'
Wifi_IP: '{.ip}'
values:
Wifi_Connected: '{.connected}'
Wifi_RSSI: '{.rssi}'
# Cloud status
- name: shelly_em_cloud
type: object
path: '{ .cloud }'
help: Shelly EM Cloud Status
values:
Cloud_Enabled: '{.enabled}'
Cloud_Connected: '{.connected}'
# Device information
- name: shelly_em_device_info
type: object
path: '{ .update }'
help: Shelly EM Device Update Information
labels:
Update_New_Version: '{.new_version}'
Update_Old_Version: '{.old_version}'
Update_Beta_Version: '{.beta_version}'
values:
Update_Status: '{.status}'
Update_Has_Update: '{.has_update}'
# System metrics
- name: shelly_em_system_metrics
type: object
path: '{ $ }'
help: Shelly EM System Metrics
values:
Ram_Total: '{.ram_total}'
Ram_Free: '{.ram_free}'
Fs_Size: '{.fs_size}'
Fs_Free: '{.fs_free}'
System_Uptime: '{.uptime}'
But I can's see some of the last metrics, RAM and fs for example. Here're the Prometheus metrics:
# HELP shelly_em_cloud_Cloud_Connected Shelly EM Cloud Status
# TYPE shelly_em_cloud_Cloud_Connected untyped
shelly_em_cloud_Cloud_Connected 1
# HELP shelly_em_cloud_Cloud_Enabled Shelly EM Cloud Status
# TYPE shelly_em_cloud_Cloud_Enabled untyped
shelly_em_cloud_Cloud_Enabled 1
# HELP shelly_em_device_info_Update_Has_Update Shelly EM Device Update Information
# TYPE shelly_em_device_info_Update_Has_Update untyped
shelly_em_device_info_Update_Has_Update{Update_Beta_Version="20231107-164916/v1.14.1-rc1-g0617c15",Update_New_Version="20230913-114150/v1.14.0-gcb84623",Update_Old_Version="20230913-114150/v1.14.0-gcb84623"} 0
# HELP shelly_em_meter_0_Energy_Consumed Shelly EM Meter 0 Data
# TYPE shelly_em_meter_0_Energy_Consumed untyped
shelly_em_meter_0_Energy_Consumed{phase="0"} 80528.8
# HELP shelly_em_meter_0_Energy_Produced Shelly EM Meter 0 Data
# TYPE shelly_em_meter_0_Energy_Produced untyped
shelly_em_meter_0_Energy_Produced{phase="0"} 0
# HELP shelly_em_meter_0_Instant_Power Shelly EM Meter 0 Data
# TYPE shelly_em_meter_0_Instant_Power untyped
shelly_em_meter_0_Instant_Power{phase="0"} 775.21
# HELP shelly_em_meter_0_Instant_PowerFactor Shelly EM Meter 0 Data
# TYPE shelly_em_meter_0_Instant_PowerFactor untyped
shelly_em_meter_0_Instant_PowerFactor{phase="0"} 0.85
# HELP shelly_em_meter_0_Instant_Voltage Shelly EM Meter 0 Data
# TYPE shelly_em_meter_0_Instant_Voltage untyped
shelly_em_meter_0_Instant_Voltage{phase="0"} 224.79
# HELP shelly_em_meter_1_Energy_Consumed Shelly EM Meter 1 Data
# TYPE shelly_em_meter_1_Energy_Consumed untyped
shelly_em_meter_1_Energy_Consumed{phase="1"} 0
# HELP shelly_em_meter_1_Energy_Produced Shelly EM Meter 1 Data
# TYPE shelly_em_meter_1_Energy_Produced untyped
shelly_em_meter_1_Energy_Produced{phase="1"} 0
# HELP shelly_em_meter_1_Instant_Power Shelly EM Meter 1 Data
# TYPE shelly_em_meter_1_Instant_Power untyped
shelly_em_meter_1_Instant_Power{phase="1"} 0
# HELP shelly_em_meter_1_Instant_PowerFactor Shelly EM Meter 1 Data
# TYPE shelly_em_meter_1_Instant_PowerFactor untyped
shelly_em_meter_1_Instant_PowerFactor{phase="1"} 0
# HELP shelly_em_meter_1_Instant_Voltage Shelly EM Meter 1 Data
# TYPE shelly_em_meter_1_Instant_Voltage untyped
shelly_em_meter_1_Instant_Voltage{phase="1"} 224.79
# HELP shelly_em_wifi_Wifi_Connected Shelly EM Wi-Fi Status
# TYPE shelly_em_wifi_Wifi_Connected untyped
shelly_em_wifi_Wifi_Connected{Wifi_IP="192.168.50.217",Wifi_SSID="Magnifico_IoT"} 1
# HELP shelly_em_wifi_Wifi_RSSI Shelly EM Wi-Fi Status
# TYPE shelly_em_wifi_Wifi_RSSI untyped
shelly_em_wifi_Wifi_RSSI{Wifi_IP="192.168.50.217",Wifi_SSID="Magnifico_IoT"} -37
Without any errors in the logs of the json_exporter.
But f I change the path: '{ $ }'
to path: '{ . }'
in the # System metrics, then I get those errors
# System metrics
- name: shelly_em_system_metrics
type: object
path: '{ . }'# from $
help: Shelly EM System Metrics
values:
Ram_Total: '{.ram_total}'
Ram_Free: '{.ram_free}'
Fs_Size: '{.fs_size}'
Fs_Free: '{.fs_free}'
System_Uptime: '{.uptime}'
Errors:
service json_exporter status
● json_exporter.service - json_exporter
Loaded: loaded (/etc/systemd/system/json_exporter.service; enabled; preset: enabled)
Active: active (running) since Sat 2024-08-17 09:31:08 CEST; 14s ago
Main PID: 679044 (json_exporter)
Tasks: 5 (limit: 9272)
CPU: 13ms
CGroup: /system.slice/json_exporter.service
└─679044 /home/dietpi/prometheus/exporter/json_exporter/json_exporter --config.file=/home/dietpi/prometheus/exporter/json_exporter/shelly.json
Aug 17 09:31:10 DietPi json_exporter[679044]: ts=2024-08-17T07:31:10.079Z caller=collector.go:139 level=error msg="Failed to execute jsonpath" err=" is not found" path="{ . }" data="{\"wifi_sta\":{\"connected\":t
rue,\"ssid\":\"Magnifico_IoT\",\"ip\":\"192.168.50.217\",\"rssi\":-37},\"cloud\":{\"enabled\":true,\"connected\":true},\"mqtt\":{\"connected\":false},\"time\":\"09:31\",\"unixtime\":1723879883,\"serial\":2418,\"h
as_update\":false,\"mac\":\"EC64C9C05EFE\",\"cfg_changed_cnt\":2,\"actions_stats\":{\"skipped\":0},\"relays\":[{\"ison\":false,\"has_timer\":false,\"timer_started\":0,\"timer_duration\":0,\"timer_remaining\":0,\"
overpower\":false,\"is_valid\":true,\"source\":\"input\"}],\"emeters\":[{\"power\":779.01,\"reactive\":473.39,\"pf\":0.85,\"voltage\":224.48,\"is_valid\":true,\"total\":80463.6,\"total_returned\":0.0},{\"power\":
0.00,\"reactive\":0.00,\"pf\":0.00,\"voltage\":224.48,\"is_valid\":true,\"total\":0.0,\"total_returned\":0.0}],\"update\":{\"status\":\"idle\",\"has_update\":false,\"new_version\":\"20230913-114150/v1.14.0-gcb846
23\",\"old_version\":\"20230913-114150/v1.14.0-gcb84623\",\"beta_version\":\"20231107-164916/v1.14.1-rc1-g0617c15\"},\"ram_total\":51064,\"ram_free\":36172,\"fs_size\":233681,\"fs_free\":157879,\"uptime\":376184}
"
Aug 17 09:31:10 DietPi json_exporter[679044]: ts=2024-08-17T07:31:10.079Z caller=collector.go:76 level=error msg="Failed to extract json objects for metric" err=" is not found" metric="Desc{fqName: \"shelly_em_sy
stem_metrics_Ram_Total\", help: \"Shelly EM System Metrics\", constLabels: {}, variableLabels: []}"
Aug 17 09:31:10 DietPi json_exporter[679044]: ts=2024-08-17T07:31:10.079Z caller=collector.go:139 level=error msg="Failed to execute jsonpath" err=" is not found" path="{ . }" data="{\"wifi_sta\":{\"connected\":t
rue,\"ssid\":\"Magnifico_IoT\",\"ip\":\"192.168.50.217\",\"rssi\":-37},\"cloud\":{\"enabled\":true,\"connected\":true},\"mqtt\":{\"connected\":false},\"time\":\"09:31\",\"unixtime\":1723879883,\"serial\":2418,\"h
as_update\":false,\"mac\":\"EC64C9C05EFE\",\"cfg_changed_cnt\":2,\"actions_stats\":{\"skipped\":0},\"relays\":[{\"ison\":false,\"has_timer\":false,\"timer_started\":0,\"timer_duration\":0,\"timer_remaining\":0,\"
overpower\":false,\"is_valid\":true,\"source\":\"input\"}],\"emeters\":[{\"power\":779.01,\"reactive\":473.39,\"pf\":0.85,\"voltage\":224.48,\"is_valid\":true,\"total\":80463.6,\"total_returned\":0.0},{\"power\":
0.00,\"reactive\":0.00,\"pf\":0.00,\"voltage\":224.48,\"is_valid\":true,\"total\":0.0,\"total_returned\":0.0}],\"update\":{\"status\":\"idle\",\"has_update\":false,\"new_version\":\"20230913-114150/v1.14.0-gcb846
23\",\"old_version\":\"20230913-114150/v1.14.0-gcb84623\",\"beta_version\":\"20231107-164916/v1.14.1-rc1-g0617c15\"},\"ram_total\":51064,\"ram_free\":36172,\"fs_size\":233681,\"fs_free\":157879,\"uptime\":376184}
"
Aug 17 09:31:10 DietPi json_exporter[679044]: ts=2024-08-17T07:31:10.079Z caller=collector.go:76 level=error msg="Failed to extract json objects for metric" err=" is not found" metric="Desc{fqName: \"shelly_em_sy
stem_metrics_Ram_Free\", help: \"Shelly EM System Metrics\", constLabels: {}, variableLabels: []}"
Aug 17 09:31:10 DietPi json_exporter[679044]: ts=2024-08-17T07:31:10.079Z caller=collector.go:139 level=error msg="Failed to execute jsonpath" err=" is not found" path="{ . }" data="{\"wifi_sta\":{\"connected\":t
rue,\"ssid\":\"Magnifico_IoT\",\"ip\":\"192.168.50.217\",\"rssi\":-37},\"cloud\":{\"enabled\":true,\"connected\":true},\"mqtt\":{\"connected\":false},\"time\":\"09:31\",\"unixtime\":1723879883,\"serial\":2418,\"h
as_update\":false,\"mac\":\"EC64C9C05EFE\",\"cfg_changed_cnt\":2,\"actions_stats\":{\"skipped\":0},\"relays\":[{\"ison\":false,\"has_timer\":false,\"timer_started\":0,\"timer_duration\":0,\"timer_remaining\":0,\"
overpower\":false,\"is_valid\":true,\"source\":\"input\"}],\"emeters\":[{\"power\":779.01,\"reactive\":473.39,\"pf\":0.85,\"voltage\":224.48,\"is_valid\":true,\"total\":80463.6,\"total_returned\":0.0},{\"power\":
0.00,\"reactive\":0.00,\"pf\":0.00,\"voltage\":224.48,\"is_valid\":true,\"total\":0.0,\"total_returned\":0.0}],\"update\":{\"status\":\"idle\",\"has_update\":false,\"new_version\":\"20230913-114150/v1.14.0-gcb846
23\",\"old_version\":\"20230913-114150/v1.14.0-gcb84623\",\"beta_version\":\"20231107-164916/v1.14.1-rc1-g0617c15\"},\"ram_total\":51064,\"ram_free\":36172,\"fs_size\":233681,\"fs_free\":157879,\"uptime\":376184}
"
Aug 17 09:31:10 DietPi json_exporter[679044]: ts=2024-08-17T07:31:10.079Z caller=collector.go:76 level=error msg="Failed to extract json objects for metric" err=" is not found" metric="Desc{fqName: \"shelly_em_sy
stem_metrics_Fs_Size\", help: \"Shelly EM System Metrics\", constLabels: {}, variableLabels: []}"
Aug 17 09:31:10 DietPi json_exporter[679044]: ts=2024-08-17T07:31:10.079Z caller=collector.go:139 level=error msg="Failed to execute jsonpath" err=" is not found" path="{ . }" data="{\"wifi_sta\":{\"connected\":t
rue,\"ssid\":\"Magnifico_IoT\",\"ip\":\"192.168.50.217\",\"rssi\":-37},\"cloud\":{\"enabled\":true,\"connected\":true},\"mqtt\":{\"connected\":false},\"time\":\"09:31\",\"unixtime\":1723879883,\"serial\":2418,\"h
as_update\":false,\"mac\":\"EC64C9C05EFE\",\"cfg_changed_cnt\":2,\"actions_stats\":{\"skipped\":0},\"relays\":[{\"ison\":false,\"has_timer\":false,\"timer_started\":0,\"timer_duration\":0,\"timer_remaining\":0,\"
overpower\":false,\"is_valid\":true,\"source\":\"input\"}],\"emeters\":[{\"power\":779.01,\"reactive\":473.39,\"pf\":0.85,\"voltage\":224.48,\"is_valid\":true,\"total\":80463.6,\"total_returned\":0.0},{\"power\":
0.00,\"reactive\":0.00,\"pf\":0.00,\"voltage\":224.48,\"is_valid\":true,\"total\":0.0,\"total_returned\":0.0}],\"update\":{\"status\":\"idle\",\"has_update\":false,\"new_version\":\"20230913-114150/v1.14.0-gcb846
23\",\"old_version\":\"20230913-114150/v1.14.0-gcb84623\",\"beta_version\":\"20231107-164916/v1.14.1-rc1-g0617c15\"},\"ram_total\":51064,\"ram_free\":36172,\"fs_size\":233681,\"fs_free\":157879,\"uptime\":376184}
"
Aug 17 09:31:10 DietPi json_exporter[679044]: ts=2024-08-17T07:31:10.079Z caller=collector.go:76 level=error msg="Failed to extract json objects for metric" err=" is not found" metric="Desc{fqName: \"shelly_em_sy
stem_metrics_Fs_Free\", help: \"Shelly EM System Metrics\", constLabels: {}, variableLabels: []}"
Aug 17 09:31:10 DietPi json_exporter[679044]: ts=2024-08-17T07:31:10.079Z caller=collector.go:139 level=error msg="Failed to execute jsonpath" err=" is not found" path="{ . }" data="{\"wifi_sta\":{\"connected\":t
rue,\"ssid\":\"Magnifico_IoT\",\"ip\":\"192.168.50.217\",\"rssi\":-37},\"cloud\":{\"enabled\":true,\"connected\":true},\"mqtt\":{\"connected\":false},\"time\":\"09:31\",\"unixtime\":1723879883,\"serial\":2418,\"h
as_update\":false,\"mac\":\"EC64C9C05EFE\",\"cfg_changed_cnt\":2,\"actions_stats\":{\"skipped\":0},\"relays\":[{\"ison\":false,\"has_timer\":false,\"timer_started\":0,\"timer_duration\":0,\"timer_remaining\":0,\"
overpower\":false,\"is_valid\":true,\"source\":\"input\"}],\"emeters\":[{\"power\":779.01,\"reactive\":473.39,\"pf\":0.85,\"voltage\":224.48,\"is_valid\":true,\"total\":80463.6,\"total_returned\":0.0},{\"power\":
0.00,\"reactive\":0.00,\"pf\":0.00,\"voltage\":224.48,\"is_valid\":true,\"total\":0.0,\"total_returned\":0.0}],\"update\":{\"status\":\"idle\",\"has_update\":false,\"new_version\":\"20230913-114150/v1.14.0-gcb846
23\",\"old_version\":\"20230913-114150/v1.14.0-gcb84623\",\"beta_version\":\"20231107-164916/v1.14.1-rc1-g0617c15\"},\"ram_total\":51064,\"ram_free\":36172,\"fs_size\":233681,\"fs_free\":157879,\"uptime\":376184}
"
Aug 17 09:31:10 DietPi json_exporter[679044]: ts=2024-08-17T07:31:10.079Z caller=collector.go:76 level=error msg="Failed to extract json objects for metric" err=" is not found" metric="Desc{fqName: \"shelly_em_sy
stem_metrics_System_Uptime\", help: \"Shelly EM System Metrics\", constLabels: {}, variableLabels
How can I read the "unreported" values?
Thanks in advance for the help.