Skip to main content

Events

An Event is a message generated by a Device. The types include but are not limited to Heartbeats, Traces, and Installs.

Event Types​

Event TypeDescription
heartbeatContains useful hourly metrics and system vitals
traceA Trace event, which adheres to the structure below

Request Schema​

Event TypeTypeDescription
type
Required
StringWhat type of Event this is. One of the Event Types above
Example: "heartbeat.hourly"
release_version
Required
StringVersion of the Release installed on the Device
Example: "1.2.3"
device_serial
Required
StringDevice Unique Identifier (set by client)
Example: ABCD1234
Example: "ABCD1234"
hardware_version
Required
StringHardware Version for the Device.
Example: "hwrev1"
sdk_version
Required
StringMemfault SDK Version on the Device
Example: "0.1.0"
captured_dateDateTimeDate the device captured the event
event_infoJSONEvent data. Exact schema is determined by the Event Type
extra_infoJSONExtra data. Memfault won't process this data, but will store it along with the Event

Event Info Payloads​

The following structures are the only valid objects that are allowed in the event_info object of an Event.

Heartbeat Event​

A heartbeat is like the "pulse" of a Device. It reports the vitals of the system, and gives Memfault an overview of what happened in the last hour.

The key-value pairs sent in the event_info.metrics field are required to be in string:number form. These metrics are parsed by Memfault and shown in dashboards. These metrics can be anything...be creative!

Some useful metrics to gather can include but are not limited to:

  • Uptime
  • Battery Percentage
  • Bluetooth Bytes Sent/Received
  • Wi-Fi Bytes Sent/Received
  • Bluetooth Time Connected
  • Heap Bytes Free/Allocated
  • Time Asleep/Awake
  • Flash Bytes Written/Read
  • CPU/MCU Utilization

It's also useful to record usage metrics of your devices. For example, if we want to record metrics for a Parking Meter, we may also want to record the number of user interactions or number of coins inserted to measure usage.

FieldTypeDescription
metricsObject[string:number]An object of a list of metrics as key:value pairs, where the key is a string and value is a number
{
"type": "heartbeat",
"release_version": "1.2.3",
"device_serial": "ABCD1234",
"hardware_version": "hwrev1",
"sdk_version": "0.4.0",
"event_info": {
"metrics": {
"battery_pct": 77,
"uptime_s": 17663,
"heap_free_b": 1227
}
},
"extra_info": {
"whatever": "you_want"
}
}

Trace Event​

An Event that is generally recorded and associated with a crash, reset, or assert. This event contains a micro-amount of data about the crash, usually on a few registers and a Trace Reason. With just this information, Memfault can group these events and surface Issues.

This is the smallest form of Traces. If you are looking for more detail about a particular type of crash, such as getting a full backtrace or a coredump of the system, Memfault can do that too. Please reach out!

FieldTypeDescription
reason
Required
Object[String:Number]The Trace Reason given by the Device
Example: See Table Below for all possible values
pc
Required
NumberRegister value of the PC (Program Counter) register at time of the Trace
Example: 226689
lrNumberRegister value of the LR (Link Register) register at time of the Trace
Example: 226574
spNumberRegister value of the SP (Stack Pointer) register at time of the Trace
Example: 6712
{
"type": "trace",
"release_version": "1.2.3",
"device_serial": "ABCD1234",
"hardware_version": "hwrev1",
"sdk_version": "0.4.0",
"event_info": {
"reason": 32769,
"pc": 226689,
"lr": 226574,
"sp": 6712
},
"extra_info": {
"whatever": "you_want"
}
}
Trace Reason​
Reason NameValueTypeNotes
UNKNOWN0x0000Unknown
USER_SHUTDOWN0x0001Normal
USER_RESET0x0002Normal
FW_UPDATE0x0003Normal
LOW_POWER0x0004Normal
ERROR_MASK0x8000ErrorEvery error below is masked against this value
WDKWWDR0x8000ErrorWe Don't Know Why We Dangerously Rebooted
wdkwwdr.com
ASSERT0x8001Error
WATCHDOG0x8002Error
BUS_FAULT0x9100ARM: Bus Fault
IBUSERR0x9101ARM: Bus Fault
PRECISERR0x9102ARM: Bus Fault
IMPRECISERR0x9103ARM: Bus Fault
UNSTKERR0x9104ARM: Bus Fault
STKERR0x9105ARM: Bus Fault
LSPERR0x9106ARM: Bus Fault
BFARVALID0x9107ARM: Bus Fault
MEM_FAULT0x9200ARM: Memory Faults
IACCVIOL0x9201ARM: Memory Faults
DACCVIOL0x9202ARM: Memory Faults
MUNSTKERR0x9203ARM: Memory Faults
MSTKERR0x9204ARM: Memory Faults
MLSPERR0x9205ARM: Memory Faults
MMARVALID0x9206ARM: Memory Faults
USAGE_FAULT0x9300ARM: Usage Faults
UNDEFINSTR0x9301ARM: Usage Faults
INVSTATE0x9302ARM: Usage Faults
INVPC0x9303ARM: Usage Faults
NOCP0x9304ARM: Usage Faults
UNALIGNED0x9305ARM: Usage Faults
DIVBYZERO0x9306ARM: Usage Faults
HARD_FAULT0x9400ARM: Hard Faults

Query Parameters​

The following parameters can be used to filter Events.

Query ParameterTypeDescription
deviceString[]Device Unique Identifier (set by client)
Example: ABCD1234
typeString[]Type of Event
Example: "heartbeat"
sinceDateTimeRecorded after this date
Example: "2019-01-19T05:01:13.000000+00:00"
untilDateTimeRecorded before this date
Example: "2019-01-19T05:01:13.000000+00:00"
releaseString[]Versions of Releases
Example: release=1.2.3&release=1.2.4
cohortString[]Events generated by Devices in these Cohorts
Example: cohort=alpha&cohort=beta
sortStringSort key (listed below)
Example: -created_date

Sort Parameters​

Sort ParameterTypeDescription
received_dateDateTimeDate the Event was received by Memfault
captured_dateDateTimeDate the Event was recorded on the Device
NOTE: will equal received_date if empty

Response Schema​

{
"data": {
"type": "heartbeat",
"device": {
"id": 1,
"device_serial": "ABCD1234",
"hardware_version": "hwrev1"
},
"release": {
"id": 1,
"version": "1.2.3",
"revision": "11d95ef20f7a048ce1da1a6891dd3e2f92c89d85"
},
"sdk_version": "0.4.0",
"received_date": "2019-01-19T05:01:13.000000+00:00",
"captured_date": "2019-01-19T05:01:13.000000+00:00",
"event_info": {
"metrics": {
"heap_free": 43,
"heap_blocks": 712,
"anything_else": 0
}
},
"user_info": {
"anything": "you_want",
"last_app_opened": "Timer"
}
}
}