How to collect "key" metrics with metricbeat from Redis running in docker container with labels (auto discovery)

  docker, docker-compose, elastic-stack, metricbeat, redis

I’m trying to collect all Redis metrics in docker container with metricbeat.
This is my Redis service definition from docker-compose:

    image: redis:6.0.8-alpine
      - co.elastic.metrics/module=redis
      - co.elastic.metrics/hosts='redis://$${}:$${data.port}'
      - co.elastic.metrics/metricsets=info,key,keyspace
      - co.elastic.metrics/period=10s

When I start the container metricbeat reports this error:

ERROR   [autodiscover]  autodiscover/autodiscover.go:209    Auto discover config check failed for config '{
  "enabled": true,
  "hosts": [
  "metricsets": [
  "module": "redis",
  "period": "10s",
  "timeout": "3s"
}', won't start runner: 1 error: failed to read configuration for 'key' metricset: missing required field accessing 'key.patterns'

Without key metric everything is working as expected.

How can I define key.patterns from with label? Is it possible?

I’ve tried with co.elastic.metrics/key.patterns but it does not work

Source: Docker Questions