Real-Time Embedded Linux Observability with Pantavisor and InfluxDB

Navigate to:

This article was originally published on HackMD and is reposted here with permission.

Presently organizations are unable to monitor millions of embedded Linux devices in real-time. With so many different architectures and device types, aggregating telemetry and metrics and viewing that data in a centralized analysis tool is problematic.

Onboarding embedded Linux devices into a telemetry service so that metrics can be easily observed is a significant challenge. But now you can automatically and quickly onboard large IoT fleets with Pantavisor-powered devices, and InfluxDB’s Telegraf plugin, and stream metrics to a centralized monitoring dashboard with minimal effort.

This post describes how to onboard and configure devices for the Telegraf plugin service to monitor Pantavisor-powered embedded Linux fleets. Device onboarding is streamlined and fast with a single sign-on process where Pantacor Hub automatically acquires InfluxDB credentials.

Telegraf and Pantacor Hub overview

Telegraf is an open-source server agent that collects telemetry and other metrics from your stacks, sensors, and systems. Pantacor Hub is our open source SaaS for remote device firmware and software lifecycle management and cloud service integration.

We containerized the telegraf plugin and made it available as a service from Pantacor Hub. Telegraf sends metrics to any InfluxDB server, including on-premise, cloud, or hosted. In this guide, we’ll use the cloud service for InfluxDB found at https://cloud2.influxdata.com/.

Telegraf and Pantacor Hub overview

How to integrate Pantavisor-enabled devices with InfluxDB

1. Create a Pantacor Hub account

Go to https://hub.pantacor.com/signup and follow the steps to create an account.

2. Flash a new device with Pantavisor

Next, select the image for the device you are using from https://hub.pantacor.com/download-image.

Download Pantavisor image

For a Raspberry Pi 3 or a Raspberry Pi 4, the recommended image is the arm-rpi64 (pantahub-ci/rpi64_initial_stable).

After downloading the image, flash it onto your device with either the Raspberry Pi Imager or the Balena Etcher.

Your device will now have Pantavisor running on it. Once the device boots, you will be able to see it in the device list on the Pantacor Hub dashboard.

Note: If your Raspberry Pi is not connected directly via an ethernet cable to the Internet, you will need to configure the WiFi connection through our captive portal before you can connect to Pantacor Hub.

See, Booting a Pantavisor-enabled device and Setting up a WiFi Portal for more information.

3. Install PVR-CLI

The PVR command line interface enables you to manage your device by installing new containers as well as many other operations.

Instructions on how to install PVR are here:

You can also watch this video to guide you through the process: https://youtu.be/yyohtCcxtog

4. Create an account at InfluxDB

Go to cloud2.influxdata.com and follow the steps to create an account.

5. Create an InfluxDB API Token for Pantacor Hub

Once inside the InfluxDB UI, select the left menu item “Load Data” and then “API TOKENS”. Create a new token by selecting “All access API token”. Set a description (like: “pantacor hub”) and then copy the token and save it in a safe place.

Create an InfluxDB API Token for Pantacor Hub

Generate All Access API Token

6. Setup Influx to receive the device data

For InfluxDB to save the device data, we need to create a bucket and specify values for the data from all the devices in your account.

Because Pantavisor is just a Linux system you can use the Linux System template from InfluxDB at:

https://github.com/influxdata/community-templates/tree/master/linux_system

To implement the template, go to Settings - Templates and add this one:

https://raw.githubusercontent.com/influxdata/community-templates/master/linux_system/linux_system.yml

Click Lookup Template and it automatically sets up everything it needs.

Click Lookup Template to automatically set up everything

7. Connect your InfluxDB account to your Pantacor account

Next, connect the InfluxDB token to your Pantacor Hub account. To accomplish that, we’ll use the sm.pantacor.com application.

This app enables you to connect and set up the necessary user-meta (or the configuration parameters in Pantacor Hub) for your devices after connecting to InfluxDB.

Go to sm.pantacor.com and log in with your Pantacor account credentials. Next, select Connected services from the menu to add a new service and fill in the following fields.

  • Name of service: InfluxDB Cloud Server (this is for description purposes only and can be anything)
  • API URL: This URL will vary depending on the server you chose when you created your InfluxDB account. You can find the URL in your signup email by looking in the Organization Settings for “Cluster URL (Host Name)”. The URL should look something like this: https://us-east-1-1.aws.cloud2.influxdata.com
  • Token: You will put here the token created in the previous step.
  • Secret: This will remain empty since InfluxDB doesn’t use a secret.
  • UserMeta JSON: This is a set of initial values to be injected into the configuration of the device.

You will also need the Organization ID from InfluxDB. This is found in the Organization Settings (same place as the API URL) as Organization ID.

Organization Settings

After adding those values, we will write a JSON file similar to this:

{"bucket": "telegraf", "org": "34655d0049224811"}

8. Install the Telegraf container with PVR

First, locate the device from the hub.pantacor.com dashboard and copy the CLONE URL from the device summary. The URL will look similar to this:

Install the Telegraf container with PVR

https://pvr.pantahub.com/highercomve/one_marketplace_development

Once you have the device CLONE URL, you can install the telegraf container and its configuration with:

DESTINATION_CLONE_URL="YOUR CLONE URL"
pvr fcp https://pvr.pantahub.com/asacasa/telegraf_arm64v8#telegraf,_config/telegraf ${DESTINATION_CLONE_URL}#telegraf,_config/telegraf

This command copies all of the configuration files and the telegraf container to your device. A new revision will also be created, which you can view in the dashboard at hub.pantacor.com.

After the new revision is DONE or UPDATED, you have everything you need to view the device metrics and to monitor them with InfluxDB.

view the device metrics

9. Monitoring devices with InfluxDB

Now that you have the telagraf container installed, go to the InfluxDB dashboard to view your device monitoring information.

Go to Dashboards - Linux System

And now you can enjoy your new device metrics!

Monitoring devices with InfluxDB

Final thoughts

This post described how to set up embedded Linux devices to work with Telegraf and InfluxDB to stream metrics for real-time monitoring.

If you have any questions or comments, reach out to us on our community forum at https://community.pantavisor.io

Refer to our websites for more information on Pantavisor and Pantacor blog