Giter Club home page Giter Club logo

redis_exporter's Introduction

Redis Metrics Exporter

Circle CI Coverage Status codecov

Prometheus exporter for Redis metrics.
Supports Redis 2.x, 3.x and 4.x

Building, configuring, and running

Locally build and run it:

    $ go get github.com/oliver006/redis_exporter
    $ cd $GOPATH/src/github.com/oliver006/redis_exporter
    $ go build
    $ ./redis_exporter <flags>

You can also run it via docker:

    $ docker pull oliver006/redis_exporter
    $ docker run -d --name redis_exporter -p 9121:9121 oliver006/redis_exporter

Add a block to the scrape_configs of your prometheus.yml config file:

scrape_configs:

...

- job_name: redis_exporter
  static_configs:
  - targets: ['localhost:9121']

...

and adjust the host name accordingly.

To run on Cloud Foundry, use:

cf push -f contrib/manifest.yml

Run on Kubernetes

Here is an example Kubernetes deployment configuration for how to deploy the redis_exporter as a sidecar with a Redis instance.

Run on Openshift

In order to deploy the exporter on Openshift environment.

oc project <myproject>

oc process -f https://raw.githubusercontent.com/ivanovaleksandar/redis_exporter/master/contrib/openshift-template.yaml \
    -p REDIS_ADDR=<redis-service>:<redis-port> \
    -p REDIS_PASSWORD=<redis-pass> \
    -p REDIS_ALIAS=<redis-alias> \
    -p REDIS_FILE=<redis-file> \
    | oc create -f -

NOTE: Some of the parameters can be ommited if no authentication is used or the default redis config is applied.

oc process -f https://raw.githubusercontent.com/ivanovaleksandar/redis_exporter/contrib/openshift-template.yaml \
    -p REDIS_ADDR=<redis-service>:<redis-port> \
    | oc create -f -

If you are running Prometheus on Openshift on the same cluster, target in prometheus.yml should point to the correct service name of the exporter

scrape_configs:

...

- job_name: redis_exporter
  static_configs:
  - targets: ['<redis-exporter.myproject.svc>:9121']

...

Flags

Name Description
debug Verbose debug output
log-format Log format, valid options are txt (default) and json.
check-keys Comma separated list of key patterns to export value and length/size, eg: db3=user_count will export key user_count from db 3. db defaults to 0 if omitted. The key patterns specified with this flag will be found using SCAN. Use this option if you need glob pattern matching; check-single-keys is faster for non-pattern keys.
check-single-keys Comma separated list of keys to export value and length/size, eg: db3=user_count will export key user_count from db 3. db defaults to 0 if omitted. The keys specified with this flag will be looked up directly without any glob pattern matching. Use this option if you don't need glob pattern matching; it is faster than check-keys.
script Path to Redis Lua script for gathering extra metrics.
redis.addr Address of one or more redis nodes, comma separated, defaults to redis://localhost:6379.
redis.password Password to use when authenticating to Redis
redis.alias Alias for redis node addr, comma separated.
redis.file Path to file containing one or more redis nodes, separated by newline. This option is mutually exclusive with redis.addr. Each line can optionally be comma-separated with the fields ,,.
namespace Namespace for the metrics, defaults to redis.
web.listen-address Address to listen on for web interface and telemetry, defaults to 0.0.0.0:9121.
web.telemetry-path Path under which to expose metrics, defaults to metrics.
use-cf-bindings Enable usage of Cloud Foundry service bindings. Defaults to false
separator Separator used to split redis.addr, redis.password and redis.alias into several elements. Defaults to ,

Redis node addresses can be tcp addresses like redis://localhost:6379, redis.example.com:6379 or unix socket addresses like unix:///tmp/redis.sock.
SSL is supported by using the rediss:// schema, for example: rediss://azure-ssl-enabled-host.redis.cache.windows.net:6380 (note that the port is required when connecting to a non-standard 6379 port, e.g. with Azure Redis instances).

These settings take precedence over any configurations provided by environment variables.

Environment Variables

Name Description
REDIS_ADDR Address of Redis node(s)
REDIS_PASSWORD Password to use when authenticating to Redis
REDIS_ALIAS Alias name of Redis node(s)
REDIS_FILE Path to file containing Redis node(s)

What's exported?

Most items from the INFO command are exported, see http://redis.io/commands/info for details.
In addition, for every database there are metrics for total keys, expiring keys and the average TTL for keys in the database.
You 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 type, the length) of the key. This can be used to export the number of elements in (sorted) sets, hashes, lists, etc.

If you require custom metric collection, you can provide a Redis Lua script using the -script flag. An example can be found in the contrib folder.

What does it look like?

Example Grafana screenshots:
redis_exporter_screen
redis_exporter_screen_02

Grafana dashboard is available on grafana.net and/or github.com.

Grafana dashboard with host & alias selector is available on github.com.

What else?

Open an issue or PR if you have more suggestions or ideas about what to add.

redis_exporter's People

Contributors

oliver006 avatar oliver-nyt avatar ihrigb avatar kpachhai avatar dkanchev avatar ericonyu avatar xginn8 avatar siavashs avatar sashgorokhov avatar cmur2 avatar 4admin2root avatar nipuntalukdar avatar mfouilleul avatar trinitronx avatar amurilloredpoints avatar azr avatar crandles avatar carlo-blohm avatar zakharovvi avatar stephanebunel avatar stanhu avatar mrwacky42 avatar rdtr avatar naseemkullah avatar mjtrangoni avatar wojas avatar s3rk avatar eagafonov avatar davidwittman avatar fajpunk avatar

Watchers

James Cloos avatar Herman Zhu avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.