oliver006/redis_exporter

lua script metric support custom attribute

Open

#922 opened on Jul 16, 2024

View on GitHub
 (3 comments) (0 reactions) (1 assignee)Go (944 forks)github user discovery
feature requesthelp wanted

Repository metrics

Stars
 (3,637 stars)
PR merge metrics
 (PR metrics pending)

Description

Describe the problem Now lua script metric only support one custom attribute named "key", I think custom attribute maybe butter.

What version of redis_exporter are you running? 1.60.0

Running the exporter lua script

local result = {}
local nodes_info = redis.pcall('CLUSTER', 'NODES')

if type(nodes_info) == 'string' then
    for line in string.gmatch(nodes_info, '([^\n]+)') do
        if string.find(line, 'myself') then

            local parts = {}
            local idx = 1
            for part in string.gmatch(line, '([^%s]+)') do
                parts[idx] = part
                idx = idx + 1
            end

            table.insert(result, 'node_info_address='..parts[2])
            table.insert(result, "1")


            break
        end
    end
else
    table.insert(result, 'Error running CLUSTER NODES')
end

return result

Screenshots script metrics

# HELP redis_script_result Result of the collect script evaluation
# TYPE redis_script_result gauge
redis_script_result{filename="/opt/server_info.lua"} 1
# HELP redis_script_values Values returned by the collect script
# TYPE redis_script_values gauge
redis_script_values{filename="/opt/server_info.lua",key="node_info_address=10.42.2.120:6379@16379"} 1

image

Additional context hope we can custom the redis_script_values attributes

redis_script_values{filename="/opt/server_info.lua", node_info_address="10.42.2.120:6379@16379"} 1

Contributor guide