Skip to content

Commit 98bb561

Browse files
DOC-5424 added TCE placeholder comments
1 parent e2cd2f3 commit 98bb561

File tree

1 file changed

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

1 file changed

+31
-1
lines changed

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

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

53+
<!--< clients-example time_series_tutorial create >}}-->
5354
```bash
5455
> TS.CREATE thermometer:1
5556
OK
@@ -61,6 +62,7 @@ TSDB-TYPE
6162
.
6263
.
6364
```
65+
<!--< /clients-example >}}-->
6466

6567
The timestamp for each data point is a 64-bit integer value. The value
6668
represents a Unix timestamp, measured in milliseconds since the
@@ -69,6 +71,7 @@ When you create a time series, you can specify a maximum retention period for th
6971
data, relative to the last reported timestamp. A retention period of zero means
7072
the data does not expire.
7173

74+
<!--< clients-example time_series_tutorial create_retention >}} -->
7275
```bash
7376
# Create a new time series with a first value of 10.8 (Celsius),
7477
# recorded at time 1, with a retention period of 100ms.
@@ -82,12 +85,14 @@ the data does not expire.
8285
.
8386
.
8487
```
88+
<!--< /clients-example >}}-->
8589

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

95+
<!--< clients-example time_series_tutorial create_labels >}} -->
9196
```bash
9297
> TS.ADD thermometer:3 1 10.4 LABELS location UK type Mercury
9398
(integer) 1
@@ -106,6 +111,7 @@ for queries and aggregations.
106111
.
107112
.
108113
```
114+
<!-- < /clients-example >}} -->
109115

110116
## Add data points
111117

@@ -117,25 +123,29 @@ is an array containing the number of samples in each time series after the opera
117123
If you use the `*` character as the timestamp, Redis will record the current
118124
Unix time, as reported by the server's clock.
119125

126+
<!-- < clients-example time_series_tutorial madd >}} -->
120127
```bash
121128
> TS.MADD thermometer:1 1 9.2 thermometer:1 2 9.9 thermometer:2 2 10.3
122129
1) (integer) 1
123130
2) (integer) 2
124131
3) (integer) 2
125132
```
133+
<!-- < /clients-example >}} -->
126134

127135
## Query data points
128136

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

140+
<!-- < clients-example time_series_tutorial get >}} -->
132141
```bash
133142
# The last recorded temperature for thermometer:2
134143
# was 10.3 at time 2ms.
135144
> TS.GET thermometer:2
136145
1) (integer) 2
137146
2) 10.3
138147
```
148+
<!-- < /clients-example >}} -->
139149

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

158+
<!-- < clients-example time_series_tutorial range >}} -->
148159
```bash
149160
# Add 5 data points to a time series named "rg:1".
150161
> TS.CREATE rg:1
@@ -204,6 +215,7 @@ OK
204215
2) 1) (integer) 0
205216
2) 18
206217
```
218+
<!-- < /clients-example >}} -->
207219

208220
Both `TS.RANGE` and `TS.REVRANGE` also let you filter results. Specify
209221
a list of timestamps to include only samples with those exact timestamps
@@ -212,6 +224,7 @@ use this option). Specify a minimum and maximum value to include only
212224
samples within that range. The value range is inclusive and you can
213225
use the same value for the minimum and maximum to filter for a single value.
214226

227+
<!-- < clients-example time_series_tutorial range_filter >}} -->
215228
```bash
216229
> TS.RANGE rg:1 - + FILTER_BY_TS 0 2 4
217230
1) 1) (integer) 0
@@ -229,6 +242,7 @@ use the same value for the minimum and maximum to filter for a single value.
229242
1) 1) (integer) 2
230243
2) 22
231244
```
245+
<!-- < /clients-example >}} -->
232246

233247
### Query multiple time series
234248

@@ -252,8 +266,9 @@ the presence or value of a label. See the description in the
252266
for details of the filter syntax. You can also request that
253267
data points be returned with all their labels or with a selected subset of them.
254268

269+
<!-- < clients-example time_series_tutorial query_multi >}} -->
255270
```bash
256-
# Create three new "rg: time series (two in the US
271+
# Create three new "rg:" time series (two in the US
257272
# and one in the UK, with different units) and add some
258273
# data points.
259274
> TS.CREATE rg:2 LABELS location us unit cm
@@ -350,6 +365,7 @@ OK
350365
3) 1) (integer) 1
351366
2) 18
352367
```
368+
<!-- < /clients-example >}} -->
353369

354370
## Aggregation
355371

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

401+
<!-- < clients-example time_series_tutorial agg >}} -->
385402
```bash
386403
> TS.RANGE rg:2 - + AGGREGATION avg 2
387404
1) 1) (integer) 0
@@ -391,6 +408,7 @@ aggregated values with only one value used to calculate the average for the last
391408
3) 1) (integer) 4
392409
2) 1.78
393410
```
411+
<!-- < /clients-example >}} -->
394412

395413
### Bucket alignment
396414

@@ -399,6 +417,7 @@ the first bucket in the sequence starts. By default, the reference timestamp is
399417
For example, the following commands create a time series and apply a `min` aggregation
400418
with a bucket size of 25 milliseconds at the default zero alignment.
401419

420+
<!-- < clients-example time_series_tutorial agg_bucket >}} -->
402421
```bash
403422
> TS.CREATE sensor3
404423
OK
@@ -418,6 +437,7 @@ OK
418437
3) 1) (integer) 50
419438
2) 5000
420439
```
440+
<!-- < /clients-example >}} -->
421441

422442
The diagram below shows the aggregation buckets and their alignment to the reference timestamp
423443
at time zero.
@@ -433,6 +453,7 @@ Bucket(25ms): |_________________________||_________________________||___________
433453

434454
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.
435455

456+
<!-- < clients-example time_series_tutorial agg_align >}} -->
436457
```bash
437458
> TS.RANGE sensor3 10 70 AGGREGATION min 25 ALIGN start
438459
1) 1) (integer) 10
@@ -442,6 +463,7 @@ You can also align the buckets to the start or end of the query range. For examp
442463
3) 1) (integer) 60
443464
2) 6000
444465
```
466+
<!-- < /clients-example >}} -->
445467

446468
The diagram below shows this arrangement of buckets.
447469

@@ -463,6 +485,7 @@ that have the same timestamp and the same label value (this feature is available
463485

464486
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.
465487

488+
<!-- < clients-example time_series_tutorial agg_multi >}} -->
466489
```bash
467490
> TS.CREATE wind:1 LABELS country uk
468491
OK
@@ -528,6 +551,7 @@ OK
528551
3) 1) (integer) 3
529552
2) 13
530553
```
554+
<!-- < /clients-example >}} -->
531555

532556
## Compaction
533557

@@ -549,6 +573,7 @@ only process data that is added to the source series after you create the rule.
549573
For example, you could use the commands below to create a time series along with a
550574
compaction rule to find the minimum reading in each period of 3ms.
551575

576+
<!-- < clients-example time_series_tutorial create_compaction >}} -->
552577
```bash
553578
# The source time series.
554579
> TS.CREATE hyg:1
@@ -577,12 +602,14 @@ OK
577602
.
578603
.
579604
```
605+
<!-- < /clients-example >}} -->
580606

581607
Adding data points within the first 3ms (the first bucket) doesn't
582608
produce any data in the compacted series. However, when you add data for
583609
time 4 (in the second bucket), the compaction rule computes the minimum
584610
value for the first bucket and adds it to the compacted series.
585611

612+
<!-- < clients-example time_series_tutorial comp_add >}} -->
586613
```bash
587614
> TS.MADD hyg:1 0 75 hyg:1 1 77 hyg:1 2 78
588615
1) (integer) 0
@@ -596,6 +623,7 @@ value for the first bucket and adds it to the compacted series.
596623
1) 1) (integer) 0
597624
2) 75
598625
```
626+
<!-- < /clients-example >}} -->
599627

600628
The general strategy is that the rule does not add data to the
601629
compaction for the latest bucket in the source series, but will add and
@@ -614,6 +642,7 @@ that fall within a given timestamp range. The range is inclusive, meaning that
614642
samples whose timestamp equals the start or end of the range are deleted.
615643
If you want to delete a single timestamp, use it as both the start and end of the range.
616644

645+
<!-- < clients-example time_series_tutorial del >}} -->
617646
```bash
618647
> TS.INFO thermometer:1
619648
1) totalSamples
@@ -660,6 +689,7 @@ If you want to delete a single timestamp, use it as both the start and end of th
660689
.
661690
.
662691
```
692+
<!-- < /clients-example >}} -->
663693

664694
## Use time series with other metrics tools
665695

0 commit comments

Comments
 (0)