Skip to content

Commit 9b39d9d

Browse files
Merge pull request #1856 from redis/DOC-5424-add-tces
DOC-5424 enabled TCEs in time series page
2 parents ad9f81d + 44bf162 commit 9b39d9d

File tree

1 file changed

+31
-36
lines changed
  • content/develop/data-types/timeseries

1 file changed

+31
-36
lines changed

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

Lines changed: 31 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,7 @@ command, specifying a key name. Alternatively, if you use [`TS.ADD`]({{< relref
5757
to add data to a time series key that does not exist, it is automatically created (see
5858
[Adding data points](#adding-data-points) below for more information about `TS.ADD`).
5959

60-
<!--< clients-example time_series_tutorial create >}}-->
61-
```bash
60+
{{< clients-example time_series_tutorial create >}}
6261
> TS.CREATE thermometer:1
6362
OK
6463
> TYPE thermometer:1
@@ -68,8 +67,7 @@ TSDB-TYPE
6867
2) (integer) 0
6968
.
7069
.
71-
```
72-
<!--< /clients-example >}}-->
70+
{{< /clients-example >}}
7371

7472
The timestamp for each data point is a 64-bit integer value. The value
7573
represents a Unix timestamp, measured in milliseconds since the
@@ -78,10 +76,8 @@ When you create a time series, you can specify a maximum retention period for th
7876
data, relative to the last reported timestamp. A retention period of zero means
7977
the data does not expire.
8078

81-
<!--< clients-example time_series_tutorial create_retention >}} -->
82-
```bash
83-
# Create a new time series with a first value of 10.8 (Celsius),
84-
# recorded at time 1, with a retention period of 100ms.
79+
{{< clients-example time_series_tutorial create_retention >}}
80+
# Create a new time series with a first value of 10.8 (Celsius), recorded at time 1, with a retention period of 100ms.
8581
> TS.ADD thermometer:2 1 10.8 RETENTION 100
8682
(integer) 1
8783
> TS.INFO thermometer:2
@@ -91,15 +87,14 @@ the data does not expire.
9187
10) (integer) 100
9288
.
9389
.
94-
```
95-
<!--< /clients-example >}}-->
90+
{{< /clients-example >}}
9691

9792
You can also add one or more *labels* to a time series when you create it. Labels
9893
are name-value pairs where both the name and value are strings. You can use
9994
the names and values to select subsets of all the available time series
10095
for queries and aggregations.
10196

102-
<!--< clients-example time_series_tutorial create_labels >}} -->
97+
{{< clients-example time_series_tutorial create_labels >}}
10398
```bash
10499
> TS.ADD thermometer:3 1 10.4 LABELS location UK type Mercury
105100
(integer) 1
@@ -118,7 +113,7 @@ for queries and aggregations.
118113
.
119114
.
120115
```
121-
<!-- < /clients-example >}} -->
116+
{{< /clients-example >}}
122117

123118
## Add data points
124119

@@ -130,29 +125,29 @@ is an array containing the number of samples in each time series after the opera
130125
If you use the `*` character as the timestamp, Redis will record the current
131126
Unix time, as reported by the server's clock.
132127

133-
<!-- < clients-example time_series_tutorial madd >}} -->
128+
{{< clients-example time_series_tutorial madd >}}
134129
```bash
135130
> TS.MADD thermometer:1 1 9.2 thermometer:1 2 9.9 thermometer:2 2 10.3
136131
1) (integer) 1
137132
2) (integer) 2
138133
3) (integer) 2
139134
```
140-
<!-- < /clients-example >}} -->
135+
{{< /clients-example >}}
141136

142137
## Query data points
143138

144139
Use [`TS.GET`]({{< relref "commands/ts.get/" >}}) to retrieve the data point
145140
with the highest timestamp in a time series. This returns both the timestamp and the value.
146141

147-
<!-- < clients-example time_series_tutorial get >}} -->
142+
{{< clients-example time_series_tutorial get >}}
148143
```bash
149144
# The last recorded temperature for thermometer:2
150145
# was 10.3 at time 2ms.
151146
> TS.GET thermometer:2
152147
1) (integer) 2
153148
2) 10.3
154149
```
155-
<!-- < /clients-example >}} -->
150+
{{< /clients-example >}}
156151

157152
Use [`TS.RANGE`]({{< relref "commands/ts.range/" >}}) to retrieve data points
158153
from a time series that fall within a given timestamp range. The range is inclusive,
@@ -162,7 +157,7 @@ indicate the minimum and maximum timestamps in the series. The response is
162157
an array of timestamp-value pairs returned in ascending order by timestamp.
163158
If you want the results in descending order, use [`TS.REVRANGE`]({{< relref "commands/ts.revrange/" >}}) with the same parameters.
164159

165-
<!-- < clients-example time_series_tutorial range >}} -->
160+
{{< clients-example time_series_tutorial range >}}
166161
```bash
167162
# Add 5 data points to a time series named "rg:1".
168163
> TS.CREATE rg:1
@@ -222,7 +217,7 @@ OK
222217
2) 1) (integer) 0
223218
2) 18
224219
```
225-
<!-- < /clients-example >}} -->
220+
{{< /clients-example >}}
226221

227222
Both `TS.RANGE` and `TS.REVRANGE` also let you filter results. Specify
228223
a list of timestamps to include only samples with those exact timestamps
@@ -231,7 +226,7 @@ use this option). Specify a minimum and maximum value to include only
231226
samples within that range. The value range is inclusive and you can
232227
use the same value for the minimum and maximum to filter for a single value.
233228

234-
<!-- < clients-example time_series_tutorial range_filter >}} -->
229+
{{< clients-example time_series_tutorial range_filter >}}
235230
```bash
236231
> TS.RANGE rg:1 - + FILTER_BY_TS 0 2 4
237232
1) 1) (integer) 0
@@ -249,7 +244,7 @@ use the same value for the minimum and maximum to filter for a single value.
249244
1) 1) (integer) 2
250245
2) 22
251246
```
252-
<!-- < /clients-example >}} -->
247+
{{< /clients-example >}}
253248

254249
### Query multiple time series
255250

@@ -273,7 +268,7 @@ the presence or value of a label. See the description in the
273268
for details of the filter syntax. You can also request that
274269
data points be returned with all their labels or with a selected subset of them.
275270

276-
<!-- < clients-example time_series_tutorial query_multi >}} -->
271+
{{< clients-example time_series_tutorial query_multi >}}
277272
```bash
278273
# Create three new "rg:" time series (two in the US
279274
# and one in the UK, with different units) and add some
@@ -372,7 +367,7 @@ OK
372367
3) 1) (integer) 1
373368
2) 18
374369
```
375-
<!-- < /clients-example >}} -->
370+
{{< /clients-example >}}
376371

377372
## Aggregation
378373

@@ -405,7 +400,7 @@ For example, the example below shows an aggregation with the `avg` function over
405400
five data points in the `rg:2` time series. The bucket size is 2ms, so there are three
406401
aggregated values with only one value used to calculate the average for the last bucket.
407402

408-
<!-- < clients-example time_series_tutorial agg >}} -->
403+
{{< clients-example time_series_tutorial agg >}}
409404
```bash
410405
> TS.RANGE rg:2 - + AGGREGATION avg 2
411406
1) 1) (integer) 0
@@ -415,7 +410,7 @@ aggregated values with only one value used to calculate the average for the last
415410
3) 1) (integer) 4
416411
2) 1.78
417412
```
418-
<!-- < /clients-example >}} -->
413+
{{< /clients-example >}}
419414

420415
### Bucket alignment
421416

@@ -424,7 +419,7 @@ the first bucket in the sequence starts. By default, the reference timestamp is
424419
For example, the following commands create a time series and apply a `min` aggregation
425420
with a bucket size of 25 milliseconds at the default zero alignment.
426421

427-
<!-- < clients-example time_series_tutorial agg_bucket >}} -->
422+
{{< clients-example time_series_tutorial agg_bucket >}}
428423
```bash
429424
> TS.CREATE sensor3
430425
OK
@@ -444,7 +439,7 @@ OK
444439
3) 1) (integer) 50
445440
2) 5000
446441
```
447-
<!-- < /clients-example >}} -->
442+
{{< /clients-example >}}
448443

449444
The diagram below shows the aggregation buckets and their alignment to the reference timestamp
450445
at time zero.
@@ -460,7 +455,7 @@ Bucket(25ms): |_________________________||_________________________||___________
460455

461456
You can also align the buckets to the start or end of the query range. For example, the following command aligns the buckets to the start of the query range at time 10.
462457

463-
<!-- < clients-example time_series_tutorial agg_align >}} -->
458+
{{< clients-example time_series_tutorial agg_align >}}
464459
```bash
465460
> TS.RANGE sensor3 10 70 AGGREGATION min 25 ALIGN start
466461
1) 1) (integer) 10
@@ -470,7 +465,7 @@ You can also align the buckets to the start or end of the query range. For examp
470465
3) 1) (integer) 60
471466
2) 6000
472467
```
473-
<!-- < /clients-example >}} -->
468+
{{< /clients-example >}}
474469

475470
The diagram below shows this arrangement of buckets.
476471

@@ -492,7 +487,7 @@ that have the same timestamp and the same label value (this feature is available
492487

493488
For example, the following commands create four time series, two for the UK and two for the US, and add some data points. The first `TS.MRANGE` command groups the results by country and applies a `max` aggregation to find the maximum sample value in each country at each timestamp. The second `TS.MRANGE` command uses the same grouping, but applies an `avg` aggregation.
494489

495-
<!-- < clients-example time_series_tutorial agg_multi >}} -->
490+
{{< clients-example time_series_tutorial agg_multi >}}
496491
```bash
497492
> TS.CREATE wind:1 LABELS country uk
498493
OK
@@ -558,7 +553,7 @@ OK
558553
3) 1) (integer) 3
559554
2) 13
560555
```
561-
<!-- < /clients-example >}} -->
556+
{{< /clients-example >}}
562557

563558
## Compaction
564559

@@ -580,7 +575,7 @@ only process data that is added to the source series after you create the rule.
580575
For example, you could use the commands below to create a time series along with a
581576
compaction rule to find the minimum reading in each period of 3ms.
582577

583-
<!-- < clients-example time_series_tutorial create_compaction >}} -->
578+
{{< clients-example time_series_tutorial create_compaction >}}
584579
```bash
585580
# The source time series.
586581
> TS.CREATE hyg:1
@@ -609,14 +604,14 @@ OK
609604
.
610605
.
611606
```
612-
<!-- < /clients-example >}} -->
607+
{{< /clients-example >}}
613608

614609
Adding data points within the first 3ms (the first bucket) doesn't
615610
produce any data in the compacted series. However, when you add data for
616611
time 4 (in the second bucket), the compaction rule computes the minimum
617612
value for the first bucket and adds it to the compacted series.
618613

619-
<!-- < clients-example time_series_tutorial comp_add >}} -->
614+
{{< clients-example time_series_tutorial comp_add >}}
620615
```bash
621616
> TS.MADD hyg:1 0 75 hyg:1 1 77 hyg:1 2 78
622617
1) (integer) 0
@@ -630,7 +625,7 @@ value for the first bucket and adds it to the compacted series.
630625
1) 1) (integer) 0
631626
2) 75
632627
```
633-
<!-- < /clients-example >}} -->
628+
{{< /clients-example >}}
634629

635630
The general strategy is that the rule does not add data to the
636631
compaction for the latest bucket in the source series, but will add and
@@ -649,7 +644,7 @@ that fall within a given timestamp range. The range is inclusive, meaning that
649644
samples whose timestamp equals the start or end of the range are deleted.
650645
If you want to delete a single timestamp, use it as both the start and end of the range.
651646

652-
<!-- < clients-example time_series_tutorial del >}} -->
647+
{{< clients-example time_series_tutorial del >}}
653648
```bash
654649
> TS.INFO thermometer:1
655650
1) totalSamples
@@ -696,7 +691,7 @@ If you want to delete a single timestamp, use it as both the start and end of th
696691
.
697692
.
698693
```
699-
<!-- < /clients-example >}} -->
694+
{{< /clients-example >}}
700695

701696
## Use time series with other metrics tools
702697

0 commit comments

Comments
 (0)