{
  "id": "ts.querylabels",
  "title": "TS.QUERYLABELS",
  "url": "https://redis.io/docs/latest/commands/ts.querylabels/",
  "summary": "Get all label names, or all values of a given label, for time series matching a filter list, or all series",
  "tags": [
    "docs",
    "develop",
    "stack",
    "oss",
    "rs",
    "rc",
    "oss",
    "kubernetes",
    "clients"
  ],
  "last_updated": "2026-07-30T08:54:30-07:00",
  "page_type": "content",
  "content_hash": "ff818ccbe1eab73f0f9b17a66a570e3126b30545b0b52973832889ce1f7141ce",
  "sections": [
    {
      "id": "overview",
      "title": "Overview",
      "role": "overview",
      "text": "This command's behavior varies in clustered Redis environments. See the [multi-key operations](https://redis.io/docs/latest/develop/using-commands/multi-key-operations) page for more information.\n\n\nGet all label names, or all values of a given label, for the time series matching a filter list (or all series when no filter is given).\n\n[Examples](#examples)"
    },
    {
      "id": "required-arguments",
      "title": "Required arguments",
      "role": "content",
      "text": "<details open>\n<summary><code>LABELS | VALUES label</code></summary>\n\nselects what the command returns:\n\n  - `LABELS` - returns the set of distinct label names used by the matching time series.\n  - `VALUES label` - returns the set of distinct values of `label` used by the matching time series. The result is empty (not an error) when `label` does not exist or when no matching series carries it.\n\nEach name or value appears at most once, regardless of how many series it belongs to. The order of the results is not defined.\n</details>"
    },
    {
      "id": "optional-arguments",
      "title": "Optional arguments",
      "role": "parameters",
      "text": "<details open>\n<summary><code>FILTER filterExpr [filterExpr ...]</code></summary>\n\nrestricts the command to the time series whose labels and label values match all of the filter expressions. When `FILTER` is omitted, the command considers all indexed time series.\n\nEach filter expression has one of the following syntaxes:\n\n  - `label!=` - the time series has a label named `label`\n  - `label=value` - the time series has a label named `label` with a value equal to `value`\n  - `label=(value1,value2,...)` - the time series has a label named `label` with a value equal to one of the values in the list\n  - `label=` - the time series does not have a label named `label`\n  - `label!=value` - the time series does not have a label named `label` with a value equal to `value`\n  - `label!=(value1,value2,...)` - the time series does not have a label named `label` with a value equal to any of the values in the list\n\n  <note><b>Notes:</b>\n   - At least one filter expression with a syntax `label=value` or `label=(value1,value2,...)` is required.\n   - Filter expressions are conjunctive. For example, the filter `type=temperature room=study` means that `type=temperature` AND `room=study`.\n   - Whitespace is not allowed in a filter expression except between quotes or double quotes in values - for example, `x=\"y y\"` or `x='(y y,z z)'`.\n   </note>\n\n</details>"
    },
    {
      "id": "examples",
      "title": "Examples",
      "role": "example",
      "text": "<details open>\n<summary><b>List labels and label values for a set of sensors</b></summary>\n\nCreate a set of sensors to measure temperature and humidity in your study and kitchen.\n\n[code example]\n\nRetrieve the label names used by the time series located in the kitchen.\n\n[code example]\n\nRetrieve the distinct values of the `type` label across all time series.\n\n[code example]\n</details>"
    },
    {
      "id": "details",
      "title": "Details",
      "role": "content",
      "text": ""
    },
    {
      "id": "access-control",
      "title": "Access control",
      "role": "content",
      "text": "Unlike [`TS.QUERYINDEX`](https://redis.io/docs/latest/commands/ts.queryindex/), which lists every matching key whether or not the user has read access to it, `TS.QUERYLABELS` silently omits the time series that the user is not allowed to read. Label names and values that belong only to unreadable series do not appear in the result."
    },
    {
      "id": "redis-software-and-redis-cloud-compatibility",
      "title": "Redis Software and Redis Cloud compatibility",
      "role": "content",
      "text": "| Redis<br />Software | Redis<br />Cloud | <span style=\"min-width: 9em; display: table-cell\">Notes</span> |\n|:----------------------|:-----------------|:------|\n| <span title=\"Not supported\">&#x274c; Standard</span><br /><span title=\"Not supported\"><nobr>&#x274c; Active-Active</nobr></span> | <span title=\"Not supported\">&#x274c; Standard</span><br /><span title=\"Not supported\"><nobr>&#x274c; Active-Active</nobr></span> |  |"
    },
    {
      "id": "return-information",
      "title": "Return information",
      "role": "returns",
      "text": "**RESP2:**\n\nOne of the following:\n* [Array reply](https://redis.io/docs/latest/develop/reference/protocol-spec#arrays) where each element is a [Bulk string reply](https://redis.io/docs/latest/develop/reference/protocol-spec#bulk-strings): a label name (with `LABELS`) or a label value (with `VALUES`). The array is empty if no time series matches the filter.\n* [Simple error reply](https://redis.io/docs/latest/develop/reference/protocol-spec#simple-errors) in these cases: invalid subtype, missing label after `VALUES`, or invalid filter expression.\n\n**RESP3:**\n\nOne of the following:\n* [Set reply](https://redis.io/docs/latest/develop/reference/protocol-spec#sets) where each element is a [Bulk string reply](https://redis.io/docs/latest/develop/reference/protocol-spec#bulk-strings): a label name (with `LABELS`) or a label value (with `VALUES`). The set is empty if no time series matches the filter.\n* [Simple error reply](https://redis.io/docs/latest/develop/reference/protocol-spec#simple-errors) in these cases: invalid subtype, missing label after `VALUES`, or invalid filter expression."
    },
    {
      "id": "see-also",
      "title": "See also",
      "role": "related",
      "text": "[`TS.QUERYINDEX`](https://redis.io/docs/latest/commands/ts.queryindex/) | [`TS.CREATE`](https://redis.io/docs/latest/commands/ts.create/) | [`TS.MGET`](https://redis.io/docs/latest/commands/ts.mget/) | [`TS.MRANGE`](https://redis.io/docs/latest/commands/ts.mrange/)"
    },
    {
      "id": "related-topics",
      "title": "Related topics",
      "role": "related",
      "text": "[RedisTimeSeries](https://redis.io/docs/latest/develop/data-types/timeseries/)"
    }
  ],
  "examples": [
    {
      "id": "examples-ex0",
      "language": "plaintext",
      "code": "redis> TS.CREATE telemetry:study:temperature LABELS room study type temperature\nOK\nredis> TS.CREATE telemetry:study:humidity LABELS room study type humidity\nOK\nredis> TS.CREATE telemetry:kitchen:temperature LABELS room kitchen type temperature\nOK\nredis> TS.CREATE telemetry:kitchen:humidity LABELS room kitchen type humidity\nOK",
      "section_id": "examples"
    },
    {
      "id": "examples-ex1",
      "language": "plaintext",
      "code": "redis> TS.QUERYLABELS LABELS FILTER room=kitchen\n1) \"room\"\n2) \"type\"",
      "section_id": "examples"
    },
    {
      "id": "examples-ex2",
      "language": "plaintext",
      "code": "redis> TS.QUERYLABELS VALUES type\n1) \"humidity\"\n2) \"temperature\"",
      "section_id": "examples"
    }
  ]
}
