Connection issue when trying to collect Redis metrics with a Metricbeat Redis module through a Unix socket connection
- Dominant language
- Go
- Stars
- 12.7k
- Forks
- 5k
- Avg merge
- 2d 15m
- Merged PRs (30d)
- 385
Description
# Connection issue when trying to collect Redis metrics through Unix socket connection
When trying to collect metrics from a Redis database, only reachable through a Unix socket connection, with the following Metricbeat configuration (Redis module in v8.17 in a Linux environment):
```yaml
- module: redis
metricsets: ["info", "keyspace"]
hosts: ["unix:///var/run/redis/redis.sock"]
network: unix
```
The following log messages are generated:
```
failed to create 'info':
failed to parse username, password and dbNumber from URI:
redis database in url should be an integer, found: /var/run/redis/redis.sock:
strconv.Atoi: parsing "/var/run/redis/redis.sock": invalid syntax
```
We suppose that the Redis module cannot use absolute paths.
Our current work around solution, is to create a symbolic link within the /usr/share/metricbeat folder:
```shell
ln -s /var/run/redis/redis.sock redis.sock
```
And to use a relative path in its Metricbeat configuration:
```yaml
- module: redis
metricsets: ["info", "keyspace"]
hosts: ["unix://redis.sock"]
network: unix
```
The [documentation](https://www.elastic.co/docs/reference/beats/metricbeat/metricbeat-module-redis) is not very clear if this method is supported and which other method than TCP are available:
```
hosts
URLs that are used to connect to Redis. URL format: redis://[:password@]host[:port][/db-number][?option=value] redis://HOST[:PORT][?password=PASSWORD[&db=DATABASE]]
network
The network type to be used for the Redis connection. The default value is tcp.
```
To my understanding Redis supports TCP and Unix sockets. Should Metricbeat do the same?
Contributor guide
Research direction
Start with the Metricbeat Redis module's connection handling and reproduce the supplied configuration using an absolute Unix socket path. Compare it with the relative-path workaround; done means the documented Unix socket connection works as expected or the supported limitation is clearly documented.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, redis
- Domain
- observability-sre
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100