ICYMI – Scripting and Query Languages in InfluxDB
By
Jason Myers /
Product, Company
Dec 13, 2022
Navigate to:
At our recent InfluxDays event, Gary Fowler discussed the current state of scripting and query language support in InfluxDB. This is an aspect of the platform undergoing constant development, so here’s a quick recap of what Gary went over.
Working with your data
At present, InfluxDB supports three different query languages. Each of these differs in capability and ease of use. As you might expect, the more complex languages allow you to do more with your data. However, determining which language is right for you depends on what you ultimately want to accomplish.
Your options include:
Flux
Flux is InfluxDB’s native scripting language. It has a steeper learning curve compared to the other languages, but it’s also the most powerful. You can perform queries with Flux, and you can also perform advanced data transformations, create tasks, and trigger actions. Flux is available across the entire InfluxDB platform – cloud, enterprise, and OSS.
InfluxQL
The forebear of Flux language is InfluxQL. This is essentially SQL with some extensions for time series that enable it to function with InfluxDB. You can do some basic transformations with it, but it’s not as powerful or robust as Flux. That’s one of the tradeoffs with InfluxQL. Nevertheless, it remains a very popular option for our users and is available in cloud, enterprise, and OSS. We’re looking to add Cloud UI support for InfluxQL, too, which has been on a lot of wishlists for quite some time.
SQL
The newest language offering is SQL. As of right now, SQL support is only available in the Cloud as part of our new IOx data engine. If you just need to do simple, fast queries, then SQL will check the box for you. We’re working on SQL support in the cloud UI and IOx also supports the PostgreSQL wire protocol so you can connect InfluxDB to compatible third-party tools.
The graphic below does a good job of summarizing what you can expect from the different supported languages.
Tasks
Tasks are scripts that run on a schedule and allow you to downsample data, perform transformations, or trigger alerts. You can use Flux to write tasks, but – in our commitment to meeting developers where they are – we’re planning to add support for writing tasks in both Python and JavaScript. This means you’ll be able to write and run tasks in these languages within InfluxDB Cloud, eliminating the need to extract data first.
Here’s a quick comparison table to help you:
Flux | SQL | InfluxQL | Python/JavaScript |
---|---|---|---|
Need most power and flexibility | Transition from relational DB | Already using with OSS & Enterprise | Python or JavaScript Expertise |
Need to transform or otherwise manipulate date, not just query it | Previous SQL Expertise | Previous InfluxQL or SQL Expertise | Want to move existing Python code into the Cloud |
Need to combine data sources | Only need to do fast, simple queries | ||
Need to make REST or other API calls | Easier API transition from other SQL DBs |
Script editing
With so many options for writing scripts and queries in InfluxDB, users also need a way to edit those scripts. Gary also introduced the new script editor for InfluxDB Cloud.
One of the key features of the new script editor is that it presents users with the visual builder and the script editor in the same window. There’s no need to toggle between them anymore.
Another major feature add is the ability to save and load scripts. At present, we’re supporting basic saving and loading of scripts, but we’re working on more advanced features that will make it easy to reuse scripts in different and/or multiple dashboards. We plan to add versioning, label and folder organization, and permissions as well.
Taken together, the scripting and query languages available in InfluxDB provide users with a range of options for working with their time series data in the way that’s most comfortable to them. We love feedback so let us know what’s working for you.
You can watch Gary’s entire presentation here: https://www.youtube.com/watch?v=BRY6VDzrCdY