Skip to content

Commit 17123f3

Browse files
committed
Adding username parameter for connecting to redis
1 parent 788af04 commit 17123f3

File tree

5 files changed

+12
-2
lines changed

5 files changed

+12
-2
lines changed

receiver/redisreceiver/config.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,14 @@ type Config struct {
2020

2121
// TODO allow users to add additional resource key value pairs?
2222

23+
// Optional username. Use the specified Username to authenticate the current connection
24+
// with one of the connections defined in the ACL list when connecting
25+
// to a Redis 6.0 instance, or greater, that is using the Redis ACL system.
26+
Username string `mapstructure:"username"`
27+
2328
// Optional password. Must match the password specified in the
24-
// requirepass server configuration option.
29+
// requirepass server configuration option, or the user's password when connecting
30+
// to a Redis 6.0 instance, or greater, that is using the Redis ACL system.
2531
Password configopaque.String `mapstructure:"password"`
2632

2733
TLS configtls.TLSClientSetting `mapstructure:"tls,omitempty"`

receiver/redisreceiver/config.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ and extend it with more fields if needed.
1212
| collection_interval |[time-Duration](#time-Duration)| 10s | |
1313
| endpoint |string| | Endpoint configures the address for this network connection. For TCP and UDP networks, the address has the form "host:port". The host must be a literal IP address, or a host name that can be resolved to IP addresses. The port must be a literal port number or a service name. If the host is a literal IPv6 address it must be enclosed in square brackets, as in "[2001:db8::1]:80" or "[fe80::1%zone]:80". The zone specifies the scope of the literal IPv6 address as defined in RFC 4007. |
1414
| transport |string| tcp | Transport to use. Known protocols are "tcp", "tcp4" (IPv4-only), "tcp6" (IPv6-only), "udp", "udp4" (IPv4-only), "udp6" (IPv6-only), "ip", "ip4" (IPv4-only), "ip6" (IPv6-only), "unix", "unixgram" and "unixpacket". |
15-
| password |string| | Optional password. Must match the password specified in the requirepass server configuration option. |
15+
| username |string| | Optional username. Use the specified username to authenticate the current connection with one of the connections defined in the ACL list when connecting to a Redis 6.0 instance, or greater, that is using the Redis ACL system. |
16+
| password |string| | Optional password. Must match the password specified in the requirepass server configuration option or the user's password when connecting to a Redis 6.0 instance, or greater, that is using the Redis ACL system. |
1617
| tls |[tls-TLSClientSetting](#tls-TLSClientSetting)| <no value> | TLSClientSetting contains TLS configurations that are specific to client connections in addition to the common configurations. This should be used by components configuring TLS client connections. |
1718
| metrics |[metrics-MetricsSettings](#metrics-MetricsSettings)| <no value> | MetricsSettings provides settings for redisreceiver metrics. |
1819

receiver/redisreceiver/config_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ func TestConfig(t *testing.T) {
3838
TLS: configtls.TLSClientSetting{
3939
Insecure: true,
4040
},
41+
Username: "test",
4142
Password: "test",
4243
ScraperControllerSettings: scraperhelper.ScraperControllerSettings{
4344
CollectionInterval: 10 * time.Second,

receiver/redisreceiver/redis_scraper.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ const redisMaxDbs = 16 // Maximum possible number of redis databases
3535
func newRedisScraper(cfg *Config, settings receiver.CreateSettings) (scraperhelper.Scraper, error) {
3636
opts := &redis.Options{
3737
Addr: cfg.Endpoint,
38+
Username: cfg.Username,
3839
Password: string(cfg.Password),
3940
Network: cfg.Transport,
4041
}

receiver/redisreceiver/testdata/config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
redis:
22
endpoint: "localhost:6379"
3+
username: "test"
34
password: "test"
45
collection_interval: 10s
56
tls:

0 commit comments

Comments
 (0)