Skip to main content

Metsuri, a serial logger

Metsuri is a base component in a serial logging system. It makes it easy to monitor hardware that has an output that can be attached with, for example, a USB serial interface.

As the monitoring hardware you will need something that runs the necessary Python components. For example, a recent RaspberryPi will work splendidly. 16GB SD card is enough, probably a lot smaller will work, as the system tries to upload the data to the cloud as soon as it is received.

The system comprises three main components, serial-logger, log-uploader and log-download. The serial-logger attaches to a serial line and logs the received data to a file, rotating files with requested intervals, log-uploader uploads the received events to AWS CloudWatch, and you download the logs from the desired internal from the cloud with log-download.

It is possible to just log the data locally, but AWS CloudWatch makes it simple to share the updated logs with a team of people. It is also a very secure way to store the logs if the loggers are installed in a remote location.

Install needed packages

% sudo apt-get update
% sudo apt-get install picocom supervisor python3-venv

Create Python env

% python3 -m venv ve
% . ve/bin/activate
(ve) % pip install metsuri-*.whl

Copy supervisor config

% cd supervisord
% sudo cp *.conf /etc/supervisor/conf.d

Currently log_uploader.conf needs to be modified. Modify the command-line to use correct serial device, log group and log stream for the device. Each device should have its own log stream.

If you wish to test the configuration, you can attach the USB serial and call

% sudo supervisorctl reload

which will start services. Both services should end up in RUNNING when observed with

% sudo supervisorctl status

In case of problems, logs can be found under /var/log/supervisor/

Setup connection configuration for AWS

The device should include credentials to allow logging into a CloudWatch log stream.

The ~/.aws/config should include the [default] section to point out the correct region for the CloudWatch target. Alternatively, you can specify, for example, AWS_PROFILE environment variable among others. See AWS documentation for details.

[default]
output = json
region = eu-central-1

By default, the credentials are found in ~/.aws/credentials, and the location can be overridden with AWS_SHARED_CREDENTIALS_FILE environment variable.

Example /home/pi/.aws/credentials below.

[default]
aws_access_key_id=foo
aws_secret_access_key=bar

Fetching the logs from CloudWatch

In the following example we gather all logs from log stream with names starting with example from the log group EXAMPLE-LOG-GROUP downloading them to files in
output-log-dir.

This method reflects the state of the device logs exactly, but can be heavy with lots of stream or log entries. Use --interval command-line option to limit the amount of data, or specify a narrow time window with --from and --to.

AWS_SHARED_CREDENTIALS_FILE=creds log-download EXAMPLE-LOG-GROUP example output-log-dir

Metadata

Release files for metsuri 0.5.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for metsuri 0.5.0
File Size Uploaded Provenance Actions
metsuri-0.5.0.tar.gz 15.8 kB Without provenance Details for metsuri-0.5.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for metsuri 0.5.0
File Interpreter ABI Platform Actions
metsuri-0.5.0-py3-none-any.whl Python 3 none any Details for metsuri-0.5.0-py3-none-any.whl

Total release size: 30.1 kB

Release files / metsuri-0.5.0.tar.gz

Download URL metsuri-0.5.0.tar.gz
Size 15.8 kB
Tags Source
SHA-256 checksum
How to use checksums
93154d5516bc8de19d2e95f0d9fc1cc191e80c704f29c6d01949953d46486075
BLAKE2b-256 checksum
How to use checksums
5d7679da46bd128f47071c44ffc223269b824aa823f5289c28e512ba3002fdab
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.12.3

Release files / metsuri-0.5.0-py3-none-any.whl

Download URL metsuri-0.5.0-py3-none-any.whl
Size 14.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cdcc86eb83dd1892883ae09e0efd475eb301f01b8926ab59f8c251e1ab599200
BLAKE2b-256 checksum
How to use checksums
03f2b92da17fc9d18628d265fd54a5a55b324b7687d84b1e14ac9f5e6e3873bd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.12.3

Security for metsuri 0.5.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.5.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page