redis-py
redis-py copied to clipboard
labels not working in timeseries
Version: Latest I guess, installed from pypi, redis is docker container, also latest
Platform: Ubuntu 22.04
Description:
I do not get any labels, no matter what I try. I tried from the documentation:
import redis
r = redis.Redis(host='localhost', port=6379, db=0)
ts = r.ts()
print(r.ping())
try:
r.execute_command('TS.CREATE', 'ts_key', labels={"label1": 1, "label2": 2}, duplicate_policy="LAST")
print("created")
except redis.exceptions.ResponseError as e:
# Ignore error if the timeseries already exists
if "already exists" not in str(e):
raise
#print(ts.add("ts_key", 1657265437756, 1, duplicate_policy="LAST"))
#print(ts.add("ts_key", "1657265437757", 2, duplicate_policy="LAST"))
#print(ts.add("ts_key", 1657265437754, 5, labels={"label1": 1, "label2": 2}, duplicate_policy="LAST"))
#print(ts.add("ts_key", 1657265437759, 17, labels={"label1": 3, "label2": 4}, duplicate_policy="LAST"))
print(r.execute_command('TS.ADD', 'ts_key', 1657265437756, 1, "LABELS", "label1", 1, "label2", 2, "DUPLICATE_POLICY", "LAST"))
print(r.execute_command('TS.ADD', 'ts_key', 1657265437757, 2, "LABELS", "label1", 1, "label2", 2, "DUPLICATE_POLICY", "LAST"))
print(r.execute_command('TS.ADD', 'ts_key', 1657265437754, 5, "LABELS", "label1", 1, "label2", 2, "DUPLICATE_POLICY", "LAST"))
print(r.execute_command('TS.ADD', 'ts_key', 1657265437759, 17, "LABELS", "label1", 3, "label2", 4, "DUPLICATE_POLICY", "LAST"))
print(ts.range("ts_key", "-", "+"))
print(ts.mget(["label1=1"], with_labels=True))
print(ts.mget(["label1=1"]))
results in
True
created
1657265437756
1657265437757
1657265437754
1657265437759
[(1657265437754, 5.0), (1657265437756, 1.0), (1657265437757, 2.0), (1657265437759, 17.0)]
[]
[]
No labels. Is it a problem or am I doing anything wrong ?