grafana-simple-json

Grafana datasource for Redis storage
0.3.3 Latest release released

grafana-redis.cr Build Status

Grefana Datasource for Redis storage

  • crystal: 0.20.1
  • static binary x86_64 linux : https://github.com/maiha/grafana-redis.cr/releases

Features

  • Grafana Datasource protocol: SimpleJson
  • Redis Storage Format: ZADD KEY epoch DSTAT_JSON

Usage

config.toml

## Setting for Redis Storage where stats are stored
[redis]
host = "127.0.0.1"
port = 6379
# pass = "secret"
zset = "dstat"  # specify your ZADD key
sampling = 3600      # max number of data to retrieve from redis

[engine]
limit = 100  # max number of datapoints to send to grafana server

## Backend Simple JSON Server that listens for Grafana
[httpd]
host = "127.0.0.1"
port = 3334

run backend server

grafana-redis config.toml

Grafana (Add data source)

  • Type: SimpleJson
  • Url: http://127.0.0.1:3334

Redis Stats

Importing

  • use ZADD with epoched SCORE
% redis-cli ZADD dstat CH 1472914799 '{"usr":1,"sys":1,...}'
  • dstat-redis with following cmds suit best to this use.
  • https://github.com/maiha/dstat-redis.cr
cmds = [
  "ZADD   dstat CH __epoch__ __json__",
]

Fetching

Expected stats are stored in ZSET as JSON String where

    1. The JSON must contain epoch field.
% redis-cli --raw ZRANGE "dstat" -1 -1
{"usr":1,"sys":1,"idl":99,"wai":0,"hiq":0,"siq":0,"1m":0.02,"5m":0.03,"15m":0.05,"used":351000000,"buff":329000000,"cach":323000000,"free":997000000,"read":0,"writ":16000,"recv":1646,"send":860,"int":287,"csw":365,"lis":16,"act":15,"syn":1,"tim":0,"clo":0,"epoch":1472914799}
    1. The entry has epoch value as SCORE.
% redis-cli --raw ZRANGEBYSCORE "dstat" 1472914796 1472914797
{"usr":1,"sys":1,"idl":98,"wai":0,"hiq":0,"siq":0,"1m":0.02,"5m":0.03,"15m":0.05,"used":351000000,"buff":329000000,"cach":323000000,"free":998000000,"read":0,"writ":16000,"recv":1808,"send":664,"int":347,"csw":422,"lis":16,"act":15,"syn":0,"tim":0,"clo":0,"epoch":1472914796}
{"usr":2,"sys":0,"idl":98,"wai":0,"hiq":0,"siq":0,"1m":0.02,"5m":0.03,"15m":0.05,"used":351000000,"buff":329000000,"cach":323000000,"free":997000000,"read":0,"writ":16000,"recv":2276,"send":1498,"int":354,"csw":467,"lis":16,"act":15,"syn":0,"tim":0,"clo":0,"epoch":1472914797}

Development

crystal src/bin/main.cr -- config.toml

Restrictions

  • Works only for Int values. It maybe fail with selecting 1m etc.

Contributing

  1. Fork it ( https://github.com/maiha/grafana-redis.cr/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Contributors

  • maiha maiha - creator, maintainer
grafana-simple-json:
  github: maiha/grafana-redis.cr
  version: ~> 0.3.3
License MIT
Crystal none

Authors

Dependencies 4

  • kemal 0.17.4
    {'github' => 'sdogruyol/kemal', 'version' => '0.17.4'}
  • jq 0.3.2
    {'github' => 'maiha/jq.cr', 'version' => '0.3.2'}
  • redis-cluster 0.7.2
    {'github' => 'maiha/redis-cluster.cr', 'version' => '0.7.2'}
  • app~maiha 0.3.2
    {'github' => 'maiha/app.cr', 'version' => '0.3.2'}

Development Dependencies 0

Dependents 0

Last synced .
search fire star recently