Redis metric plugin for vayne_core monitor framework. Checkout real monitor example to see vayne_server.
Add package to your list of dependencies in mix.exs:
def deps do
[
{:vayne_metric_redis, github: "mon-suit/vayne_metric_redis"}
]
end#Setup params for plugin.
params = %{"host" => "127.0.0.1", "password" => "foo"}
#Init plugin.
{:ok, stat} = Vayne.Metric.Redis.init(params)
#In fact, log_func will be passed by framework to record error.
log_func = fn msg -> IO.puts msg end
#Run plugin and get returned metrics.
{:ok, metrics} = Vayne.Metric.Redis.run(stat, log_func)
#Do with metrics
IO.inspect metrics
#Clean plugin state.
:ok = Vayne.Metric.Redis.clean(stat)Support params:
host: Redis host.Required.port: Redis port. Not required, default 6379.password: password. Not required.max_memory: max_memory. Not required(CONFIG GETwill failed in some cloud instance).
- All
infoitems(could be parsed to number). - Custom items:
is_slave: "slave" -> 1, other -> 0. (check iffailoverhappen)master_link_status: nil -> 2, "up" -> 1, other -> 0used_memory_percent: 100 * used_memory / max_memorykeys: count of keys in db0~db15key_hits_percent: 100 * keyspace_hits / (keyspace_hits + keyspace_misses)aof_last_bgrewrite_statusandrdb_last_bgsave_status: "ok" -> 1, other -> 0cluster_state: "ok" -> 1, other -> 0. (whencluster_enabled== 1)