<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>TSL Archives - OVHcloud Blog</title>
	<atom:link href="https://blog.ovhcloud.com/tag/tsl/feed/" rel="self" type="application/rss+xml" />
	<link>https://blog.ovhcloud.com/tag/tsl/</link>
	<description>Innovation for Freedom</description>
	<lastBuildDate>Fri, 31 Jan 2020 13:41:35 +0000</lastBuildDate>
	<language>en-GB</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://blog.ovhcloud.com/wp-content/uploads/2019/07/cropped-cropped-nouveau-logo-ovh-rebranding-32x32.gif</url>
	<title>TSL Archives - OVHcloud Blog</title>
	<link>https://blog.ovhcloud.com/tag/tsl/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>TSL (or how to query time series databases)</title>
		<link>https://blog.ovhcloud.com/tsl-or-how-to-query-time-series-databases/</link>
		
		<dc:creator><![CDATA[Aurélien Hébert]]></dc:creator>
		<pubDate>Fri, 31 Jan 2020 13:41:34 +0000</pubDate>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Language]]></category>
		<category><![CDATA[Metrics]]></category>
		<category><![CDATA[Observability]]></category>
		<category><![CDATA[Time series]]></category>
		<category><![CDATA[TSL]]></category>
		<guid isPermaLink="false">https://www.ovh.com/blog/?p=16734</guid>

					<description><![CDATA[Last year, we released TSL as an open source tool to query a Warp 10 platform, and by extension, the OVHcloud Metrics Data Platform. 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 [&#8230;]<img src="//blog.ovhcloud.com/wp-content/plugins/matomo/app/matomo.php?idsite=1&amp;rec=1&amp;url=https%3A%2F%2Fblog.ovhcloud.com%2Ftsl-or-how-to-query-time-series-databases%2F&amp;action_name=TSL%20%28or%20how%20to%20query%20time%20series%20databases%29&amp;urlref=https%3A%2F%2Fblog.ovhcloud.com%2Ffeed%2F" style="border:0;width:0;height:0" width="0" height="0" alt="" />]]></description>
										<content:encoded><![CDATA[
<p>Last year, we released <a href="https://github.com/ovh/tsl/)" data-wpel-link="external" target="_blank" rel="nofollow external noopener noreferrer"><strong>TSL</strong></a> as an <strong>open source tool</strong> to <strong>query</strong> a<strong> Warp 10</strong> platform, and by extension, the <a href="https://www.ovh.com/fr/data-platforms/metrics/" data-wpel-link="exclude"><strong>OVHcloud Metrics Data Platform</strong></a>. </p>



<div class="wp-block-image"><figure class="aligncenter size-large"><img fetchpriority="high" decoding="async" width="1024" height="540" src="https://www.ovh.com/blog/wp-content/uploads/2020/01/135A79BD-555F-4967-96DF-32F0A92E6C8A-1024x540.jpeg" alt="TSL by OVHcloud" class="wp-image-16774" srcset="https://blog.ovhcloud.com/wp-content/uploads/2020/01/135A79BD-555F-4967-96DF-32F0A92E6C8A-1024x540.jpeg 1024w, https://blog.ovhcloud.com/wp-content/uploads/2020/01/135A79BD-555F-4967-96DF-32F0A92E6C8A-300x158.jpeg 300w, https://blog.ovhcloud.com/wp-content/uploads/2020/01/135A79BD-555F-4967-96DF-32F0A92E6C8A-768x405.jpeg 768w, https://blog.ovhcloud.com/wp-content/uploads/2020/01/135A79BD-555F-4967-96DF-32F0A92E6C8A.jpeg 1202w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure></div>



<p>But how has it evolved since then? Is TSL ready to query <strong>other time series databases</strong>? What about TSL states on the <strong>Warp10 eco-system</strong>?</p>



<hr class="wp-block-separator"/>



<h3 class="wp-block-heading">TSL to query many time series databases</h3>



<p>We wanted TSL to be usable in front of <strong>multiple time series databases</strong>. That&#8217;s why we also released a <strong>PromQL query generator</strong>.</p>



<p>One year later, we now know this wasn&#8217;t the way to go. Based on what we learned, the <strong><a href="https://github.com/aurrelhebert/TSL-Adaptor/" data-wpel-link="external" target="_blank" rel="nofollow external noopener noreferrer">TSL-Adaptor</a> project</strong> was open sourced, as a proof of concept for how TSL can be used  to query a <em>non-Warp 10</em> database. Put simply, TSL-Adaptor allows TSL to <strong>query an InfluxDB</strong>.</p>



<h4 class="wp-block-heading">What is TSL-Adaptor?</h4>



<p>TSL-Adaptor is a <strong><a href="https://quarkus.io/" data-wpel-link="external" target="_blank" rel="nofollow external noopener noreferrer">Quarkus</a> JAVA REST API</strong> 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 <strong>to make TSL available</strong> on top of <strong>other TSDBs</strong>.</p>



<div class="wp-block-image"><figure class="aligncenter size-large"><img decoding="async" width="971" height="702" src="https://www.ovh.com/blog/wp-content/uploads/2020/01/8834E834-6E98-4567-A2B0-B6FD530B2197.png" alt="" class="wp-image-16866" srcset="https://blog.ovhcloud.com/wp-content/uploads/2020/01/8834E834-6E98-4567-A2B0-B6FD530B2197.png 971w, https://blog.ovhcloud.com/wp-content/uploads/2020/01/8834E834-6E98-4567-A2B0-B6FD530B2197-300x217.png 300w, https://blog.ovhcloud.com/wp-content/uploads/2020/01/8834E834-6E98-4567-A2B0-B6FD530B2197-768x555.png 768w" sizes="(max-width: 971px) 100vw, 971px" /></figure></div>



<p>In concrete terms, we are running a JAVA REST API that<strong> integrates the WarpScript library</strong> in its runtime. TSL is  then used to compile the query into a valid WarpScript one. This is <strong>fully transparent</strong>, and only deals with TSL queries on the user&#8217;s side. </p>



<p>To load raw data from the InfluxDB, we created a WarpScript extension. This extension integrates an abstract class <code>LOADSOURCERAW</code> that needs  to be implemented to create an TSL-Adaptor data source. This requires only two methods: <code>find</code> and <code>fetch</code>. <code>Find</code> gathers all series selectors matching a query (class names, tags or labels), while <code>fetch</code>actually retrieves the raw data within a time span.</p>



<h4 class="wp-block-heading">Query Influx with TSL-Adaptor</h4>



<p>To get started, simply run an <a href="https://www.influxdata.com/products/influxdb-overview/" data-wpel-link="external" target="_blank" rel="nofollow external noopener noreferrer">InfluxDB</a> locally on the 8086 port. Then, let&#8217;s start an influx <a href="https://www.influxdata.com/time-series-platform/telegraf/" data-wpel-link="external" target="_blank" rel="nofollow external noopener noreferrer">Telegraf</a> agent and record Telegraf data on the local influx instance.</p>



<p>Next, make sure you have locally installed TSL-Adaptor and updated its config with the path to a <a href="https://github.com/ovh/tsl/releases" data-wpel-link="external" target="_blank" rel="nofollow external noopener noreferrer"><code>tsl.so</code> library</a>.</p>



<p>To specify a custom influx address or databases, update the <a href="https://github.com/aurrelhebert/TSL-Adaptor/blob/master/src/main/resources/application.properties" data-wpel-link="external" target="_blank" rel="nofollow external noopener noreferrer">TSL-Adaptor configuration</a> file accordingly.</p>



<p>You can start TSL-Adaptor with the following example command:</p>



<pre class="wp-block-code"><code class="">java -XX:TieredStopAtLevel=1 -Xverify:none -Djava.util.logging.manager=org.jboss.logmanager.LogManager -jar build/tsl-adaptor-0.0.1-SNAPSHOT-runner.jar </code></pre>



<p>And that&#8217;s it! You can now query your influx database with TSL and TSL-Adaptor.</p>



<p>Let&#8217;s start with the retrieval of the time series relating to the disk measurements.</p>



<pre class="wp-block-code"><code class="">curl --request POST \
  --url http://u:p@0.0.0.0:8080/api/v0/tsl \
  --data 'select("disk")'</code></pre>



<p>Now let&#8217;s use the TSL analytics power! </p>



<p>First, we would like to retrieve only the data containing a mode set to <code>rw</code>.&nbsp;</p>



<pre class="wp-block-code"><code class="">curl --request POST \
  --url http://u:p@0.0.0.0:8080/api/v0/tsl \
  --data 'select("disk").where("mode=rw")'</code></pre>



<p>We would like to retrieve the maximum value at every five-minute interval, for the last 20 minutes. The TSL query will therefore be:</p>



<pre class="wp-block-code"><code class="">curl --request POST \
  --url http://u:p@0.0.0.0:8080/api/v0/tsl \
  --data 'select("disk").where("mode=rw").last(20m).sampleBy(5m,max)'</code></pre>



<p>Now it&#8217;s your turn to have some fun with TSL and InfluxDB. You can find details of all the implemented functions in the <a href="https://github.com/ovh/tsl/blob/master/spec/doc.md" data-wpel-link="external" target="_blank" rel="nofollow external noopener noreferrer">TSL documentation</a>. Enjoy exploring!</p>



<hr class="wp-block-separator"/>



<h3 class="wp-block-heading">What&#8217;s new on TSL with Warp10?</h3>



<p>We originally built TSL as a <a href="https://github.com/ovh/tsl" data-wpel-link="external" target="_blank" rel="nofollow external noopener noreferrer">GO proxy</a> in front of Warp10. <strong>TSL</strong> has now integrated the Warp 10 ecosystem as a <strong>Warp10 extension</strong>, or as a <strong>WASM library</strong>! We have also added some <strong>new native TSL functions</strong> to make the language even richer!</p>



<h4 class="wp-block-heading">TSL as WarpScript function</h4>



<p>To make TSL work as a Warp10 function, you need to have the <code>tsl.so</code> library available locally. This library can be found in <a href="https://github.com/ovh/tsl/releases" data-wpel-link="external" target="_blank" rel="nofollow external noopener noreferrer">TSL github repository</a>. We have also made a <a href="https://warpfleet.senx.io/browse/io.ovh/tslToWarpScript#main" data-wpel-link="external" target="_blank" rel="nofollow external noopener noreferrer">TSL WarpScript extension</a> available from <a href="https://warpfleet.senx.io/" data-wpel-link="external" target="_blank" rel="nofollow external noopener noreferrer">WarpFleet</a>, the extension repository of the Warp 10 community. </p>



<p>To set up TSL extension on your Warp 10, simply download the JAR indicated in <a href="https://warpfleet.senx.io/browse/io.ovh/tslToWarpScript#main" data-wpel-link="external" target="_blank" rel="nofollow external noopener noreferrer">WarpFleet</a>. You can then configure the extension in the Warp 10 configuration file: </p>



<pre class="wp-block-code"><code class="">warpscript.extensions = io.ovh.metrics.warp10.script.ext.tsl.TSLWarpScriptExtension
warpscript.tsl.libso.path = &lt;PATH_TO_THE_tsl.so_FILE></code></pre>



<p>Once you reboot Warp 10, you are ready to go. You can test if it&#8217;s working by running the following query:</p>



<pre class="wp-block-code"><code class="">// You will need to put here a valid Warp10 token when computing a TSL select statement
// '&lt;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
 &lt;'
    create(series('test').setValues("now", [-5m, 2], [0, 1])) 
'>
TSL</code></pre>



<p>With the WarpScript TSL function, you can use native WarpScript variables in your script, as shown in the example below:</p>



<pre class="wp-block-code"><code class="">// Set a Warp10 variable

NOW 'test' STORE

'' 

// A Warp10 variable can be reused in TSL script as a native TSL variable
 &lt;'
    create(series('test').setValues("now", [-5m, 2], [0, 1])).add(test)
'>
TSL</code></pre>



<h4 class="wp-block-heading">TSL WASM</h4>



<p>To expand TSL&#8217;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 <a href="https://github.com/ovh/tsl#use-tsl-with-webassembly" data-wpel-link="external" target="_blank" rel="nofollow external noopener noreferrer">TSL github</a>.</p>



<h4 class="wp-block-heading">TSL&#8217;s new features</h4>



<p>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.</p>



<p>We added the <code>setLabelFromName</code>method, 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. </p>



<p>We also completed the <code>sort</code>method, to allow users to sort their series set based on series meta data (i.e. selector, name or labels).</p>



<p>Finally, we added a <code>filterWithoutLabels</code>, to filter a series set and remove any series that do not contain specific labels.</p>



<p>Thanks for reading! I hope you will give TSL a try, as I would love to hear your feedback.  </p>



<hr class="wp-block-separator"/>



<h2 class="wp-block-heading">Paris Time Series meetup</h2>



<p>We are delighted to be <strong>hosting</strong>, at the <strong>OVHcloud office</strong> in Paris, soon the third<strong> <a href="https://www.meetup.com/Paris-Time-Series-Meetup/events/266610627/" data-wpel-link="external" target="_blank" rel="nofollow external noopener noreferrer">Paris Time Series meetup</a></strong>, 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.</p>



<p>If you are available, we will be happy to meet you there!</p>
<img decoding="async" src="//blog.ovhcloud.com/wp-content/plugins/matomo/app/matomo.php?idsite=1&amp;rec=1&amp;url=https%3A%2F%2Fblog.ovhcloud.com%2Ftsl-or-how-to-query-time-series-databases%2F&amp;action_name=TSL%20%28or%20how%20to%20query%20time%20series%20databases%29&amp;urlref=https%3A%2F%2Fblog.ovhcloud.com%2Ffeed%2F" style="border:0;width:0;height:0" width="0" height="0" alt="" />]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>TSL: a developer-friendly Time Series query language for all our metrics</title>
		<link>https://blog.ovhcloud.com/tsl-a-developer-friendly-time-series-query-language-for-all-our-metrics/</link>
		
		<dc:creator><![CDATA[Aurélien Hébert]]></dc:creator>
		<pubDate>Wed, 13 Feb 2019 13:11:28 +0000</pubDate>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Language]]></category>
		<category><![CDATA[Metrics]]></category>
		<category><![CDATA[Time series]]></category>
		<category><![CDATA[TSL]]></category>
		<guid isPermaLink="false">https://blog.ovh.com/fr/blog/?p=14445</guid>

					<description><![CDATA[At the Metrics team we have been working on time series for several years. From our experience the data analytics capabilities of a Time Series Database (TSDB) platform is a key factor to create value from your metrics. And these analytics capabilities are mostly defined by the query languages they support. 

TSL stands for Time Series Language. In a few words, TSL is an abstracted way, under the form of an HTTP proxy, to generate queries for different TSDB backends. Currently it supports Warp 10's WarpScript and  Prometheus' PromQL query languages but we aim to extend the support to other major TSDB.


To better understand why we created TSL, we are reviewing some of the TSDB query languages supported on OVH Metrics Data Platform. When implementing them, we learnt the good, the bad and the ugly of each one. At the end, we decided to build TSL to simplify the querying on our platform, before open-sourcing it to use it on any TSDB solution. 

Why did we decide to invest some of our Time in such a proxy? Let me tell you the story of the OVH metrics protocol!<img src="//blog.ovhcloud.com/wp-content/plugins/matomo/app/matomo.php?idsite=1&amp;rec=1&amp;url=https%3A%2F%2Fblog.ovhcloud.com%2Ftsl-a-developer-friendly-time-series-query-language-for-all-our-metrics%2F&amp;action_name=TSL%3A%20a%20developer-friendly%20Time%20Series%20query%20language%20for%20all%20our%20metrics&amp;urlref=https%3A%2F%2Fblog.ovhcloud.com%2Ffeed%2F" style="border:0;width:0;height:0" width="0" height="0" alt="" />]]></description>
										<content:encoded><![CDATA[
<p>At the Metrics team, we have been working on Time Series for several years now. In our experience, the <strong>data analytics capabilities</strong> of a Time Series Database (TSDB) platform is a key factor in <strong>creating value</strong> from your metrics. These analytics capabilities are mostly defined by the <strong>query languages</strong> they support. </p>



<p>TSL stands for <strong>Time Series Language</strong>. In simple terms, <a rel="noreferrer noopener nofollow external" href="https://github.com/ovh/tsl" target="_blank" data-wpel-link="external">TSL</a> is an abstracted way of generating queries for <strong>different TSDB backends</strong>, in the form of an HTTP proxy. It currently supports Warp 10&#8217;s WarpScript and  Prometheus&#8217; PromQL query languages, but we aim to extend the support to other major TSDBs.</p>



<div class="wp-block-image"><figure class="aligncenter"><img loading="lazy" decoding="async" width="300" height="213" src="/blog/wp-content/uploads/2019/02/E80CF711-CFD0-45F8-B7E4-4CEBE7E5815A-300x213.png" alt="TSL - Time Series Language" class="wp-image-14499" srcset="https://blog.ovhcloud.com/wp-content/uploads/2019/02/E80CF711-CFD0-45F8-B7E4-4CEBE7E5815A-300x213.png 300w, https://blog.ovhcloud.com/wp-content/uploads/2019/02/E80CF711-CFD0-45F8-B7E4-4CEBE7E5815A-768x545.png 768w, https://blog.ovhcloud.com/wp-content/uploads/2019/02/E80CF711-CFD0-45F8-B7E4-4CEBE7E5815A.png 885w" sizes="auto, (max-width: 300px) 100vw, 300px" /></figure></div>



<p><em>To provide some context around why we created TSL, it began with a review of some of the <strong>TSDB query languages</strong> supported on the&nbsp;<strong>OVH Metrics Data Platform</strong>. When implementing them, we learned the good, the bad and the ugly of each one. In the end, we decided to build TSL to <strong>simplify the querying</strong> on our platform, before open-sourcing it to use it on any TSDB solution.&nbsp;</em></p>



<p><em>So why did we decide to invest our time in developing such a proxy? Well, let me tell you <strong>the story of the OVH Metrics protocol</strong>!</em></p>



<h3 class="wp-block-heading">From OpenTSDB&#8230;</h3>



<div class="wp-block-image"><figure class="alignleft"><img loading="lazy" decoding="async" width="300" height="80" src="/blog/wp-content/uploads/2019/02/AEEDC522-26CE-44F6-A6F2-6B80480F8FC2-300x80.png" alt="OpenTSDB" class="wp-image-14507" srcset="https://blog.ovhcloud.com/wp-content/uploads/2019/02/AEEDC522-26CE-44F6-A6F2-6B80480F8FC2-300x80.png 300w, https://blog.ovhcloud.com/wp-content/uploads/2019/02/AEEDC522-26CE-44F6-A6F2-6B80480F8FC2-768x205.png 768w, https://blog.ovhcloud.com/wp-content/uploads/2019/02/AEEDC522-26CE-44F6-A6F2-6B80480F8FC2.png 810w" sizes="auto, (max-width: 300px) 100vw, 300px" /></figure></div>



<p>The first aim of our platform is to be able to support the OVH infrastructure and application monitoring. When this project started, a lot of people were using <a href="http://opentsdb.net/" target="_blank" rel="noreferrer noopener nofollow external" data-wpel-link="external">OpenTSDB</a>, and were familiar with its query syntax. <a href="http://opentsdb.net/" target="_blank" rel="noreferrer noopener nofollow external" data-wpel-link="external">OpenTSDB</a> is a scalable database for Time Series. The <a href="http://opentsdb.net/docs/build/html/user_guide/query/index.html" data-wpel-link="external" target="_blank" rel="nofollow external noopener noreferrer">OpenTSDB query</a>&nbsp;syntax is easy to read, as you send a JSON document describing the request. The document below will load all<code>sys.cpu.0</code>&nbsp;metrics of the<code>test</code>datacentre, summing them between the<code>start</code>&nbsp;and <code>end</code> dates:</p>



<pre class="wp-block-code"><code lang="java" class="language-java">{
    "start": 1356998400,
    "end": 1356998460,
    "queries": [
        {
            "aggregator": "sum",
            "metric": "sys.cpu.0",
            "tags": {
                "host": "*",
                "dc": "test"
            }
        }
    ]
}</code></pre>



<p>This enables the quick retrieval of specific data, in a specific time range. At OVH, this was used for graphs purpose, in conjunction with Grafana, and helped us to spot potential issues in real time, as well as investigate past events. OpenTSDB integrates simple queries, where you can define your own sampling and deal with counter data, as well as filtered and aggregated raw data.</p>



<p>OpenTSDB was the first protocol supported by the Metrics team, and is still widely used today. Internal statistics shows that 30-40% of our traffic is based on OpenTSDB queries. A lot of internal use cases can still be entirely resolved with this protocol, and the queries are easy to write and understand.</p>



<p>For example, a query with OpenTSDB to get the max value of the<code>usage_system</code>for the<code>cpu</code>0 to 9, sampled for a 2-minute span by their values&#8217; average, looks like this:</p>



<pre class="wp-block-code"><code lang="java" class="language-java">{
    "start": 1535797890,
    "end": 1535818770,
    "queries":  [{
        "metric":"cpu.usage_system",
        "aggregator":"max",
        "downsample":"2m-avg",
        "filters": [{
            "type":"regexp",
            "tagk":"cpu",
            "filter":"cpu[0–9]+",
            "groupBy":false
            }]
        }]
}</code></pre>



<p>However, OpenTSDB quickly shows its limitations, and some specific uses cases can&#8217;t be resolved with it. For example, you can&#8217;t apply any operations directly on the back-end. You have to load the data on an external tool and use it to apply any analytics.</p>



<p>One of the main areas where OpenTSDB (version 2.3) is lacking&nbsp; is multiple Time Series set operators, which allow actions like a divide series. Those operators can be a useful way to compute the individual query time per request, when you have (for example) a set of total time spend in requests and a set of total requests count series. That’s one of the reasons why the OVH Metrics Data Platform supports other protocols.</p>



<h2 class="wp-block-heading">&#8230; to PromQL</h2>



<div class="wp-block-image"><figure class="alignleft"><img loading="lazy" decoding="async" width="150" height="150" src="/blog/wp-content/uploads/2019/02/790C8FFD-E734-475E-BF7E-B93F0708C604-150x150.png" alt="Prometheus" class="wp-image-14503"/></figure></div>



<p>The second protocol we worked on was <a href="https://prometheus.io/docs/prometheus/latest/querying/basics/" data-wpel-link="external" target="_blank" rel="nofollow external noopener noreferrer">PromQL</a>, the query language of the <a href="https://prometheus.io/" target="_blank" rel="noreferrer noopener nofollow external" data-wpel-link="external">Prometheus</a> Time Series database. When we made that choice in 2015, <a href="https://prometheus.io/" target="_blank" rel="noreferrer noopener nofollow external" data-wpel-link="external">Prometheus</a> was gaining some traction, and it still has an impressive adoption rate. But if Prometheus is a success, it isn&#8217;t for it’s query language, PromQL. This language never took off internally, although it has started to gain some adoption recently, mainly due to the arrival of people that worked with Prometheus in their previous companies. Internally,&nbsp;<strong>PromQL queries represent about 1-2%</strong> of our daily traffic. The main reasons are that a lot of simple use cases can be solved quickly and with more control of the raw data with OpenTSDB queries, while a lot of more complex use cases cannot be solved with PromQL. A similar request to the one defined in OpenTSDB would be:</p>



<pre class="wp-block-code"><code lang="c" class="language-c">api/v1/query_range?
query=max(cpu. usage_system{cpu=~"cpu[0–9]%2B"})
start=1535797890&amp;
end=1535818770&amp;
step=2m</code></pre>



<p>With PromQL, <strong>you lose control of how you sample the data</strong>, as the only operator is <strong>last</strong>. This means that &nbsp;if (for example) you want to downsample your series with a 5-minute duration, you are only able to keep the last value of each 5-minute series span. In contrast, all competitors include a range of operators. For example, with OpenTSDB, you can choose between several operators, including average, count, standard deviation, first, last, percentiles, minimal, maximal or summing all values inside your defined span.</p>



<p>In the end, a lot of people choose to use a much more complex method: WarpScript, which is powered by the Warp10 Analytics Engine we use behind the scenes.</p>



<h2 class="wp-block-heading">Our internal adoption of WarpScript</h2>



<div class="wp-block-image"><figure class="alignleft"><img loading="lazy" decoding="async" width="300" height="106" src="/blog/wp-content/uploads/2019/02/559ED4E1-4AD2-453B-A96B-74BF6490D6B9-300x106.png" alt="WarpScript by SenX" class="wp-image-14505" srcset="https://blog.ovhcloud.com/wp-content/uploads/2019/02/559ED4E1-4AD2-453B-A96B-74BF6490D6B9-300x106.png 300w, https://blog.ovhcloud.com/wp-content/uploads/2019/02/559ED4E1-4AD2-453B-A96B-74BF6490D6B9-768x272.png 768w, https://blog.ovhcloud.com/wp-content/uploads/2019/02/559ED4E1-4AD2-453B-A96B-74BF6490D6B9.png 837w" sizes="auto, (max-width: 300px) 100vw, 300px" /></figure></div>



<p><a rel="noreferrer noopener nofollow external" href="https://www.warp10.io/content/03_Documentation/04_WarpScript/01_Concepts" target="_blank" data-wpel-link="external">WarpScript</a> is the current Time Series language of <a rel="noreferrer noopener nofollow external" href="https://www.warp10.io/" target="_blank" data-wpel-link="external">Warp 10(R)</a>, our underlying backend. WarpScript will help for any complex Time Series use case, and solves numerous real-world problems, as you have full control of all your operations. You have dedicated frameworks of functions to sample raw data and fill missing values. You also have frameworks to apply operations on single-value or window operations. You can apply operations on multiple Time Series sets, and have dedicated functions to manipulate Time Series times, statistics, etc.</p>



<p>It works with a Reverse Polish Notation (like a good, old-fashioned HP48, for those who&#8217;ve got one!), and simple uses cases can be easy to express. But when it comes to analytics, while it certainly solves problems, it’s still complex to learn. In particular, Time Series use cases are complex and require a thinking model, so WarpScript helped to solve a lot of hard ones.</p>



<p>This is why it&#8217;s still the main query used at OVH on the OVH Metrics platform, with <strong>nearly 60%</strong> of internal queries making use of it. The same request that that we just computed in OpenTSDB and PromQL would be as follows in WarpScript:</p>



<pre class="wp-block-code"><code lang="c" class="language-c">[ "token" "cpu.average" { "cpu" "~cpu[0–9]+" } NOW 2 h ] FETCH
[ SWAP bucketizer.mean 0 2 m 0 ] BUCKETIZE
[ SWAP [ "host" ] reducer.max ] REDUCE</code></pre>



<p>A lot of users find it hard to learn WarpScript at first, but after solving their initial issues with some (sometimes a lot of) support, it becomes&nbsp;the first step of their Time Series adventure. Later, they figure out some new ideas about how they can gain knowledge from their metrics. They then come back with many demands and questions about their daily issues, some of which can be solved quickly, with their own knowledge and experience.</p>



<p>What we learned from WarpScript is that it’s a fantastic tool with which to build analytics for our Metrics data. We pushed many complex use cases with advanced signal-processing algorithms like <a href="https://www.warp10.io/doc/LTTB#sigTitle" data-wpel-link="external" target="_blank" rel="nofollow external noopener noreferrer">LTTB</a>, <a href="https://www.warp10.io/tags/outlier" data-wpel-link="external" target="_blank" rel="nofollow external noopener noreferrer">Outliers</a> or <a href="https://www.warp10.io/doc/PATTERNDETECTION#sigTitle" data-wpel-link="external" target="_blank" rel="nofollow external noopener noreferrer">Patterns</a> detections, and&nbsp;<a href="https://en.wikipedia.org/wiki/Kernel_smoother" data-wpel-link="external" target="_blank" rel="nofollow external noopener noreferrer">Kernel Smoothing,</a> where it proved to be a&nbsp; real enabler. However, it proved quite expensive to support for basic requirements, and feedback indicated the syntax and overall complexity were big concerns.</p>



<p>A WarpScript can involve dozens (or even hundreds) of lines, and a successful execution is often an accomplishment, with the special feeling that comes from having made full use of one&#8217;s brainpower. In fact, an inside joke amongst our team is being born able to write a WarpScript in a single day, or to earn a WarpScript Pro Gamer badge! That&#8217;s why we&#8217;ve distributed Metrics t-shirts to users that have achieved significant successes with the Metrics Data Platform.</p>



<p>We liked the WarpScript semantic, but we wanted it to have a significant impact on a broader range of use cases. This is why we started to write TSL with few simple goals:</p>



<ul class="wp-block-list"><li>Offer a clear Time Series analytics semantic</li><li>Simplify the writing and making it developer-friendly</li><li>Support data flow queries and ease debugging for complex queries</li><li>Don&#8217;t try and be the ultimate tool box. Keep it simple.</li></ul>



<p>We know that users will probably have to switch back to WarpScript every so often. However, we hope that using TSL will simplify their learning curve. TSL is simply a new step in the Time Series adventure!</p>



<h3 class="wp-block-heading">The path to&nbsp;TSL</h3>



<div class="wp-block-image"><figure class="alignleft"><img loading="lazy" decoding="async" width="300" height="213" src="/blog/wp-content/uploads/2019/02/E80CF711-CFD0-45F8-B7E4-4CEBE7E5815A-300x213.png" alt="TSL - Time Series Language" class="wp-image-14499" srcset="https://blog.ovhcloud.com/wp-content/uploads/2019/02/E80CF711-CFD0-45F8-B7E4-4CEBE7E5815A-300x213.png 300w, https://blog.ovhcloud.com/wp-content/uploads/2019/02/E80CF711-CFD0-45F8-B7E4-4CEBE7E5815A-768x545.png 768w, https://blog.ovhcloud.com/wp-content/uploads/2019/02/E80CF711-CFD0-45F8-B7E4-4CEBE7E5815A.png 885w" sizes="auto, (max-width: 300px) 100vw, 300px" /></figure></div>



<p><a rel="noreferrer noopener nofollow external" href="https://github.com/ovh/tsl" target="_blank" data-wpel-link="external">TSL</a> is the result of three years of Time Series analytics support, and offers a functional Time Series Language. The aim of TSL is to build a Time Series data flow as code. </p>



<p>With TSL, native methods, such as <code>select</code> and <code>where</code>, exist to choose which metrics to work on. Then, as Time Series data is time-related, we have to use a time selector method on the selected meta. The two available methods are <code>from</code> and <code>last</code>. The vast majority of the other TSL methods take Time Series sets as input and provide Time Series sets as the result. For example, you have methods that only select values above a specific threshold, compute rate, and so on. We have also included specific operations to apply to multiple subsets of Time Series sets, as additions or multiplications.</p>



<p>Finally, for a more readable language, you can define variables to store Time Series queries and reuse them in your script any time you wish. For now, we support only a few native types, such as <code>Numbers</code>, <code>Strings</code>, <code>Time durations</code>, <code>Lists</code>, and <code>Time Series</code> (of course!).</p>



<p>Finally, the same query used throughout this article will be as follows in TSL:</p>



<pre class="wp-block-code"><code lang="javascript" class="language-javascript">select("cpu.usage_system")
.where("cpu~cpu[0–9]+")
.last(12h)
.sampleBy(2m,mean)
.groupBy(max)</code></pre>



<p>You can also write more complex queries. For example, we condensed our WarpScript hands-on, designed to detect <a href="https://helloexoworld.github.io/hew-hands-on/" target="_blank" rel="noreferrer noopener nofollow external" data-wpel-link="external">exoplanets from NASA raw data</a>, into a single TSL query:</p>



<pre class="wp-block-code"><code lang="javascript" class="language-javascript">sample = select('sap.flux')
 .where('KEPLERID=6541920')
 .from("2009–05–02T00:56:10.000000Z", to="2013–05–11T12:02:06.000000Z")
 .timesplit(6h,100,"record")
 .filterByLabels('record~[2–5]')
 .sampleBy(2h, min, false, "none")

trend = sample.window(mean, 5, 5)

sub(sample,trend)
 .on('KEPLERID','record')
 .lessThan(-20.0)</code></pre>



<p>So what did we do here? First we instantiated a <strong>sample</strong> variable in which we loaded the ‘sap.flux’ raw data of one star, the 6541920. We then cleaned the series, using the timesplit function (to split the star series when there is a hole in the data with a length greater than 6h), keeping only four records. Finally, we sampled the result, keeping the minimal value of each 2-hour bucket.</p>



<p>We then used this result to compute the series trend, using a moving average of 10 hours.</p>



<p>To conclude, the query returns only the points less than 20 from the result of the subtraction of the trend and the sample series.</p>



<h3 class="wp-block-heading">TSL is Open Source</h3>



<p>Even if our first community of users was mostly inside OVH, we&#8217;re pretty confident that TSL can be used to solve a lot of Time Series use cases.</p>



<p>We are currently beta testing TSL on our OVH Metrics public platform. Furthermore, TSL is <a href="https://github.com/ovh/tsl" data-wpel-link="external" target="_blank" rel="nofollow external noopener noreferrer">open-sourced on Github</a>, so you can also test it on your own platforms.</p>



<p>We would love to get your feedback or comments on TSL, or Time Series in general. We&#8217;re available on the <a href="https://gitter.im/ovh/metrics" data-wpel-link="external" target="_blank" rel="nofollow external noopener noreferrer">OVH Metrics gitter,</a> and you can find out more about TSL &nbsp;in <a href="https://labs.ovh.com/metrics-beta-features/" data-wpel-link="exclude">our Beta features documentation</a>.</p>
<img loading="lazy" decoding="async" src="//blog.ovhcloud.com/wp-content/plugins/matomo/app/matomo.php?idsite=1&amp;rec=1&amp;url=https%3A%2F%2Fblog.ovhcloud.com%2Ftsl-a-developer-friendly-time-series-query-language-for-all-our-metrics%2F&amp;action_name=TSL%3A%20a%20developer-friendly%20Time%20Series%20query%20language%20for%20all%20our%20metrics&amp;urlref=https%3A%2F%2Fblog.ovhcloud.com%2Ffeed%2F" style="border:0;width:0;height:0" width="0" height="0" alt="" />]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
