-
Notifications
You must be signed in to change notification settings - Fork 885
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #165 from wojas/lua-script
Optional Redis Lua script for metric collection
- Loading branch information
Showing
5 changed files
with
90 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
-- Example collect script for -script option | ||
-- This returns a Lua table with alternating keys and values. | ||
-- Both keys and values must be strings, similar to a HGETALL result. | ||
-- More info about Redis Lua scripting: https://redis.io/commands/eval | ||
|
||
local result = {} | ||
|
||
-- Add all keys and values from some hash in db 5 | ||
redis.call("SELECT", 5) | ||
local r = redis.call("HGETALL", "some-hash-with-stats") | ||
if r ~= nil then | ||
for _,v in ipairs(r) do | ||
table.insert(result, v) -- alternating keys and values | ||
end | ||
end | ||
|
||
-- Set foo to 42 | ||
table.insert(result, "foo") | ||
table.insert(result, "42") -- note the string, use tostring() if needed | ||
|
||
return result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters