mirror of
https://github.com/lucky-sideburn/kubeinvaders.git
synced 2026-08-23 21:46:21 +00:00
fix metrics
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user