Sign inSign up

yehudayefet/redis-stats

By yehudayefet

•Updated almost 8 years ago

This docker image is intended for end users that want to push Redis Statistics to Elasticsearch.

Image
0

100K+

yehudayefet/redis-stats repository overview

This docker image is intended for end users that want to push Redis Statistics to Elasticsearch. These statistics can be plotted, graphed, and added to dashboards for real-time stats in Kibana (for example).

Requirements:

  • Redis instance
  • Elasticsearch Instance

Docker image is expecting the following Environment Variables to be set during startup: $REDIS_HOST $REDIS_PORT $ES_HOST $ES_HOST

For kubernetes deployments, it is helpful to run this container as a CronJob that executes every 1 minute:

apiVersion: batch/v1beta1
kind: CronJob
metadata:
  name: redis-stats
spec:
  schedule: "*/1 * * * *"
  jobTemplate:
    spec:
      template:
        spec:
          containers:
          - name: redis-stats
            image: yehudayefet/redis-stats
            env:
             - name: REDIS_HOST
               value: "name-of-redis-service.default.svc.cluster.local"
             - name: REDIS_PORT
               value: "6379"
             - name: ES_HOST
               value: "name-of-elasticsearch-logging-service.kube-system.svc.cluster.local"
             - name: ES_PORT
               value: "9200"
          restartPolicy: OnFailure

Adding Field Types and Time Field in Elasticsearch:

Note: this long one liner will add types to all redis fields in the index. This should be run before the container is executed.

curl -X DELETE "http://[your_elasticsearch_ip]:9200/redis" && \
JSON_DATA="{\"mappings\": {\"stats\": {\"properties\": {\"time\": {\"type\": \"date\",\"format\": \"epoch_second\"},\"redisversion\": {\"type\": \"text\"},\"redisgitsha1\": {\"type\": \"text\"},\"redisgitdirty\": {\"type\": \"long\"},\"redisbuildid\": {\"type\": \"text\"},\"redismode\": {\"type\": \"text\"},\"os\": {\"type\": \"text\"},\"archbits\": {\"type\": \"text\"},\"multiplexingapi\": {\"type\": \"text\"},\"gccversion\": {\"type\": \"long\"},\"processid\": {\"type\": \"text\"},\"runid\": {\"type\": \"text\"},\"tcpport\": {\"type\": \"long\"},\"uptimeinseconds\": {\"type\": \"text\"},\"uptimeindays\": {\"type\": \"long\"},\"hz\": {\"type\": \"long\"},\"lruclock\": {\"type\": \"long\"},\"configfile\": {\"type\": \"long\"},\"connectedclients\": {\"type\": \"long\"},\"clientlongestoutputlist\": {\"type\": \"text\"},\"clientbiggestinputbuf\": {\"type\": \"long\"},\"blockedclients\": {\"type\": \"long\"},\"usedmemory\": {\"type\": \"long\"},\"usedmemoryhuman\": {\"type\": \"long\"},\"usedmemoryrss\": {\"type\": \"long\"},\"usedmemorypeak\": {\"type\": \"text\"},\"usedmemorypeakhuman\": {\"type\": \"long\"},\"usedmemorylua\": {\"type\": \"long\"},\"memfragmentationratio\": {\"type\": \"text\"},\"memallocator\": {\"type\": \"long\"},\"loading\": {\"type\": \"float\"},\"rdbchangessincelastsave\": {\"type\": \"text\"},\"rdbbgsaveinprogress\": {\"type\": \"long\"},\"rdblastsavetime\": {\"type\": \"long\"},\"rdblastbgsavestatus\": {\"type\": \"long\"},\"rdblastbgsavetimesec\": {\"type\": \"long\"},\"rdbcurrentbgsavetimesec\": {\"type\": \"text\"},\"aofenabled\": {\"type\": \"long\"},\"aofrewriteinprogress\": {\"type\": \"long\"},\"aofrewritescheduled\": {\"type\": \"long\"},\"aoflastrewritetimesec\": {\"type\": \"long\"},\"aofcurrentrewritetimesec\": {\"type\": \"long\"},\"aoflastbgrewritestatus\": {\"type\": \"long\"},\"aoflastwritestatus\": {\"type\": \"long\"},\"totalconnectionsreceived\": {\"type\": \"text\"},\"totalcommandsprocessed\": {\"type\": \"text\"},\"instantaneousopspersec\": {\"type\": \"long\"},\"totalnetinputbytes\": {\"type\": \"long\"},\"totalnetoutputbytes\": {\"type\": \"long\"},\"instantaneousinputkbps\": {\"type\": \"long\"},\"instantaneousoutputkbps\": {\"type\": \"long\"},\"rejectedconnections\": {\"type\": \"float\"},\"syncfull\": {\"type\": \"float\"},\"syncpartialok\": {\"type\": \"long\"},\"syncpartialerr\": {\"type\": \"long\"},\"expiredkeys\": {\"type\": \"long\"},\"evictedkeys\": {\"type\": \"long\"},\"keyspacehits\": {\"type\": \"long\"},\"keyspacemisses\": {\"type\": \"long\"},\"pubsubchannels\": {\"type\": \"long\"},\"pubsubpatterns\": {\"type\": \"long\"},\"latestforkusec\": {\"type\": \"long\"},\"role\": {\"type\": \"long\"},\"connectedslaves\": {\"type\": \"long\"},\"masterreploffset\": {\"type\": \"text\"},\"replbacklogactive\": {\"type\": \"long\"},\"replbacklogsize\": {\"type\": \"long\"},\"replbacklogfirstbyteoffset\": {\"type\": \"long\"},\"replbackloghistlen\": {\"type\": \"long\"},\"usedcpusys\": {\"type\": \"long\"},\"usedcpuuser\": {\"type\": \"long\"},\"usedcpusyschildren\": {\"type\": \"float\"},\"usedcpuuserchildren\": {\"type\": \"float\"},\"db1\": {\"type\": \"float\"}}}}}" && \
curl -X PUT -H "Content-Type: application/json" -H "Cache-Control: no-cache" -d "$JSON_DATA" "http://[your_elasticsearch_ip]4:9200/redis"

Tag summary

Content type

Image

Digest

Size

20.8 MB

Last updated

almost 8 years ago

docker pull yehudayefet/redis-stats