Skip to main content

Device Attributes

You can store custom attributes for each of your devices.

Attributes and Metrics

Any metric that a device reports through the Metric SDK automatically populates an updatable device attribute with its latest reading. For example, sending battery_pct as a metric will populate a battery_pct attribute on the device with the last known battery level read from the device. As such, you can configure both metrics and attributes via the Metrics section of the Project Settings page.

Defining an Attribute#

An attribute is defined the first time you write it. You can view all defined properties going to Project Settings and then Metrics. An attribute definition can have a few properties:

  • A string_key which devices and APIs can use to identify the attribute.
  • Whether the data type is an INT (default), FLOAT, BOOL, or STRING.
  • Whether or not the value is updatable (or write-once).
  • Whether it is a favorite attribute, which will cause it to appear more prominently in a few places in the web app.
  • The value range which informs charts and other components.
  • A set of ignored_values (like -1) which should be ignored.

Example of some attribute definitions

Viewing an Attribute#

Find the device you want to view the attributes for (for example by browsing your devices on the Devices page) and select the Attributes tab. You'll see all the properties known for this project and the respective value for the device you're currently looking at.

Setting an Attribute#

There are three ways to write an attribute.

  1. using the Metrics API,
  2. using the REST API
  3. using the web application.

Because devices can update attributes, anyone who holds your Project Key can write or overwrite these attributes.

Using the REST API#

Below is an example of how attributes can be set using the Project Key and the REST API:


Be sure to replace ${DEVICE_SERIAL} and ${MEMFAULT_PROJECT_KEY} below with the device you want to update and your Project Key, respectively.

curl --location --request PATCH \
--header "Content-Type: application/json" \
--header "Memfault-Project-Key: ${MEMFAULT_PROJECT_KEY}" \
--data-raw '
{"string_key": "ProductName", "value": "SmartWatch"},
{"string_key": "ModelColor", "value": "Blue"}

Using the Web Application#

Visit the respective device page as described in Viewing an Attribute. Click on the pencil icon next to the value, enter the new value, and finally Save it.

Example of editing an attribute via the web application

Searching by Attribute#

You can search devices by attributes. Visiting the Devices page, open the Filter panel and select the Custom Metric you want to search by.

Example of filtering by an attribute

You can search by multiple attributes using the plus icon.

Searching by Attribute vs Metric Readings

If you select a During time frame, devices will be searched by their metric readings during that time frame, not by their device attributes (the latest reported metric).