Search code examples
pythonredistime-seriesredis-pyredistimeseries

How to use "mrange" function in Python module "redis-py"?


I'm trying to get used to the redis-py Python module. I just can't figure out how the "mrange" function has to be used to get one or more Time-Series by its labels.

In the CLI it looks like this and it works:

TS.MRANGE - + FILTER area_id=32

But I can't get it to work in Python (one of many things that I tried):

import redis

r = redis.Redis()

r.ts().mrange("-","+","area_id:32")
r.ts().mrange("-","+",filters="area_id:32")
r.ts().mrange("-","+",filters='{area_id}32')

#And I tried many more...

I get the following Error:

ResponseError: TSDB: failed parsing labels

Solution

  • r.ts().mrange('-','+',['area_id=32'])

    you need [square brackets]