Skip to content

Commit ccd18b7

Browse files
DOC-5424 query multiple time series section
1 parent 3dc0af2 commit ccd18b7

File tree

1 file changed

+53
-100
lines changed
  • content/develop/data-types/timeseries

1 file changed

+53
-100
lines changed

content/develop/data-types/timeseries/_index.md

Lines changed: 53 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -349,106 +349,6 @@ OK
349349
2) 18
350350
```
351351

352-
## Deleting data points
353-
354-
Use [`TS.DEL`]({{< relref "commands/ts.del/" >}}) to delete data points
355-
that fall within a given timestamp range. The range is inclusive, meaning that
356-
samples whose timestamp equals the start or end of the range are deleted.
357-
If you want to delete a single timestamp, use it as both the start and end of the range.
358-
359-
```bash
360-
> TS.INFO thermometer:1
361-
1) totalSamples
362-
2) (integer) 2
363-
3) memoryUsage
364-
4) (integer) 4856
365-
5) firstTimestamp
366-
6) (integer) 1
367-
7) lastTimestamp
368-
8) (integer) 2
369-
.
370-
.
371-
> TS.ADD thermometer:1 3 9.7
372-
(integer) 3
373-
127.0.0.1:6379> TS.INFO thermometer:1
374-
1) totalSamples
375-
2) (integer) 3
376-
3) memoryUsage
377-
4) (integer) 4856
378-
5) firstTimestamp
379-
6) (integer) 1
380-
7) lastTimestamp
381-
8) (integer) 3
382-
.
383-
.
384-
> TS.DEL thermometer:1 1 2
385-
(integer) 2
386-
> TS.INFO thermometer:1
387-
1) totalSamples
388-
2) (integer) 1
389-
3) memoryUsage
390-
4) (integer) 4856
391-
5) firstTimestamp
392-
6) (integer) 3
393-
7) lastTimestamp
394-
8) (integer) 3
395-
.
396-
.
397-
> TS.DEL thermometer:1 3 3
398-
(integer) 1
399-
> TS.INFO thermometer:1
400-
1) totalSamples
401-
2) (integer) 0
402-
.
403-
.
404-
```
405-
406-
## Filtering
407-
You can filter your time series by value, timestamp and labels:
408-
409-
### Filtering by label
410-
You can retrieve datapoints from multiple timeseries in the same query, and the way to do this is by using label filters. For example:
411-
412-
```
413-
TS.MRANGE - + FILTER area_id=32
414-
```
415-
416-
This query will show data from all sensors (timeseries) that have a label of `area_id` with a value of `32`. The results will be grouped by timeseries.
417-
418-
Or we can also use the [`TS.MGET`]({{< relref "commands/ts.mget/" >}}) command to get the last sample that matches the specific filter:
419-
420-
```
421-
TS.MGET FILTER area_id=32
422-
```
423-
424-
### Filtering by value
425-
We can filter by value across a single or multiple timeseries:
426-
427-
```
428-
TS.RANGE sensor1 - + FILTER_BY_VALUE 25 30
429-
```
430-
This command will return all data points whose value sits between 25 and 30, inclusive.
431-
432-
To achieve the same filtering on multiple series we have to combine the filtering by value with filtering by label:
433-
434-
```
435-
TS.MRANGE - + FILTER_BY_VALUE 20 30 FILTER region=east
436-
```
437-
438-
### Filtering by timestamp
439-
To retrieve the datapoints for specific timestamps on one or multiple timeseries we can use the `FILTER_BY_TS` argument:
440-
441-
Filter on one timeseries:
442-
```
443-
TS.RANGE sensor1 - + FILTER_BY_TS 1626435230501 1626443276598
444-
```
445-
446-
Filter on multiple timeseries:
447-
```
448-
TS.MRANGE - + FILTER_BY_TS 1626435230501 1626443276598 FILTER region=east
449-
```
450-
451-
452352
## Aggregation
453353
It's possible to combine values of one or more timeseries by leveraging aggregation functions:
454354
```
@@ -558,6 +458,59 @@ TS.CREATERULE sensor1 sensor1_compacted AGGREGATION avg 60000 # Create the rul
558458

559459
With this creation rule, datapoints added to the `sensor1` timeseries will be grouped into buckets of 60 seconds (60000ms), averaged, and saved in the `sensor1_compacted` timeseries.
560460

461+
## Deleting data points
462+
463+
Use [`TS.DEL`]({{< relref "commands/ts.del/" >}}) to delete data points
464+
that fall within a given timestamp range. The range is inclusive, meaning that
465+
samples whose timestamp equals the start or end of the range are deleted.
466+
If you want to delete a single timestamp, use it as both the start and end of the range.
467+
468+
```bash
469+
> TS.INFO thermometer:1
470+
1) totalSamples
471+
2) (integer) 2
472+
3) memoryUsage
473+
4) (integer) 4856
474+
5) firstTimestamp
475+
6) (integer) 1
476+
7) lastTimestamp
477+
8) (integer) 2
478+
.
479+
.
480+
> TS.ADD thermometer:1 3 9.7
481+
(integer) 3
482+
127.0.0.1:6379> TS.INFO thermometer:1
483+
1) totalSamples
484+
2) (integer) 3
485+
3) memoryUsage
486+
4) (integer) 4856
487+
5) firstTimestamp
488+
6) (integer) 1
489+
7) lastTimestamp
490+
8) (integer) 3
491+
.
492+
.
493+
> TS.DEL thermometer:1 1 2
494+
(integer) 2
495+
> TS.INFO thermometer:1
496+
1) totalSamples
497+
2) (integer) 1
498+
3) memoryUsage
499+
4) (integer) 4856
500+
5) firstTimestamp
501+
6) (integer) 3
502+
7) lastTimestamp
503+
8) (integer) 3
504+
.
505+
.
506+
> TS.DEL thermometer:1 3 3
507+
(integer) 1
508+
> TS.INFO thermometer:1
509+
1) totalSamples
510+
2) (integer) 0
511+
.
512+
.
513+
```
561514

562515
## Using with other metrics tools
563516

0 commit comments

Comments
 (0)