As I always warn people, do not treat structured data as text. Using Splunk's built-in function with JSON, XML, and so on is much more robust and saves you tons of headaches in future maintenance. ...
See more...
As I always warn people, do not treat structured data as text. Using Splunk's built-in function with JSON, XML, and so on is much more robust and saves you tons of headaches in future maintenance. All you need to do is to extract the conformant JSON into its own field. Then apply spath. (An alternative new syntax is fromjson.) | rex "^[^{]+\s*(?<json>{.+})"
| spath input=json It's that simple. Your sample log will give you everything in that JSON. fieldname fieldvalue Bat1Volt 7.931 BatPercent 100 BatTech Rechargeable Battery1CaliVoltage 7.931 CameraOffline 48 CameraOnline 11029337 ChargerTech QuickCharger ChargingState Off CriticalBatStatus 0 DdrFailCnt 0 FailedStreams 1 FailedUpgrades 0 HardwareRevision H6 HardwareVersion H6 ID 534 IRLEDsOn 21054 ISPOn 57564 ISPWatchdogCount 0 ISPWatchdogCount2 0 LogFrequency 2 MotionStreamed 7561 PIREvents 66 PercentAtPlug 95 PercentAtUnPlug 100 PirOorEvents 0 PoweredOn 11029385 SecsPerPercentAvg 0 SecsPerPercentCurr 0 SignalStrengthIndicator 2 SnapshotCount 0 Streamed 53395 SystemFirmwareVersion 1.096.3.2_30_0bad0df SystemSerialNumber 51D29C77A022A SystemVersionString 1.096.3.2_1.8.65.0_22 Temperature 24 TimeAtPlug 11025490 TimeAtUnPlug 10979418 TimeStamp 2023-10-12T11:23:36+0000 Type status UserStreamed 1650 WifiConnectionAttempts 2 WifiConnectionCount 2 WifiCountryDetails carrierFw Generic json {"Type":"status","HardwareRevision":"H6","WifiCountryDetails":"","BatPercent":100,"BatTech":"Rechargeable","ChargerTech":"QuickCharger","ChargingState":"Off","Bat1Volt":7.931,"Temperature":24,"Battery1CaliVoltage":7.931,"Streamed":53395,"UserStreamed":1650,"MotionStreamed":7561,"IRLEDsOn":21054,"PoweredOn":11029385,"CameraOnline":11029337,"CameraOffline":48,"WifiConnectionCount":2,"WifiConnectionAttempts":2,"PIREvents":66,"FailedStreams":1,"FailedUpgrades":0,"SnapshotCount":0,"LogFrequency":2,"CriticalBatStatus":0,"ISPOn":57564,"TimeAtPlug":11025490,"TimeAtUnPlug":10979418,"PercentAtPlug":95,"PercentAtUnPlug":100,"ISPWatchdogCount":0,"ISPWatchdogCount2":0,"SecsPerPercentCurr":0,"SecsPerPercentAvg":0,"PirOorEvents":0,"DdrFailCnt":0,"carrierFw":"Generic","SignalStrengthIndicator":2,"SystemVersionString":"1.096.3.2_1.8.65.0_22","ID":534,"SystemFirmwareVersion":"1.096.3.2_30_0bad0df","HardwareVersion":"H6","SystemSerialNumber":"51D29C77A022A","TimeStamp":"2023-10-12T11:23:36+0000"} Here is an emulation you can play with and compare with real data | makeresults
| eval _raw="178.197.202.134 SECURITY_MONITORING_AUTOMATION CAMERA_SYSTEMS VML4 VML4030 1697109816450 INFO 51D29C77A022A KU5TFBKH-1700-316-114351851 - statusInfo {\"Type\":\"status\",\"HardwareRevision\":\"H6\",\"WifiCountryDetails\":\"\",\"BatPercent\":100,\"BatTech\":\"Rechargeable\",\"ChargerTech\":\"QuickCharger\",\"ChargingState\":\"Off\",\"Bat1Volt\":7.931,\"Temperature\":24,\"Battery1CaliVoltage\":7.931,\"Streamed\":53395,\"UserStreamed\":1650,\"MotionStreamed\":7561,\"IRLEDsOn\":21054,\"PoweredOn\":11029385,\"CameraOnline\":11029337,\"CameraOffline\":48,\"WifiConnectionCount\":2,\"WifiConnectionAttempts\":2,\"PIREvents\":66,\"FailedStreams\":1,\"FailedUpgrades\":0,\"SnapshotCount\":0,\"LogFrequency\":2,\"CriticalBatStatus\":0,\"ISPOn\":57564,\"TimeAtPlug\":11025490,\"TimeAtUnPlug\":10979418,\"PercentAtPlug\":95,\"PercentAtUnPlug\":100,\"ISPWatchdogCount\":0,\"ISPWatchdogCount2\":0,\"SecsPerPercentCurr\":0,\"SecsPerPercentAvg\":0,\"PirOorEvents\":0,\"DdrFailCnt\":0,\"carrierFw\":\"Generic\",\"SignalStrengthIndicator\":2,\"SystemVersionString\":\"1.096.3.2_1.8.65.0_22\",\"ID\":534,\"SystemFirmwareVersion\":\"1.096.3.2_30_0bad0df\",\"HardwareVersion\":\"H6\",\"SystemSerialNumber\":\"51D29C77A022A\",\"TimeStamp\":\"2023-10-12T11:23:36+0000\"}"
``` data emulation above ```