Reference: memfaultd Configuration
Useful links:
Basic Usage
Running memfaultd --help
prints the following:
Usage: memfaultd [OPTION]...
--config-file <file> : Configuration file
--daemonize : Daemonize process
--enable-data-collection : Enable data collection, will restart the main memfaultd service
--disable-data-collection : Disable data collection, will restart the main memfaultd service
-h, --help : Display this help and exit
-s, --show-settings : Show settings
-v, --version : Show version information
The --config-file
path defaults to /etc/memfaultd.conf
. The settings you add
in /etc/memfaultd.conf
extend the built-in configuration
file.
As of v1.2.0, we recommend using memfaultctl
to
enable/disable data collection and view current settings.
--(enable|disable)-data-collection
and --show-settings
are still present on
memfaultd
for backwards compatibility but will be removed in a future major
version of the SDK.
Usage in a systemd
service
The meta-memfault
Yocto layer already includes a
service file, so you don't need to add one if you're using meta-memfault
.
You can use the --daemonize
flag for this. See this example, taken from the
meta-memfault
layer:
[Unit]
Description=memfaultd daemon
After=local-fs.target network.target
Before=swupdate.service collectd.service
[Service]
Type=forking
PIDFile=/run/memfaultd.pid
ExecStart=/usr/bin/memfaultd --daemonize
Restart=on-failure
[Install]
WantedBy=multi-user.target
The Before=
parameter is there to ensure memfaultd
starts before
swupdate.service
as well as collectd.service
. The configuration files used
by these daemons are generated (at least partly) by memfaultd
at startup, and
need to be present before the respective services start.
If you're not using OTA or Metrics, you may remove
the corresponding part of the Before=
parameter. You may also wish to opt out
of building the plugins with memfaultd
.
/etc/memfaultd.conf
A full configuration example can be found in the source directory of
memfaultd
. Here's a copy:
{
"queue_size_kib": 1024,
"refresh_interval_seconds": 3600,
"enable_data_collection": false,
"enable_dev_mode": false,
"software_version": "<YOUR_SOFTWARE_VERSION>",
"software_type": "<YOUR_SOFTWARE_TYPE>",
"project_key": "<YOUR_PROJECT_KEY>",
"base_url": "https://device.memfault.com",
"data_dir": "/media/memfaultd",
"swupdate_plugin": {
"input_file": "/etc/swupdate.cfg",
"output_file": "/tmp/swupdate.cfg"
},
"reboot_plugin": {
"last_reboot_reason_file": "/media/last_reboot_reason",
"uboot_fw_env_file": "/etc/fw_env.config"
},
"collectd_plugin": {
"footer_include_output_file": "/tmp/collectd-footer-include.conf",
"header_include_output_file": "/tmp/collectd-header-include.conf",
"interval_seconds": 3600,
"non_memfaultd_chain": "",
"write_http_buffer_size_kib": 64
},
"coredump_plugin": {
"coredump_max_size_kib": 96000,
"rate_limit_count": 5,
"rate_limit_duration_seconds": 3600,
"storage_max_usage_kib": 0,
"storage_min_headroom_kib": 10240
},
"fluent-bit": {
"extra_fluentd_attributes": [],
"bind_address": "127.0.0.1:5170",
"max_buffered_lines": 1000,
"max_connections": 4
},
"logs": {
"rotate_size_kib": 10240,
"rotate_after_seconds": 3600,
"tmp_folder": "tmplogs"
}
}
The settings you add in /etc/memfaultd.conf
extend the built-in configuration
file.
Top-level /etc/memfaultd.conf
configuration
Field | Description | Recommended value |
---|---|---|
queue_size_kib | Size of $data_dir/queue in kibibytes. | 1024 |
refresh_interval_seconds | The frequency (in seconds) with which memfaultd will attempt to flush its queue and post it to Memfault. Note that a recovery system with exponential back-off is in place for network failures. | 3600 |
enable_data_collection | Whether memfaultd should collect and post data to Memfault by default. Read more here. | false (ask for user consent first) |
enable_dev_mode | Change memfaultd default settings for development. Read more here. | false (only use in development) |
base_url | The base URL to Memfault's device API. | https://device.memfault.com |
software_version | The current version of your software. Read more here. | Project-specific |
software_type | The current version of your software. Read more here. | Project-specific |
project_key | A write-only key for your Project. Find yours in Project -> Settings in the app. | Project-specific |
data_dir | A directory where memfaultd can store application data persistently (needs to survive firmware upgrades). Read more here. | Project-specific |
swupdate_plugin | Configuration values for plugin_swupdate if enabled in memfaultd (default). Read more. | See swupdate_plugin |
reboot_plugin | Configuration values for plugin_reboot if enabled in memfaultd (default). Read more. | See reboot_plugin |
collectd_plugin | Configuration values for plugin_collectd if enabled in memfaultd (default). Read more. | See reboot_plugin |
coredump_plugin | Configuration values for plugin_coredump if enabled in memfaultd (default). Read more. | See coredump_plugin |
swupdate_plugin
{
"swupdate_plugin": {
"input_file": "/etc/swupdate.cfg",
"output_file": "/tmp/swupdate.cfg"
}
}
Field | Description | Recommended value |
---|---|---|
input_file | Will be used as the base SWUpdate configuration when generating $output_file . May specify a suricatta section (gets merged with generated parameters). If an identify section exists it will get replaced. See upstream SWUpdate docs. | /etc/swupdate.cfg |
output_file | Generated by memfaultd using $input_file as a base. Needs to be passed to SWUpdate as its config file. See an example here. | /tmp/swupdate.cfg |
reboot_plugin
{
"reboot_plugin": {
"last_reboot_reason_file": "/media/last_reboot_reason",
"uboot_fw_env_file": "/etc/fw_env.config"
}
}
Field | Description | Recommended value |
---|---|---|
last_reboot_reason_file | The path where memfaultd 's reboot reason tracking plugin will attempt to find the device-specific reboot reason. If the file does not exist, memfaultd will interpret this as "no device specific reason known". | Project-specific |
uboot_fw_env_file | Path to a valid fw_env.config file. See the SWUpdate dependency of Reboot Reason Tracking for more information. Read about libubootenv and see an example. | /etc/fw_env.config |
collectd_plugin
{
"collectd_plugin": {
"footer_include_output_file": "/tmp/collectd-footer-include.conf",
"header_include_output_file": "/tmp/collectd-header-include.conf",
"interval_seconds": 3600,
"non_memfaultd_chain": "",
"write_http_buffer_size_kib": 64
}
}
Field | Description | Recommended value |
---|---|---|
footer_include_output_file | Generated by memfaultd . Needs to be Include d in the main collectd.conf as the last statement. | /tmp/collectd-footer-include.conf |
header_include_output_file | Generated by memfaultd . Needs to be Include d in the main collectd.conf as the first statement. | /tmp/collectd-header-include.conf |
non_memfaultd_chain | An optional collectd chain to jump to after the Memfault-generated chain. Read more here. | Project-specific |
write_http_buffer_size_kib | Size of the collectd in-memory write buffer. Read more here. | 64 |
interval_seconds | Governs collectd's Interval and the FlushInterval setting of the write_http plugin. Read more here. | 3600 |
coredump_plugin
{
"coredump_plugin": {
"compression": "gzip",
"coredump_max_size_kib": 96000,
"rate_limit_count": 5,
"rate_limit_duration_seconds": 3600,
"storage_max_usage_kib": 0,
"storage_min_headroom_kib": 10240
}
}
To configure the location where coredumps are stored during processing, see
data_dir
.
Field | Description | Recommended value |
---|---|---|
compression | Compression to use when storing on disk and uploading to Memfault (none or gzip ). | gzip |
coredump_max_size_kib | The maximum size of a coredump that can be processed. | 96000 |
rate_limit_count * | The maximum amount of coredumps to process in a given period of rate_limit_duration_seconds . | 5* |
rate_limit_duration_seconds * | A window in which a maximum of rate_limit_count coredumps can be processed. | 3600* |
storage_max_usage_kib | A maximum of disk space to use for the purposes of coredump processing. | Project-specific |
storage_min_headroom_kib | A minimum of disk space to leave unused in disk while processing a coredump. | Project-specific |
* Please consult with the Memfault team if you need to change rate-limiting settings for your integration, as the Memfault Web App will further enforce rate limiting rules.
When a program crashes, the kernel will attempt to produce a coredump for the
crashing process. When memfaultd
receives the coredump, it will first apply
the rate limiting policy, to limit the number of coredumps that can get
generated within a period of time. If the rate limit is exceeded, the coredump
is dropped.
Next, memfaultd
will determine the maximum size that is allowed, based on the
coredump_max_size_kib
, storage_max_usage_kib
and storage_min_headroom_kib
configuration values and the amount of available storage space.
Unless there is no available storage, the coredump is written into a temporary
holding area inside the data_dir
.
Finally, the coredump is added to the upload queue. This queue is serviced
periodically (see the top-level refresh_interval_seconds
).
fluent-bit
{
"fluent-bit": {
"extra_fluentd_attributes": [],
"bind_address": "127.0.0.1:5170",
"max_buffered_lines": 1000,
"max_connections": 4
}
}
Field | Description | Recommended value |
---|---|---|
extra_fluentd_attributes | List of fluentd attributes to save beyond the defaults | [] |
bind_address | Address and port to bind the fluent-bit listener to. Replacing 127.0.0.1 by 0.0.0.0 will open the log collection service to the network (not recommended). | 127.0.0.1:5170 |
max_buffered_lines | Maximum number of lines to buffer in memory before applying backpressure to fluent-bit. | 10000 |
max_connections | Maximum number of simultaneous connected sockets with fluent-bit. | 4 |
logs
{
"logs": {
"rotate_size_kib": 10240,
"rotate_after_seconds": 3600,
"tmp_folder": "tmplogs"
}
}
Field | Description | Recommended value |
---|---|---|
rotate_after_seconds | Log files will be rotated when they reach this number of seconds. | 3600 |
rotate_size_kib | Log files will be rotated when they reach this size (in kibibytes). | 10240 (10 MiB) |
tmp_folder | Where to store logfiles while they are being written. If this path does not start with a / , it will be relative to the data_dir . | tmplogs (so {data_dir}/tmplogs ). |
mar
{
"mar": {
"storage_max_usage_kib": 102400
}
}
Field | Description | Recommended value |
---|---|---|
storage_max_usage_kib | Maximum disk space used by memfaultd for MAR entries. | 102400 (100 MiB) |
memfaultd
will transform log files into MAR entries on disk and keep them in
the MAR staging area until they are uploaded.
Older entries will be deleted automatically to keep the total size smaller than
storage_max_usage_kib
.