Serial log collector and uploader
Project description
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file metsuri-0.5.0.tar.gz.
File metadata
- Download URL: metsuri-0.5.0.tar.gz
- Upload date:
- Size: 15.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
93154d5516bc8de19d2e95f0d9fc1cc191e80c704f29c6d01949953d46486075
|
|
| MD5 |
291cf245390cad948335f276d249a2ac
|
|
| BLAKE2b-256 |
5d7679da46bd128f47071c44ffc223269b824aa823f5289c28e512ba3002fdab
|
File details
Details for the file metsuri-0.5.0-py3-none-any.whl.
File metadata
- Download URL: metsuri-0.5.0-py3-none-any.whl
- Upload date:
- Size: 14.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cdcc86eb83dd1892883ae09e0efd475eb301f01b8926ab59f8c251e1ab599200
|
|
| MD5 |
c3f7cb6ecac230d9ab5a9319cc43a8c7
|
|
| BLAKE2b-256 |
03f2b92da17fc9d18628d265fd54a5a55b324b7687d84b1e14ac9f5e6e3873bd
|