fix metrics

This commit is contained in:
Eugenio Marzo
2021-01-25 21:14:00 +01:00
parent d8ac596fe2
commit f9f6b8ee44
3 changed files with 30 additions and 6 deletions
+4 -4
View File
@@ -155,16 +155,16 @@ Example of metrics
curl localhost:8080/metrics
# Total number of chaos jobs executed on the node workernode01
chaos_node_jobs_total_on_workernode01 2
chaos_jobs_node_count{node=workernode01} 100
# Total number of chaos jobs executed against all worker nodes
chaos_node_jobs_total 4
chaos_node_jobs_total 200
# Total number of deleted pods
deleted_pods_total 12
deleted_pods_total 16
# Total number of deleted pods
deleted_pods_total_on_kubeinvadersdemo 4
deleted_namespace_pods_count{namespace=myawesomenamespace} 8
```
## Configuration
+13 -1
View File
@@ -20,7 +20,19 @@ server {
local okredis, errredis = red:connect(os.getenv("REDIS_HOST"), 6379)
for i, res in ipairs(red:keys("*")) do
ngx.log(ngx.ERR, res)
ngx.say(res .. " " .. red:get(res))
if string.find(res, "chaos_node_jobs_total_on") then
node = string.gsub(res, "chaos_node_jobs_total_on_", "")
metric = "chaos_jobs_node_count{node=".. node .."}"
ngx.say(metric .. " " .. red:get(res))
elseif string.find(res, "deleted_pods_total_on") then
namespace = string.gsub(res, "deleted_pods_total_on_", "")
metric = "deleted_namespace_pods_count{namespace=".. namespace .."}"
ngx.say(metric .. " " .. red:get(res))
else
ngx.say(res .. " " .. red:get(res))
end
end
}
}
+13 -1
View File
@@ -20,7 +20,19 @@ server {
local okredis, errredis = red:connect(os.getenv("REDIS_HOST"), 6379)
for i, res in ipairs(red:keys("*")) do
ngx.log(ngx.ERR, res)
ngx.say(res .. " " .. red:get(res))
if string.find(res, "chaos_node_jobs_total_on") then
node = string.gsub(res, "chaos_node_jobs_total_on_", "")
metric = "chaos_jobs_node_count{node=".. node .."}"
ngx.say(metric .. " " .. red:get(res))
elseif string.find(res, "deleted_pods_total_on") then
namespace = string.gsub(res, "deleted_pods_total_on_", "")
metric = "deleted_namespace_pods_count{namespace=".. namespace .."}"
ngx.say(metric .. " " .. red:get(res))
else
ngx.say(res .. " " .. red:get(res))
end
end
}
}