Skip to main content

Android Built-in Metrics

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

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, can be done 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), if desired. Note that Memfault will automatically configure certain metrics as Timeseries or Attributes and set a value range upon creation, but these defaults can changed in the same view.

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

Memfault also supports recording custom metrics using Memfault's Reporting API. This enables capturing domain specific metrics that Memfault wouldn't know about otherwise. All built-in metrics are captured using the same Memfault Reporting API.

Collected via HRT since Android SDK 4.5.0

Since Android SDK 4.5.0, battery metrics on timeline are displayed using High-Resolution Telemetry (note: this is behind a feature flag which is being rolled out progressively to devices running 4.5.0 or higher).

Several new metrics were added to timeline as part of this change — these are only available when collecting via HRT:

  • Wi-Fi On
  • User (current active user on multi-user devices)
  • Foreground User (current foreground user on multi-user devices)
  • Job (adds job identifier)
  • Package Install (shows all PackageManager installs, with package and version)
  • Package Uninstall (show all PackageManager uninstalls, with package and version)

Collected Since Android SDK 3.0

The Android SDK collects metrics from the Android batterystats subsystem. This includes data from many components which may affect battery usage (Radio, Wi-Fi, Bluetooth, Screen, CPU, GPS), in addition to statistics about the battery itself.

These metrics are displayed on the device timeline:

batterystats metrics

And several summary metrics are also available. Each metric is listed below, noting the batterystats output code that it is derived from (they are defined in the batterystats source):

MetricDescriptionBatterystats Key
audio_on_ratioPercentage of time (0.0-1.0) audio was switched on.a
battery_discharge_rate_pct_per_hour_avgPercentage drop (-100-0) per-hour, when discharging.N/A
battery_health_not_good_ratio

Percentage of time (0.0-1.0) when the battery health was not "good".

Bh
battery_level_pct_avgMean battery level (0-100).N/A
bluetooth_scan_ratioPercentage of time (0.0-1.0) with bluetooth LE scanning active.bles
cpu_running_ratioPercentage of time (0.0-1.0) CPU was running.r
cpu_resume_count_per_hourNumber of times per hour CPU became active.r
cpu_suspend_count_per_hourNumber of times per hour CPU became inactive.r
cpu_wake_count_per_hourNumber of individual CPU wakeups.wr
doze_full_ratioPercentage of time (0.0-1.0) spent in full Doze mode.di
doze_ratio

Percentage of time (0.0-1.0) spent in any (full or light) Doze mode.

di
gps_on_ratioPercentage of time (0.0-1.0) GPS was switched on.g
max_battery_tempMaximum battery temperature (°C x 10) during the period.Bt
phone_radio_active_ratio

Percentage of time (0.0-1.0) the phone radio was active (see batterystats Pr).

Pr
phone_scanning_ratioPercentage of time (0.0-1.0) the phone was scanning.Psc
phone_signal_strength_none_ratio

Percentage of time (0.0-1.0) the phone signal strength was "none" (0).

Pss
phone_signal_strength_poor_ratio

Percentage of time (0.0-1.0) the phone signal strength was "poor" (1).

Pss
screen_on_ratioPercentage of time (0.0-1.0) the screen was on.S
screen_brightness_light_or_bright_ratio

Percentage of time (0.0-1.0) the screen brightness was "light" ( 3) or "bright" (4).

Sb
wifi_on_ratioPercentage of time (0.0-1.0) Wi-Fi was on.W
wifi_radio_active_ratioPercentage of time (0.0-1.0) Wi-Fi was on.Wr
wifi_running_ratioPercentage of time (0.0-1.0) Wi-Fi was on.Ww
wifi_scan_ratioPercentage of time (0.0-1.0) Wi-Fi was scanning.Ws
wifi_signal_strength_poor_or_very_poor_ratio

Percentage of time (0.0-1.0) Wi-Fi signal was "poor" (1) or "very poor" (0).

Wss

These metrics would be good candidates for Timeseries metrics, to monitor fleet performance over time and find outlier devices.

Battery Summary Metrics

Supported Since Android SDK 4.8.0

Android SDK 4.8.0 supports collecting new types of battery metrics, which show a summary of battery usage during the collection period:

Battery usage metrics
MetricDescription
screen_off_battery_drain_%/hour

The battery drain rate while the screen was off — useful for isolating battery drain rate from screen usage (0-100% per hour).

screen_on_battery_drain_%/hourThe battery drain rate while the screen was on (0-100% per hour).
estimated_battery_capacity_mahThe battery capacity reported by Android.
battery.charge_cycle_count.latest

Supported Since Android SDK 4.18.0

The total number of charge cycles reported by the battery (as reported to /sys/class/power_supply/battery/cycle_count, if supported on the device).

The above metrics are available for use as timeseries metrics.

Additionally, 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. This includes both Android OS components (e.g. cell, idle, android, screen, bluetooth, gnss) and applications (e.g. com.google.android.youtube, com.android.vending, com.whatsapp).
  • These per-component metrics are only displayed on timeline — they are not available as timeseries metrics.

Device Temperatures

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 1
    • temp_skin_0.max
    • temp_skin_0.mean
    • temp_skin_0.min
  • CPU Sensor 1
    • temp_cpu_0.max
    • temp_cpu_0.mean
    • temp_cpu_0.min
  • CPU Sensor 2
    • temp_cpu_1.max
    • temp_cpu_1.mean
    • temp_cpu_1.min

These metrics would be good candidates for Timeseries metrics, to monitor fleet performance over time and find outlier devices.

Storage Usage

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

MetricDescription
storage.data.bytes_free

File.getFreeSpace on the data directory.

storage.data.bytes_total

File.getTotalSpace on the data directory.

storage.data.bytes_used

The difference between storage.data.bytes_total and storage.data.bytes_free.

storage.data.percentage_used

The ratio of storage.data.bytes_used over storage.data.bytes_total.

These metrics would be good candidates for Timeseries metrics, to monitor fleet performance over time and find outlier devices.

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).

Connectivity Metrics

Collected Since Android SDK 4.4.0

The Android SDK collects metrics describing connectivity changes on the device:

MetricDescription
connectivity.type

The network transport, one of NONE, WIFI, CELLULAR, ETHERNET, BLUETOOTH, or UNKNOWN. This roughly matches the transport types returned from the Android NetworkCapabilities#hasTransport API.

Aggregate time in state by hour metrics for each type are also available, for example connectivity.type_CELLULAR.secs/hour.

airplane_modeBoolean for whether airplane mode is enabled.
connectivity.validated

Boolean for whether the current network has been validated for Internet.

connectivity.captive_portalBoolean for whether device is connected to a captive portal.

Network Usage Metrics

Collected Since Android SDK 4.15.0

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

MetricDescription
network.total.in.allTotal incoming network usage (KB).
network.total.out.allTotal outgoing network usage (KB).

Updated In Android SDK 4.15.0

The Android SDK will also record network usage stats 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.

MetricDescription
network.total.in.btTotal incoming Bluetooth network usage (KB).
network.total.out.btTotal outgoing Bluetooth network usage (KB).
network.total.in.ethTotal incoming Ethernet network usage (KB).
network.total.out.ethTotal outgoing Ethernet network usage (KB).
network.total.in.mobileTotal incoming Mobile network usage (KB).
network.total.out.mobileTotal outgoing Mobile network usage (KB).
network.total.in.wifiTotal incoming Wi-Fi network usage (KB).
network.total.out.wifiTotal outgoing Wi-Fi network usage (KB).

The Android SDK will also collect per-app network usage for every app on device that exceeds the specified threshold (1MB by default). These are only visible in HRT, on the device timeline.

MetricDescription
network.app.in.bt_com.mypackage.nameIncoming Bluetooth network usage (KB) for the app.
network.app.out.bt_com.mypackage.nameOutgoing Bluetooth network usage (KB) for the app.
network.app.in.eth_com.mypackage.nameIncoming Ethernet network usage (KB) for the app.
network.app.out.eth_com.mypackage.nameOutgoing Ethernet network usage (KB) for the app.
network.app.in.mobile_com.mypackage.nameIncoming Mobile network usage (KB) for the app.
network.app.out.mobile_com.mypackage.nameOutgoing Mobile network usage (KB) for the app.
network.app.in.wifi_com.mypackage.nameIncoming Wi-Fi network usage (KB) for the app.
network.app.out.wifi_com.mypackage.nameOutgoing Wi-Fi network usage (KB) for the app.

Fleet Sampling Aspect Metrics

Collected Since Android SDK 4.5.0

info

These are only collected for customers using Fleet Sampling.

The active Fleet Sampling resolution for each aspect can be shown over time if HRT is enabled. These can be seen on the device timeline for devices with the debugging aspect enabled.

MetricValue
debugging.resolution

OFF or NORMAL

monitoring.resolution

OFF or NORMAL

logging.resolution

OFF or NORMAL

Fleet-sampling attributes are also reported as Heartbeat metrics. These metrics are good candidates for device attributes (to search for devices by resolution) or timeseries metrics, and can seen with hourly resolution on timeline for devices with the monitoring aspect enabled.

MetricValue
debugging.resolution.latest

OFF or NORMAL

monitoring.resolution.latest

OFF or NORMAL

logging.resolution.latest

OFF or NORMAL