admin 管理员组

文章数量: 887021


2024年1月17日发(作者:穆特辛德勒名单小提琴)

- redis://second-redis-host:6379 - redis://second-redis-host:6380 - redis://second-redis-host:6381 metrics_path: /scrape relabel_configs: - source_labels: [__address__] target_label: __param_target - source_labels: [__param_target] target_label: instance - target_label: __address__ replacement: <>:9121 ## config for scraping the exporter itself - job_name: 'redis_exporter' static_configs: - targets: - <>:9121```The Redis instances are listed under `targets`, the Redis exporter hostname is configured via the last relabel_config authentication is needed for the Redis instances then you can set the password via the `--rd` command line option ofthe exporter (this means you can currently only use one password across the instances you try to scrape this way. Use severalexporters if this is a problem). You can also use a json file to supply multiple targets by using `file_sd_configs` like so:```yamlscrape_configs: - job_name: 'redis_exporter_targets' file_sd_configs: - files: - metrics_path: /scrape relabel_configs: - source_labels: [__address__] target_label: __param_target - source_labels: [__param_target] target_label: instance - target_label: __address__ replacement: <>:9121 ## config for scraping the exporter itself - job_name: 'redis_exporter' static_configs: - targets: - <>:9121```The `` should look something like this:```json[ { "targets": [ "redis://redis-host-01:6379", "redis://redis-host-02:6379"], "labels": { } }]```Prometheus uses file watches and all changes to the json file are applied immediately.### Command line flagsName | Environment Variable Name | Description----------------------------|--------------------------------------------|-----------------

----------------------------|--------------------------------------------|----------------- | REDIS_ADDR | Address of the Redis instance, defaults to `redis://localhost:6379`. | REDIS_USER | User name to use for authentication (Redis ACL for Redis 6.0 and newer).rd | REDIS_PASSWORD | Password of the Redis instance, defaults to `""` (no password).rd-file | REDIS_PASSWORD_FILE | Password file of the Redis instance to scrape, defaults to `""` (no password file).check-keys | REDIS_EXPORTER_CHECK_KEYS | Comma separated list of key patterns to export value and length/size, eg: `db3=user_coucheck-single-keys | REDIS_EXPORTER_CHECK_SINGLE_KEYS | Comma separated list of keys to export value and length/size, eg: `db3=user_councheck-streams | REDIS_EXPORTER_CHECK_STREAMS | Comma separated list of stream-patterns to export info about streams, groups and ccheck-single-streams | REDIS_EXPORTER_CHECK_SINGLE_STREAMS | Comma separated list of streams to export info about streams, groups and cocheck-keys-batch-size | REDIS_EXPORTER_CHECK_KEYS_BATCH_SIZE | Approximate number of keys to process in each execution. This is basically thscript | REDIS_EXPORTER_SCRIPT | Path to Redis Lua script for gathering extra | REDIS_EXPORTER_DEBUG | Verbose debug outputlog-format | REDIS_EXPORTER_LOG_FORMAT | Log format, valid options are `txt` (default) and `json`.namespace | REDIS_EXPORTER_NAMESPACE | Namespace for the metrics, defaults to `redis`.-address | REDIS_EXPORTER_WEB_LISTEN_ADDRESS | Address to listen on for web interface and telemetry, defaults to `0.0.0.0:9121`.try-path | REDIS_EXPORTER_WEB_TELEMETRY_PATH | Path under which to expose metrics, defaults to `/metrics`.redis-only-metrics | REDIS_EXPORTER_REDIS_ONLY_METRICS | Whether to also export go runtime metrics, defaults to -keys | REDIS_EXPORTER_COUNT_KEYS | Comma separated list of patterns to count, eg: `db3=sessions:*` will count all keys with prconnection-timeout | REDIS_EXPORTER_CONNECTION_TIMEOUT | Timeout for connection to Redis instance, defaults to "15s" (in Golang duration

include-system-metrics | REDIS_EXPORTER_INCL_SYSTEM_METRICS | Whether to include system metrics like `total_system_memory_bytes`, defaultsis-tile38 | REDIS_EXPORTER_IS_TILE38 | Whether to scrape Tile38 specific metrics, defaults to -client-list | REDIS_EXPORTER_EXPORT_CLIENT_LIST | Whether to scrape Client List specific metrics, defaults to -tls-verification | REDIS_EXPORTER_SKIP_TLS_VERIFICATION | Whether to to skip TLS verificationping-on-connect | REDIS_EXPORTER_PING_ON_CONNECT | Whether to ping the redis instance after connecting and record the duration as a mexport-client-port | REDIS_EXPORTER_EXPORT_CLIENT_PORT | Whether to include the client's port when exporting the client list. Warning: includintls-client-key-file | REDIS_EXPORTER_TLS_CLIENT_KEY_FILE | Name of the client key file (including full path) if the server requires TLS client authentls-client-cert-file | REDIS_EXPORTER_TLS_CLIENT_CERT_FILE | Name the client cert file (including full path) if the server requires TLS client authentictls-server-key-file | REDIS_EXPORTER_TLS_SERVER_KEY_FILE | Name of the server key file (including full path) if the web interface and telemetry shtls-server-cert-file | REDIS_EXPORTER_TLS_SERVER_CERT_FILE | Name of the server certificate file (including full path) if the web interface and telemset-client-name | REDIS_EXPORTER_SET_CLIENT_NAME | Whether to set client name to redis_exporter, defaults to -ca-cert-file | REDIS_EXPORTER_TLS_CA_CERT_FILE | Name of the CA certificate file (including full path) if the server requires TLS client authecheck-key-groups | REDIS_EXPORTER_CHECK_KEY_GROUPS | Comma separated list of [LUA regexes](/pil/) for clasmax-distinct-key-groups | MAX_DISTINCT_KEY_GROUPS | Maximum number of distinct key groups that can be tracked independently *per Redis

Redis instance addresses can be tcp addresses: `redis://localhost:6379`, `:6379` unix sockets: `unix:///tmp/`.SSL is supported by using the `rediss://` schema, for example: `rediss://:6380` (note that the port is required wheCommand line settings take precedence over any configurations provided by the environment variables.### Authenticating with RedisIf your Redis instance requires authentication then there are several ways how you can supply

a username (new in Redis 6.x with ACLs) and a can provide the username and password as part of the address, see [here](/assignments/uri-schemes/prov/redis) for the official documeYou can set `-rd-file=` to specify a password file when using the `/scrape` endpoint, It only takes effect when `rd ==An example for a URI including a password is: `redis://<>:<>@<>:<>`Alternatively, you can provide the username and/or password using the `--` and `--rd` directly to the redis_ you want to use a dedicated Redis user for the redis_exporter (instead of the default user) then you need enable a list of commands for that can use the following Redis command to set up the user, just replace `<<>>` and `<<>>` with your desired values.``````ACL SETUSER <<>> +client +ping +info +config|get +cluster|info +slowlog +latency +memory +select +get +scan +xinfo +type +pfcount +strlen +llen### Run via DockerThe latest release is automatically published to the [Docker registry](/r/oliver006/redis_exporter/).You can run it like this:

You can run it like this:```shdocker run -d --name redis_exporter -p 9121:9121 oliver006/redis_exporter```Docker images are also published to the [ docker repo](/oliver006/redis_exporter) so you can pull them from there if for instance you run into```shdocker run -d --name redis_exporter -p 9121:9121 /oliver006/redis_exporter```The `latest` docker image contains only the exporter e.g. for debugging purposes, you need the exporter runningin an image that has a shell then you can run the `alpine` image:```shdocker run -d --name redis_exporter -p 9121:9121 oliver006/redis_exporter:alpine```If you try to access a Redis instance running on the host node, you'll need to add `--network host` so theredis_exporter container can access it:```shdocker run -d --name redis_exporter --network host oliver006/redis_exporter```### Run on Kubernetes[Here](contrib/) is an example Kubernetes deployment configuration for how to deploy the redis_exporter as a sidecar to### Tile38[Tile38]() now has native Prometheus support for exporting server metrics and basic stats about number of objects, strings, can also use redis_exporter to export Tile38 metrics, especially more advanced metrics by using Lua scripts or the `-check-keys` enable Tile38 support, run the exporter with `--is-tile38=true`.## What's exportedMost items from the INFO command are exported,see [Redis documentation](/commands/info) for addition, for every database there are metrics for total keys, expiring keys and the average TTL for keys in the can also export values of keys if they're in numeric format by using the `-check-keys` flag. The exporter will also export the size (or, depending on the data tyIf you require custom metric collection, you can provide a [Redis Lua script](/commands/eval) using the `-script` flag. An example can be found [in t### The redis_memory_max_bytes metricThe metric `redis_memory_max_bytes` will show the maximum number of bytes Redis can is zero if no memory limit is set for the Redis instance you're scraping (this is the default setting for Redis).You can confirm that's the case by checking if the metric `redis_config_maxmemory` is zero or by connecting to the Redis instance via redis-cli and running the co## What it looks likeExample [Grafana](/) screenshots:![redis_exporter_screen_01](/assets/1222339/19412031/)![redis_exporter_screen_02](/assets/1222339/19412041/)Grafana dashboard is available on [](/dashboards/763) and/or [](contrib/grafana_prometheus_redis_).### Viewing multiple Redis simultaneously

### Viewing multiple Redis simultaneouslyIf running [Redis Sentinel](/topics/sentinel), it may be desirable to view the metrics of the various cluster members simultaneously. For this reason th## Using the mixinThere is a set of sample rules, alerts and dashboards available in [redis-mixin](contrib/redis-mixin/)## Upgrading from 0.x to 1.x[PR #256](/oliver006/redis_exporter/pull/256) introduced breaking changes which were released as version you only scrape one Redis instance and use command line flags `--s`and `--rd` then you're most probably not ise, please see [PR #256](/oliver006/redis_exporter/pull/256) and [this README](/oliver006/redis_exporter#prometheu## Memory Usage Aggregation by Key GroupsWhen a single Redis instance is used for multiple purposes, it is useful to be able to see how Redis memory is consumed among the different usage scenarios. TTo enable memory usage aggregation by key groups, simply specify a non-empty comma-separated list of LUA regular expressions through the `check-key-grou 1. The `MEMORY USAGE` command is called to gather memory usage for each key 2. The specified LUA regexes are applied to each key in the specified order, and the group name that a given key belongs to will be derived from concatenating

Once a key has been classified, the memory usage and key counter for the corresponding group will be incremented in a local LUA table. This aggregated metricBesides making the full flexibility of LUA regex available for classifying keys into groups, the LUA script also has the benefit of reducing network traffic by executinScanning the entire key space of a Redis instance may sound a lttle extravagant, but it takes only a single scan to classify all keys into groups, and on a moderateTo protect Prometheus from being overwhelmed by a large number of time series resulting from misconfigured group classification regular expression (e.g. applyHere is a list of additional metrics that will be exposed when memory usage aggregation by key groups is enabled:|Name |Labels |Description|--------------------------------------------------|------------|-----------|redis_key_group_count |db,key_group|Number of keys in a key group|redis_key_group_memory_usage_bytes |db,key_group|Memory usage by key group|redis_number_of_distinct_key_groups |db |Number of distinct key groups in a Redis database when the `overflow` group is fully expanded|redis_last_key_groups_scrape_duration_milliseconds| |Duration of the last memory usage aggregation by key groups in milliseconds### Script to collect Redis lists and respective using Redis version < 4.0, most of the helpful metrics which we need to gather based on length or memory is not possible via default redis_ the help of LUA scripts, we can gather these of these scripts [contrib/collect_lists_length_](./contrib/collect_lists_length_) will help to collect the length of redis this count, we can take following actions such as Create alerts or dashboards in Grafana or any similar tools with these Prometheus metrics.## DevelopmentThe tests require a variety of real Redis instances to not only verify correctness of the exporter but alsocompatibility with older versions of Redis and with Redis-like systems like KeyDB or [contrib/](./contrib/) file has service definitions foreverything that's you're done testing you can bring down the stack by running `make docker-env-down`.Or you can bring up the stack, run the tests, and then tear down the stack, all in one shot, by running `make docker-all`.You can bring up the Redis test instances first by running `make docker-env-up` and then, every time you want to run the tests, you can run `make docker-test`. T***Note.** Tests initialization can lead to unexpected results when using a persistent testing environment. When `make docker-env-up` is executed once and `mak## Communal effortOpen an issue or PR if you have more suggestions, questions or ideas about what to add.


本文标签: 名单 作者