How to use AI to analyze and visualize CAN data with Grafana Assistant
Summary
My data source contains data from a Kia EV6 electric car, recorded with a CANedge CAN bus data logger with device ID 2A896980. The data includes battery data from the EV and GPS/IMU data from a sensor module. I want to know the following:
1: What tables and columns are available for this device?
2: What time period does the data span? Grafana Assistant starts analyzing the data via multiple queries, summarizing the results in a tabular form, and in the chat. Notice how the LLM iterates through multiple queries to understand the data structure. You can of course inspect what queries are used to generate each result, ensuring full transparency. The summary provides us with a good starting point for further investigation. Example 2: Explore data ad hoc In many cases you’ll want to explore the data directly in the chat window prior to creating actual panels. Here, Grafana Assistant runs the relevant queries and produces the output in-chat as text or as plots. We can also prompt the LLM to create a panel that displays speed over time within our dashboard, which Grafana does successfully as shown below. Copy Prompt:
What is the average speed from the CAN2_GnssSpeed message in July 2023? It's in m/s. Please create a panel in this dashboard to visualize the average speed over time Example 3: Create dashboard via a high-level prompt An obvious use case for Grafana Assistant is to create a new dashboard from scratch. In this example we try a minimal-effort prompt���leaving a lot up to the imagination of the LLM. The result is a functional 12-panel dashboard where all SQL queries are as expected (i.e., as per our system prompt guidance). Notice in particular that the LLM proactively identifies available (and relevant) messages/signals. Pretty cool! It’s worth reflecting on how commoditized LLMs + tools have already become. If this was 2022 we’d have been blown away. However, the dashboard we get is highly inconsistent between re-runs of the same prompt. This is of course to be expected given the open-ended nature of our request. In our view, there’s not much practical value to providing prompts that are this high level if the goal is to create real Grafana dashboards. Copy Prompt:
My data source contains data from a Kia EV6 electric car, recorded with a CANedge CAN bus data logger with device ID 2A896980. The data includes battery data from the EV and GPS/IMU data from a sensor module.
Update my dashboard to include panels showing my Kia EV6 battery data and GPS/IMU data. Example 4: Create a dashboard via a detailed prompt Instead of using a fairly vague prompt, a much better approach is of course to provide highly detailed guidance, similar to what you would provide a human assistant if they were to design your dashboard. You can find the full detailed prompt here. As you can see, the result looks as intended. And more importantly, when we run this 10x (in new conversations each time), we get a 90%+ consistent dashboard each time. You might argue that writing a prompt like this is also time consuming, but in our experience it is still five to 10 times faster than if we were to construct this dashboard from scratch. For example, notice that many of our message/signal names are approximate, leaving Grafana Assistant to figure out what the exact table and column names are. Further, some of the panels involve semi-complex queries (e.g., the consumed State of Charge and the delta distance traveled), which would require significant SQL expertise to create. Most importantly, the prompt specifies no SQL syntax, which is important as 99%+ of our end users have zero SQL experience. Check out the generated dashboard in our public playground. Our summary thoughts We spent 20+ hours with Grafana Assistant. Here are our overarching thoughts. 1: Excellent concept. For users that have already hooked up Grafana to their data, it is extremely simple to start working with the data through the LLM. This ease-of-access is a critical advantage���and the Grafana Assistant UI is great. 2: A drunk genius. Grafana Assistant can give you that “magical experience” where you sit back and watch it produce an entire Grafana dashboard in one shot according to your specifications. However, in some cases it will produce invalid queries, get stuck or hallucinate���just like all LLMs. Make sure to always review the output. 3: Visualization vs. analysis. The LLM is able to modify dashboards and execute SQL queries, making it an excellent tool for data visualization and light exploration. However, it is not able to run scripts (in contrast to ChatGPT, for example), making it less suitable for highly complex, multi-step data analysis���at least for now. Such functionality could be a powerful future mode/variation of the assistant. 4: Huge potential. While the current version has li
Read the Original Article
This article originally appeared on Grafana Labs blog on Grafana Labs.
Read Full Article on Original Site