But how has it evolved since then? Is TSL ready to query other time series databases? What about TSL states on the Warp10 eco-system?
TSL to query many time series databases
We wanted TSL to be usable in front of multiple time series databases. That’s why we also released a PromQL query generator.
One year later, we now know this wasn’t the way to go. Based on what we learned, the TSL-Adaptor project was open sourced, as a proof of concept for how TSL can be used to query a non-Warp 10 database. Put simply, TSL-Adaptor allows TSL to query an InfluxDB.
What is TSL-Adaptor?
TSL-Adaptor is a Quarkus JAVA REST API that can be used to query a backend. TSL-Adaptor parses the TSL query, identifies the fetch operation, and loads natively raw data from the backend. It then computes the TSL operations on the data, before returning the result to the user. The main goal of TSL-Adaptor is to make TSL available on top of other TSDBs.
In concrete terms, we are running a JAVA REST API that integrates the WarpScript library in its runtime. TSL is then used to compile the query into a valid WarpScript one. This is fully transparent, and only deals with TSL queries on the user’s side.
To load raw data from the InfluxDB, we created a WarpScript extension. This extension integrates an abstract class
LOADSOURCERAW that needs to be implemented to create an TSL-Adaptor data source. This requires only two methods:
Find gathers all series selectors matching a query (class names, tags or labels), while
fetchactually retrieves the raw data within a time span.
Query Influx with TSL-Adaptor
Next, make sure you have locally installed TSL-Adaptor and updated its config with the path to a
To specify a custom influx address or databases, update the TSL-Adaptor configuration file accordingly.
You can start TSL-Adaptor with the following example command:
java -XX:TieredStopAtLevel=1 -Xverify:none -Djava.util.logging.manager=org.jboss.logmanager.LogManager -jar build/tsl-adaptor-0.0.1-SNAPSHOT-runner.jar
And that’s it! You can now query your influx database with TSL and TSL-Adaptor.
Let’s start with the retrieval of the time series relating to the disk measurements.
curl --request POST \ --url http://u:email@example.com:8080/api/v0/tsl \ --data 'select("disk")'
Now let’s use the TSL analytics power!
First, we would like to retrieve only the data containing a mode set to
curl --request POST \ --url http://u:firstname.lastname@example.org:8080/api/v0/tsl \ --data 'select("disk").where("mode=rw")'
We would like to retrieve the maximum value at every five-minute interval, for the last 20 minutes. The TSL query will therefore be:
curl --request POST \ --url http://u:email@example.com:8080/api/v0/tsl \ --data 'select("disk").where("mode=rw").last(20m).sampleBy(5m,max)'
Now it’s your turn to have some fun with TSL and InfluxDB. You can find details of all the implemented functions in the TSL documentation. Enjoy exploring!
What’s new on TSL with Warp10?
We originally built TSL as a GO proxy in front of Warp10. TSL has now integrated the Warp 10 ecosystem as a Warp10 extension, or as a WASM library! We have also added some new native TSL functions to make the language even richer!
TSL as WarpScript function
To make TSL work as a Warp10 function, you need to have the
tsl.so library available locally. This library can be found in TSL github repository. We have also made a TSL WarpScript extension available from WarpFleet, the extension repository of the Warp 10 community.
To set up TSL extension on your Warp 10, simply download the JAR indicated in WarpFleet. You can then configure the extension in the Warp 10 configuration file:
warpscript.extensions = io.ovh.metrics.warp10.script.ext.tsl.TSLWarpScriptExtension warpscript.tsl.libso.path = <PATH_TO_THE_tsl.so_FILE>
Once you reboot Warp 10, you are ready to go. You can test if it’s working by running the following query:
// You will need to put here a valid Warp10 token when computing a TSL select statement // '<A_VALID_WARP_10_TOKEN>' // A valid TOKEN isn't needed on the create series statement in this example // You can simply put an empty string '' // Native TSL create series statement <' create(series('test').setValues("now", [-5m, 2], [0, 1])) '> TSL
With the WarpScript TSL function, you can use native WarpScript variables in your script, as shown in the example below:
// Set a Warp10 variable NOW 'test' STORE '' // A Warp10 variable can be reused in TSL script as a native TSL variable <' create(series('test').setValues("now", [-5m, 2], [0, 1])).add(test) '> TSL
To expand TSL’s potential uses, we have also exported it as a Wasm library, so you can use it directly in a browser! The Wasm version of the library parses TSL queries locally and generates the WarpScript. The result can then be used to query a Warp 10 backend. You will find more details on the TSL github.
TSL’s new features
As TSL has grown in popularity, we have detected and fixed a few bugs, and also added some additional native functions to accommodate new use cases.
We added the
setLabelFromNamemethod, to set a new label to a series, based on its name. This label can be the exact series name, or the result of a regular expression.
We also completed the
sortmethod, to allow users to sort their series set based on series meta data (i.e. selector, name or labels).
Finally, we added a
filterWithoutLabels, to filter a series set and remove any series that do not contain specific labels.
Thanks for reading! I hope you will give TSL a try, as I would love to hear your feedback.
Paris Time Series meetup
We are delighted to be hosting, at the OVHcloud office in Paris, soon the third Paris Time Series meetup, organised by Nicolas Steinmetz. During this meetup, we will be speaking about TSL, as well as listening to an introduction of the Redis Times Series platform.
If you are available, we will be happy to meet you there!