Skip to main content

Android Built-in Metrics

The Android SDK contains built-in support for collecting many different types of metrics from Android devices.

Configuration

Most built-in metrics can be enabled, disabled, and additionally configured in Memfault dashboard, under Settings → Data Sources. Additional setup in the Memfault dashboard, under Settings → Metrics, may be necessary to set the metrics as Attributes (for use of the metric in Search and Device Sets) or Timeseries (for use of the metric in Metric charts and Device Sets).

Memfault will automatically configure certain metrics as Timeseries or Attributes and set a value range upon creation, but these can changed in the same view.

Visibility

Some metrics are only visible as High-Resolution Telemetry, which allows for fine-grained observability of a single Device, but no aggregation or search across multiple devices.

Many HRT-only metrics will have a counterpart aggregate Heartbeat Metric.

Memfault will also add new built-in metrics, and improve existing metrics over time, with newer SDK versions.

Custom Metrics

Support for custom metrics is available with Memfault's Reporting API. This enables capturing domain specific metrics that Memfault wouldn't know about otherwise. Most built-in metrics are captured using the same Memfault Reporting API.

Crash Metrics

Collected since Android SDK 5.3.0

MetricDescriptionUsage
drop_box_(.*)_countNumber of dropbox entries received by type (one of anr|exception|wtf|native|kmsg|panic).Track crashes or errors by type.
operational_crashesNumber of crashes captured.Track crashes.
operational_crashes_(.*)Number of crashes captured, by app/process group.Track crashes, for specific apps/processes.

Battery Metrics

MetricDescriptionUsage
battery_discharge_duration_msTime spent with the battery discharging. Calculated by the time spent in the BatteryStats Battery Status (“Bs”) Discharging (“d”) state.
battery_charge_duration_msTime spent charging the battery. Calculated by the time spent in the BatteryStats Battery Status (“Bs”) Charging (“c”) state.
battery_soc_pct_dropBattery discharged (in whole %). Calculated as the drop in the BatteryStats Battery Level (“Bl”) value.Identify devices with periods of large battery drain.
battery_soc_pct_riseBattery charge gained (in whole %). Calculated as the rise in the BatteryStats Battery Level (“Bl”) value.
battery_charge_rate_pct_per_hour_avgCharging rate (0-100% per hour), when charging. Calculated by dividing the battery_soc_pct_rise by battery_charge_duration_ms, adjusted to a per hour rate.
battery_discharge_rate_pct_per_hour_avgDischarge rate (-100-0% per hour), when discharging. Calculated by dividing the battery_soc_pct_drop by battery_discharge_duration_ms, adjusted to a per hour rate.
screen_on_battery_drain_%/hourBattery drain (0-100% per hour), while the screen was on. Calculated as the BatteryStats Discharge Data (”dc”) total drain counter subtracted by the screen off drain counter, divided by the estimated_battery_capacity_mah, adjusted to a per hour rate.
screen_off_battery_drain_%/hourBattery drain (0-100% per hour), while the screen was off. Calculated as the BatteryStats Discharge Data (”dc”) screen off drain counter divided by the estimated_battery_capacity_mah, adjusted to a per hour rate.
battery_screen_on_discharge_duration_msTime spent with the battery discharging while the screen was on. Calculated from the BatteryStats Battery (“Bt”) realtime value minus screen off realtime.
battery_screen_on_soc_pct_dropBattery drain (0-100%), while the screen was on. Calculated as the BatteryStats Discharge Data (”dc”) total drain counter subtracted by the screen off drain counter, divided by the estimated_battery_capacity_mah.
battery_screen_off_discharge_duration_msTime spent with the battery discharging while the screen was of. Calculated from the BatteryStats Battery (“Bt”) screen off realtime value.
battery_screen_off_soc_pct_dropBattery drain (0-100%), while the screen was off. Calculated as the BatteryStats Discharge Data (”dc”) screen off drain counter divided by the estimated_battery_capacity_mah.
battery_use_%/hour_(.*)Battery usage by component (0-100%). There are 2 different kinds of components: Android-specific power components, and process components. Only usage over 0.01% is recorded.Track the relative battery usage between different components and apps/processes.
battery_use_top_component_nameName of the component with the highest battery usage that period.
battery_use_top_component_pctPercent usage of the component with the highest battery usage that period.
estimated_battery_capacity_mahReturns the estimated real battery capacity, which may be less than the capacity declared by the PowerProfile (for example, because of battery aging). Calculated as the capacity declared in the PowerProfile by default, and updated by dividing the charge counter by the battery level.
original_battery_capacity_mahReturns the best known estimate of the battery capacity. Calculated as taking the learned battery capacity, or the min learned battery capacity, else falling back to the estimated battery capacity.Identify discrepancies in the calculated battery capacity versus the actual expected battery capacity.
computed_battery_capacity_mahReturns the total amount of battery charge drained since the last BatteryStats reset.
min_battery_capacity_mahReturns the minimum range of discharged power since the last BatteryStats reset.
max_battery_capacity_mahReturns the maximum range of discharged power since the last BatteryStats reset.
battery_state_of_health_%Health of the battery, as estimated_battery_capacity_mah divided by original_battery_capacitiy_mah.
battery.charge_cycle_count.latestValue of the battery charging cycle count.Track devices with high charge cycle counts. Preemptively account for battery drain issues.

Per-component battery usage is displayed on Timeline. The usage (in % per hour) for component app which used >= 0.01% is shown as follows:

Battery usage per component
  • This is shown in the Battery Usage %/hour swimlane as shown in the screenshot, with separate entries for each component. Components is grouped into Android OS components (e.g. cell, idle, android, screen, bluetooth, gnss) and applications/processes (e.g. com.google.android.youtube, com.android.vending, com.whatsapp).

Connectivity Metrics

The Android SDK collects metrics tracking connectivity changes on the Device.

MetricDescriptionUsageHRT only
airplane_modeChecks whether Airplane Mode was enabled. Derived from Settings.Global.AIRPLANE_MODE_ON.✔️
connectivity.validatedChecks whether the connectivity on the connected network was successfully validated. Derived from NetworkCapabilities.NET_CAPABILITY_VALIDATED.✔️
connectivity.captive_portalChecks whether the connectivity on the connected network was found to have a captive portal in place. Derived from NetworkCapabilities.NET_CAPABILITY_CAPTIVE_PORTAL.✔️
connectivity.roamingChecks whether the connected network is roaming. Derived from NetworkCapabilities.NET_CAPABILITY_NOT_ROAMING.✔️
connectivity.unmetered_temporarilyChecks whether the connected network is temporarily unmetered. Derived from NetworkCapabilities.NET_CAPABILITY_TEMPORARILY_NOT_METERED.✔️
connectivity.meteredChecks whether the connected network is metered. Derived from NetworkCapabilities.NET_CAPABILITY_NOT_METERED.✔️
connectivity.metered.latestReturns whether the network is metered.Track devices that are connected to metered networks.

Uptime Metrics

The connectivity type matches the transport types returned from the Android NetworkCapabilities#hasTransport API.

MetricDescriptionUsageHRT only
connectivity.type_(.*).secs/hourRate of time (seconds per hour) connected to the type of connectivity (one of NONE|ETHERNET|CELLULAR|WIFI|VPN|USB|UNKNOWN).Segment investigations by connectivity type.
connectivity.type_(.*).total_secsAbsolute time (seconds) connected to the type of connectivity (one of NONE|ETHERNET|CELLULAR|WIFI|VPN|USB|UNKNOWN).
connectivity.type_(.*).mean_time_in_state_msAverage time (seconds) spent connected to the type of connectivity (one of NONE|ETHERNET|CELLULAR|WIFI|VPN|USB|UNKNOWN).

Wi-Fi Metrics

Collected since Android SDK 5.4.0

If the Device is connected to a Wi-Fi network, additional Wi-Fi metrics can be collected.

MetricDescriptionUsageHRT only
connectivity.wifi.frequency.latestReturns the frequency of the connected Wi-Fi network, if available.
connectivity.wifi.link_speed_mbps.latestReturns the link speed (in Mbps) of the connected Wi-Fi network, if available.
connectivity.wifi.standard_version.latestReturns the standard of the connected Wi-Fi network, if available (Android 11+).
connectivity.wifi.security_type.latestReturns the security type of the connected Wi-Fi network, if available (Android 12+).
connectivity.wifi.lost_tx_packets_per_second.latestAverage rate of lost transmitted packets (packets per second).Identify devices with poor network reliability.
connectivity.wifi.retried_tx_packets_per_second.latestAverage rate of transmitted retry packets (packets per second).Identify devices with poor network reliability.
connectivity.wifi.successful_tx_packets_per_second.latestAverage rate of successfully transmitted unicast packets (packets per second).
connectivity.wifi.successful_rx_packets_per_second.latestAverage rate of received unicast data packets (packets per second).

Network Bandwidth

Collected since Android SDK 4.15.0, Updated in SDK 5.2.0

The Android SDK will record the total network usage on the Device every Heartbeat period using Android's NetworkStatsManager APIs. These are always recorded in every Heartbeat report.

The Android SDK will also record the network usage on the Device by the specific type of connectivity (WIFI, ETHERNET, MOBILE, or BLUETOOTH), if the value is greater than zero for that Heartbeat period.

Finally, the Android SDK can also collect per-app network usage for every app on the Device that exceeds the specified threshold (1MB by default). These are only visible in HRT, on the Device Timeline.

MetricDescriptionUsage
connectivity_recv_bytesTotal data received from the network (bytes).Track the network usage of the device.
connectivity_sent_bytesTotal data sent through the network (bytes).Track the network usage of the device.
connectivity_(bt|wifi|mobile|eth)_(recv|sent)_bytesTotal data received/sent through the network for the type of connectivity (bytes).Track the type of network usage of the device.
connectivity_comp_(.*)_(recv|sent)_bytesTotal data received/sent through the network by the specific component (bytes).Identify apps/proccesses with higher than expected network usage.
connectivity_comp_(.*)_(bt|wifi|mobile|eth)_(recv|sent)_bytesTotal data received/sent through the network for the type of connectivity by the specific component (bytes).

Storage Metrics

The Android SDK regularly collects Device storage usage metrics from Android's Environment.getDataDirectory API.

MetricDescriptionUsage
storage_used_pctPercent (0-100%) of free space in the user data directory.Identify devices that may be running out of space. Preemptively account for low space issues.
storage.data.percentage_used.latestDeprecated. Percent (0-1%) of free space in the user data directory.
storage.data.bytes_free.latestAmount of free space in the user directory (bytes).
storage.data.bytes_used.latestAmount of used space in the user directory (bytes).
storage.data.bytes_total.latestTotal storage available in the user directory (bytes).

Temperature Metrics

Updated in SDK 5.2.0

The Android SDK regularly collects several device temperature metrics, from Android's HardwarePropertiesManager. This allows the SDK to collect the CPU and device skin temperatures programmatically.

The temperatures are reported with min/max/mean values each hour. Note that each device has a different collection of sensors — an example device with one device skin sensor and two CPU sensors might have a set of metrics like this.

  • Device Skin Sensor A
    • thermal_skin_A_c
    • thermal_skin_A_c_max
  • CPU Sensor 1
    • thermal_cpu_1_c
    • thermal_cpu_1_c_max
  • CPU Sensor 2
    • thermal_cpu_2_c
    • thermal_cpu_2_c_max
MetricDescriptionUsage
thermal_cpu_cAverage temperature (Celsius) of all CPU sensors.Track the average CPU temperature of the device.
thermal_cpu_c_maxMax temperature (Celsius) of all CPU sensors.Identify devices with high CPU temperature readings.
thermal_battery_cAverage temperature (Celsius) of all Battery sensors.Track the average Battery temperature of the device.
thermal_battery_c_maxMax temperature (Celsius) of all Battery sensors.Identify devices with high Battery temperature readings.
thermal_(.*)_(.*)_cAverage temperature (Celsius) of the sensor by type and name.Track the average temperature of the device by sensor.
thermal_(.*)_(.*)_c_maxMax temperature (Celsius) of the sensor by type and name.Identify devices with high temperature readings by sensor.
thermal_status_(.*)_maxMax reading for the thermal mitigation status of the sensor by type and name. 3 and higher is severe. See https://source.android.com/docs/core/power/thermal-mitigation#codes.Identify devices experiencing thermal throttling.

Memory Metrics

MetricDescriptionUsage
memory_pctAverage memory used by the system (0-100%), polled every 5 minutes by default.Track the average memory usage of the device.
memory_pct_maxMax memory used by the system (0-100%), polled every 5 minutes by default.Identify periods of high memory usage.

CPU Metrics

MetricDescriptionUsage
cpu_usage_pctAverage CPU usage in the system. Collected by parsing /proc/stat for the total ticks minus the idle ticks this period.Track the average CPU usage of the device.
cpu_usage_(.*)_pctAverage CPU usage in the system, for the app/process. Collected by parsing /proc/<pid>/stat/ for system and user time (stime + utime) divided by the total usage (sum of all fields from /proc/stat).Identify periods of high CPU usage.

Disk Wear Metrics

MetricDescriptionUsage
disk_wear.(.*).versionFlash EMMC/UFS version, as reported by the vendor implementation.
disk_wear.(.*).pre_eolPre-EOL information, overall status of consumed reserved blocks.Track the disk wear of the device. Preemptively account for issues with failing flash.
disk_wear.(.*).lifetime_remaining_pctEstimate of how much of the type A flash is remaining, in increments of 10%.Track the disk wear of the device. Preemptively account for issues with failing flash.
disk_wear.(.*).lifetime_b_remaining_pctEstimate of how much of the type B flash is remaining, in increments of 10%.Track the disk wear of the device. Preemptively account for issues with failing flash.
disk_wear.(.*).bytes_writtenCount of bytes written to the (virtual) device.Identify periods of high disk wear on the device.

Telephony Metrics

MetricDescriptionUsage
phone.imeiThis device’s IMEI number, if it exists. Collected via TelephonyManager.
batterystats metrics

Batterystats is periodically parsed and displayed in HRT according to the output code from the batterystats source.

Some Batterystats metrics are aggregated so they can also be used in Heartbeats for Fleet-wide insights.

MetricDescriptionUsageHRT only
wakelockBatteryStats “w” key.✔️
cpu_runningBatteryStats “r” key.✔️
cpu_running_ratioPercent (0-1%) of time the CPU was running.Segment battery drain investigations by CPU activity.
cpu_resume_count_per_hourCPU resume rate (per hour).
cpu_suspend_count_per_hourCPU suspend rate (per hour).
battery_levelBatteryStats “Bl” key.✔️
battery_level_pct_avgAverage battery level this heartbeat. Calculated as the arithmetic average of all battery level readings.
battery_charge_rate_first_80_percent_pct_per_hour_avgCharging rate (% per hour), while the battery level is under 80% to exclude trickle charging.Track the rate of charge.
battery_temperatureBatteryStats “Bt” key.✔️
max_battery_tempMax reading of the Battery temperature.
battery_voltageBatteryStats “Bv” key.✔️
min_battery_voltageMinimum reading of the Battery voltage.Identify periods of low battery voltage. Indicates battery undervoltage or battery miscalibration issues.
battery_coulomb_chargeBatteryStats “Bcc” key.✔️
battery_healthBatteryStats “Bs” key. One of: Good, Overheat, Dead, OverVoltage, Failure, Cold.✔️
battery_health_not_good_ratioPercent (0-1%) of time spent outside of the “Good” Battery Health state.Identify devices with battery problems.
battery_statusBatteryStats “Bs” key.✔️
battery_charge_duration_msAmount of time spent in the "Charging” Battery Status state.
battery_discharge_duration_msAmount of time spent in the "Discharging” Battery Status state.
battery_plugBatteryStats “Bp” key.✔️
battery_pluggedBatteryStats “BP” key.✔️
chargingBatteryStats “ch” key.✔️
audioBatteryStats “a” key.✔️
audio_on_ratioPercent (0-1%) of time spent with Audio active.Segment battery drain investigations by audio activity.
cameraBatteryStats “ca” key.✔️
videoBatteryStats “v” key.✔️
sensorBatteryStats “s” key.✔️
gps_onBatteryStats “g” key.✔️
gps_on_ratioPercent (0-1%) of time spent with GPS active.Segment battery drain investigations by GPS activity.
gps_signal_strengthBatteryStats “Gss” key.✔️
screen_onBatteryStats “S” key.✔️
screen_on_ratioPercent (0-1%) of time spent with Screen on.Segment battery drain investigations by Screen use.
screen_brightnessBatteryStats “Sb” key.✔️
screen_brightness_light_or_bright_ratioPercent (0-1%) of time spent with the Screen Brightness at Light or Bright (40% of the maximum brightness, 5 buckets).Segment battery drain investigations by Screen brightness.
wifi_onBatteryStats “W” key.✔️
wifi_on_ratioPercent (0-1%) of time spent with the Wi-Fi on.Segment battery drain investigations by Wi-Fi activity.
wifi_full_lockBatteryStats “Wl” key.✔️
wifi_scanBatteryStats “Ws” key.✔️
wifi_scan_ratioPercent (0-1%) of time spent with the Wi-Fi scanning.Segment battery drain investigations by Wi-Fi activity.
wifi_multicastBatteryStats “Wm” key.✔️
wifi_radioBatteryStats “Wr” key.✔️
wifi_radio_active_ratioPercent (0-1%) of time spent with Wi-Fi radio active.Segment battery drain investigations by Wi-Fi activity.
wifi_runningBatteryStats “Ww” key.✔️
wifi_signal_strengthBatteryStats “Wss” key.✔️
wifi_signal_strength_poor_or_very_poor_ratioPercent (0-1%) of time spent with the Wi-Fi signal strength at “Poor” or “Very Poor” (40% of the minimum strength, 5 buckets).Identify periods of poor network reliability. Segment battery drain investigations by Wi-Fi activity.
wifi_supplicantBatteryStats “Wsp” key.✔️
power_saveBatteryStats “ps” or “lp” key.✔️
dozeBatteryStats “di” key.✔️
doze_full_ratioPercent (0-1%) of time spent with the Device Idle state at “Full”. Segment battery drain investigations by Doze.
doze_ratioPercent (0-1%) of time spent with the Device Idle state at “Full” or “Light”. Segment battery drain investigations by Doze.
userBatteryStats “Eur” key.✔️
user_foregroundBatteryStats “Euf” key.✔️
jobBatteryStats “Ejb” key.✔️
package_installBatteryStats “Epi” key.✔️
package_uninstallBatteryStats “Epu” key.✔️
device_activeBatteryStats “Eac” key.✔️
bluetooth_le_scanningBatteryStats “Etp” key.✔️
bluetooth_scan_ratioPercent (0-1%) of time spent with the Bluetooth scanning.Segment battery drain investigations by Bluetooth activity.
phone_radioBatteryStats “Pr” key.✔️
phone_radio_active_ratioPercent (0-1%) of time spent with the Phone radio active.Segment battery drain investigations by Phone activity.
phone_connectionBatteryStats “Pcn” key.✔️
phone_in_callBatteryStats “Pcl” key.✔️
phone_scanningBatteryStats “Psc” key.✔️
phone_scanning_ratioPercent (0-1%) of time spent with the Phone radio scanningSegment battery drain investigations by Phone activity.
phone_signal_strengthBatteryStats “Pss” key.✔️
phone_signal_strength_none_ratioPercent (0-1%) of time spent with the Phone radio signal strength at “None”.Identify periods of poor network reliability.
phone_signal_strength_poor_ratioPercent (0-1%) of time spent with the Phone radio signal strength at “Poor”.Identify periods of poor network reliability.
phone_stateBatteryStats “Pst” key.✔️
top_appBatteryStats “Etp” key.✔️
foregroundBatteryStats “Efg” key.✔️
longwakeBatteryStats “Elw” key.✔️
alarmBatteryStats “Eal” key.✔️
startBatteryStats “START” or “SHUTDOWN”.✔️
screen_dozeBatteryStats “Sd” key.✔️
flashlightBatteryStats “fl” key.✔️
bluetoothBatteryStats “b” key.✔️
usb_dataBatteryStats “Ud” key.✔️
cellular_high_tx_powerBatteryStats “Chtp” key.✔️
nr_stateBatteryStats “nrs” key.✔️

Installed App Versions

The Android SDK can collect installed app versions as metrics. These can be configured on the Memfault Settings Dashboard, on the Data Sources tab, by entering package names to collect:

Installed app versions configuration

Wildcards can be used, to collect multiple apps sharing the same package root.

Each collected version is stored as a Metric, prefixed with version.:

Installed app versions metric

These metrics would be good candidates for Attributes, to enable e.g. searching for devices with a given app version installed, or checking the installed versions on a specific device.

System Properties

The Android SDK can collect Android System Properties. These can be configured on the Memfault Settings Dashboard, on the Data Sources tab, by entering each property to collect:

System Properties configuration

Each collected property is stored as a metric, prefixed with sysprop.:

System Properties metric

These metrics would be good candidates for Attributes, to enable e.g. searching for devices with a given system property, or checking the properties for a specific device.

info

persist.sys.timezone is collected by default. This is used in the Memfault dashboard to enable browsing in the device's time zone (ro.build.type is also collected by default).