Skip to content

Commit b7f2c89

Browse files
[redisdb] Set client name to 'datadog-agent' on Redis connections (#23734)
* [redisdb] Allow setting client_name on Redis connections Allow users to set client_name in their instance configuration, making it easy to identify agent connections in CLIENT LIST output on the Redis server without requiring CLIENT SETNAME permissions in restricted ACL environments. * [redisdb] Document client_name in configuration spec --------- Co-authored-by: Sarah Witt <sarah.witt@datadoghq.com>
1 parent 2bbade5 commit b7f2c89

6 files changed

Lines changed: 17 additions & 0 deletions

File tree

redisdb/assets/configuration/spec.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,13 @@ files:
128128
type: boolean
129129
example: true
130130
fleet_configurable: true
131+
- name: client_name
132+
display_priority: 0
133+
description: |
134+
Set the connection name that appears in CLIENT LIST on the Redis server.
135+
Useful for identifying agent connections. Requires the CLIENT SETNAME permission.
136+
value:
137+
type: string
131138
- name: keys
132139
display_priority: 0
133140
description: |

redisdb/changelog.d/23734.added

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Allow setting ``client_name`` on Redis connections for easier identification in CLIENT LIST output.

redisdb/datadog_checks/redisdb/config_models/instance.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ class InstanceConfig(BaseModel):
3737
arbitrary_types_allowed=True,
3838
frozen=True,
3939
)
40+
client_name: Optional[str] = None
4041
collect_client_metrics: Optional[bool] = None
4142
command_stats: Optional[bool] = None
4243
db: Optional[int] = None

redisdb/datadog_checks/redisdb/data/conf.yaml.example

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,12 @@ instances:
9494
#
9595
# ssl_check_hostname: true
9696

97+
## @param client_name - string - optional
98+
## Set the connection name that appears in CLIENT LIST on the Redis server.
99+
## Useful for identifying agent connections. Requires the CLIENT SETNAME permission.
100+
#
101+
# client_name: <CLIENT_NAME>
102+
97103
## @param keys - list of strings - optional
98104
## Enter the list of keys to collect the lengths from.
99105
## The length is 1 for strings.

redisdb/datadog_checks/redisdb/redisdb.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ def _get_conn(self, instance_config):
8989
'ssl_ca_certs',
9090
'ssl_cert_reqs',
9191
'ssl_check_hostname',
92+
'client_name',
9293
]
9394

9495
# Set a default timeout (in seconds) if no timeout is specified in the instance config

redisdb/tests/test_unit.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ def test_check_all_available_config_options(check, aggregator, redis_instance, d
127127
'ssl_ca_certs': '/path',
128128
'ssl_cert_reqs': 0,
129129
'ssl_check_hostname': True,
130+
'client_name': 'datadog-agent',
130131
}
131132
redis_instance.update(connection_args)
132133

0 commit comments

Comments
 (0)