Golioth has just released a Grafana WebSocket Data Source plugin. This open source plugin allows you to create a graphic dashboard using data from any WebSocket URL that uses JSON formatting. This means you can you directly connect the Golioth Cloud API and have Grafana render incoming data in real time as graphs, charts, maps, etc.

Grafana Takes Care of Data Visualization

Temperature data display as graphs

Realtime data from Golioth devices looks great in Grafana!

Grafana is an open source visualization and analytics software from GrafanaLabs. It allows you to query, visualize, alert on, and understand your metrics no matter where they are stored. We chose Grafana because we heard it mentioned multiples times by our community members and found that it streamlines the process of managing device data and visualizing. You can build from source and run it locally (the power of open source), or use the free tier of the hosted Grafana Cloud platform.

We’re Going to Need WebSockets

At Golioth, we recently added WebSocket support for some of our services like Logs, LightDB State, and LightdDB Stream. Actaully, Chris wrote a blog post all about it. You can now connect to a WebSocket URL and get real-time data updates from your devices without the need to poll for updates like you would with a REST API.

As awesome as it is, Grafana didn’t have a WebSockets plugin, so we created one! It allows you to connect to any WebSocket URL and visualize the data in Grafana. You can get a copy of the WebSockets plugin code in our repo. But we have also submitted it as an official plugin – it should be available in Grafana soon!

Let’s Try the Demo!

Setting Up a Device to Send Data

As a hardware beginner, I followed one of our easiest samples using PlatformIO and our Arduino SDK to get my ESP32 board connected to our platform, see our examples folder on our Arduino SDK repo.

Note: The arduino-sdk repository showcased in this post is deprecated. GoliothLabs has an experimental repository that may work as a replacement:

I’m writing data on both of our services in a 5 seconds loop, updating my device’s state with LightDB State and reporting time series data for our LightDB Stream service.

// Every 5 seconds loop
...
  int core_temp = randomNumber(40, 60);
  int room_temp = randomNumber(27, 33);
  int uptime = millis() / 1000;
  String payload =
    "{
      \"core\":
        {
          \"temp\":" + String(core_temp) + ",
          \"uptime\":" + String(uptime) +
        "},
    \"room\":
      {
        \"temp\":" + String(room_temp) + "
      }
    }";
  
  client->setLightDBStateAtPath("/", payload.c_str());
  client->sendLightDBStream("/", payload.c_str());
...

This small program sends random numbers as core/room temperatures, and the device’s uptime. We have data, now let’s graph it!

Golioth’s WebSockets API

LightDB state data

Devices > Your Device > LightDB State

LightDB Stream Data

Monitor > LightDB Stream

WebSockets “listens” for changes, so every 5 seconds those updates on State and Stream are also available thru Golioth’s WebSocket API. We can follow the WebSockets docs to setup a connection to listen to them.

Below you can see how the WebSocket hosts URLs are formatted. Use the Golioth Console to find the projectId, deviceId, API key, and any paths you need. (This information is also available using the goliothctl command line tool.)

LightDB State

// Websocket URL format: wss://api.golioth.io/v1/ws/projects/{projectId}/devices/{deviceId}/data{/path=**}?{x-api-key|jwt}={API_KEY|JWT}

wss://api.golioth.io/v1/ws/projects/smart-house/devices/61d315e441da400dd6934493/data?x-api-key={projectApiKey}

LightDB Stream

// Websocket URL format: wss://api.golioth.io/v1/ws/projects/{projectId}/stream?{x-api-key|jwt}={API_KEY|JWT}

wss://api.golioth.io/v1/ws/projects/smart-house/stream?x-api-key={projectApiKey}

With those I was able to test the endpoint using websocat to make sure that the data my device was sending created notifications through the WebSocket connection as expected.

websocat command line tool used to test WebSocket feed

Grafana WebSocket Plugin Setup

For this demo I’m running everything locally (both Grafana and the Plugin itself), but we have submitted the signed plugin to Grafana’s Cloud so soon you will be able to find it there by default.

To use the plugin, there are a few configuration steps we need to follow:

  • Once you’ve logged into Grafana, go to the Configuration page (gear icon) and then to Plugins
  • Search for WebSocket API, select and then click on Create a WebSocket API data source

Now we fill in the fields as the API requires and hit save. For Golioth’s WebSocket API you can see I’ve entered the URL, and I’ve specified x-api-key and stored the API key that I generated on the Golioth Console.

Grafana WebSocket data source

Notice that I’m not using the full path, but only through the project level (smart-house). This way we can select the specific path we want to listen to later on the Panel’s Query page. This allows more flexibility.

Building the Dashboard that Shows the Data

With the data source set up, it’s time for us to build the query on an actual panel.

Something to keep in mind is that, right now, it will only listen to future events, so if there’s any update on the Query Field, Path, Panel or Dashboard, the current stored data will be wiped.

Graphing LightDB Stream:

  • Hover on the plus sign at the sidebar and select Dashboard
  • Then click on Add a new panel
  • Select WebSocket API under the Query’s data source
  • Go to Query A Path tab and fill with your desired path. In my case /stream

Grafana WebSockets path setting

  • Under Fields tab, use JSONPath reference to transform the JSON result into something that the dashboard can display. Here I’ve used $.result.data.timestamp, $..core.temp, and $..room.temp
  • I want to display the last 5 minute events of my device’s temperature, both for the core and room. So I changed the panel’s type into Time Series on the top right corner, and filled with the fields required:
  • Hit Save, and its done.

Grafana WebSockets field configuration

As long as data is streaming in from a device, it will be graphed in real time. One tip as you get used to handling data, try starting with Table View on to better understand the JSON by your query.

Displaying LightDB State

To create another panel for the LightDB State we can just duplicate the first one and update his its Path, so:

Grafana state data path configuration

There’s a small differences here, LightDB State can have deeper paths e.g. .../data/core/temp but they will only be notified via WebSockets when there’s an update on them. Because I want to listen to multiple path updates for this Panel, I will leave the path set to the root level, that is .../data.

Grafana state field queries

  • Transform the query fields to use $..core.temp and $..room.temp
  • Hit Save, and it’s another one done.

Final Results

Grafana state field queries

Like that, we have 2 panels ready to listen for updates coming from both LightDB Stream and State in real-time. Feel free to add more data and to listen to different State paths.

Conclusion

Grafana is an awesome tool that allows us to connect and create professional visualizations. Because it is open source, a major part of its improvement over time is a result of its community. We’re building an amazing platform at Golioth and we also want to empower our community with the freedom to build things they love with us. With WebSockets now available on our platform, we built this plugin to share that excitement with our users and with the entire world.

Hopefully you’ll give this a try, and we want your feedback! Get in touch with us on the Golioth Discord server and please join us there for our Office Hours every Wednesday at 10 am Pacific Time.

Welcome to the Dev Tier

Golioth, the straightforward commercial IoT development platform built for scale, is now generally available. This means that IoT deployments from one to one million devices can now join the platform, prototype new business concepts, and immediately scale.

We recently completed our “beta” program which was an opportunity to work with engaged hardware, firmware, and software developers. People who are building interconnected systems of hardware and cloud connectivity (AKA “IoT deployments”). We learned what this group needs on a daily and longer-term deployment basis and have refined the Golioth offering to better serve developers throughout the product development lifecycle. We now offer these services to the wider hardware development community with the click of a button.

For those just getting started, our “Dev” tier provides everything you need to evaluate and develop your proof of concept, all for free. What does that include?

  • Our open source Zephyr® SDK integrated with the Golioth Cloud
  • Support for 100+ hardware components, including the latest cellular nRF9160 from Nordic Semiconductor & the ESP32-C3 Wi-Fi SoC based on RISC-V from Espressif Systems
  • “Secure by Default” communication over an ultra-efficient protocols like CoAP
  • Access to powerful Device Services like:
    • Software updates that include secure boot and firmware management
    • A realtime NoSQL database, useful for creating Digital Twins and synchronization
    • A time-series database for storing and querying sensor data
    • A flexible logging system to collect OS & application status and troubleshoot from the field
  • A browser-based app to manage your fleet, as well as command line tools and RESTful APIs for automation
  • Community support via our Discord server and GitHub
  • Enough space to get your early deployment off the ground (see rates and limits)

For those ready to scale their product, we offer additional features including advanced reporting, white-glove service, and on-demand support.

Contact us at [email protected] about Pilots and beyond.

A brief recap of Golioth

New to Golioth? Here’s a quick overview of who we are, what we do, and the problems we’re solving.

What is Golioth?

First and foremost, Golioth is a cloud platform. We offer APIs in the form of “Device Services” and cloud processing for your IoT fleet. For developers, this means you can point their embedded devices at these endpoints on the web and have access to some really advanced capabilities.

Why build Golioth at all? We see product teams creating these same functions over and over again with their cloud teams, with no standardization and without flexibility across cloud providers. What’s worse, these features are tough to build until development teams grow to a certain size. With Golioth, we have standardized an offering of key services and make them available from day one of hardware development.

An IoT deployment is nothing without hardware, and we want to support as much choice as possible. That’s why we support our community by offering the Golioth SDK built on top of Zephyr®. This is a Real Time Operating System that makes it easy to implement the networking capabilities and get started quickly. There is support across hundreds of boards and platforms, so you can customize your hardware to fit your end customers’ needs. Zephyr® is flexible enough to allow switching between platforms, which is extra critical during the chip shortages in 2021 and beyond.

What are the problems we’re solving?

Complexity

The Golioth SDK is incredibly simple to set up with only 4 lines in a configuration file. Once you pull in the SDK, you not only get access to sample code to test our services, you get access to services built for hardware developers: The ability to troubleshoot, the ability to fix problems remotely, the ability to get readings from your devices, and more.

Lock-In

2021 has been a challenging year for sourcing hardware. Building on top of an open source Real Time Operating System (RTOS) like Zephyr® allows much needed flexibility. By abstracting away some of the hardware specificity, you gain access to a wide range of devices and types of connectivity. The Golioth Device Catalog shows a range of hardware already tested with Golioth services and many more devices that will be supported soon.

Security

Your IoT deployment is secure from the first packet you upload to the Golioth cloud. All devices use a flexible, yet secure DTLS protocol with Pre-Shared Key authentication. The data you push from your device to the cloud will be encrypted and easily authenticated and decoded in the Golioth cloud. Our REST API uses OAuth 2.0 for authorization and web side access to the Golioth cloud conforms to industry best practices. Hardware and firmware developers can prototype within minutes, and the rest of their team will trust the incoming data from a trusted data pipeline such as Golioth. Pushing firmware updates back down to the device are also secure by default, passing signed images over an encrypted connection down to each device.

Continuous Improvement

At Golioth, we strive to continuously improve our offering for developers and their IoT deployments. What’s more, we actively engage with our community to find out what will make it more straightforward to deploy devices out into the world. Top requested features under development include security certificates, MQTT, WebSockets, with even more on the long-term roadmap.

Long Term Support

After our first year of operation, we have seen the pain that IoT companies of all sizes experience. But in this final point about who we are and what we do, we want to emphasize our support for you, the developer, and the company deploying IoT devices. We offer community-based support as part of all tiers, including the Dev Tier. For those who need or desire more hands-on support, we have white-glove service for our Pilot customers (reach out to us if this is you!). With Golioth, your IoT deployment will not only be easier to get off the ground, it will also have the ability to scale across devices, across divisions in your company, and across the globe.

Are you ready to build?

Golioth is ready for your next IoT deployment. We can help you to connect an older industrial product, your brand new asset tracker, or help you to deploy a never-before-seen device. See how Golioth speeds up development and increases the chances that your next pilot hardware will be put into production. Get started today for free with Golioth’s brand new Dev Tier.

Get started today

Sign up:

Follow us:

In September 2022, Golioth launched Account Management and Self Service Upgrades. When you’re ready to scale your fleet past 50 devices in the Dev Tier, you can upgrade your account with a couple of clicks.

Today, we’re excited to announce our $2.5 million Seed funding led by Zetta Venture Partners, with participation from additional investors including Chris Aniszczyk (CTO of CNCF), Sam Ramji (CSO of Datastax), Shiva Rajaraman (VP Commerce at Facebook and former CTO WeWork), and Stephen Blum (CTO of PubNub). We’re also opening up Golioth to beta testers and are proud to share that we’ve joined the Zephyr™ Project as a Silver Member.