oliver006/redis_exporter

lua script metric support custom attribute

Open

#922 aperta il 16 lug 2024

Vedi su GitHub
 (3 commenti) (0 reazioni) (1 assegnatario)Go (944 fork)github user discovery
feature requesthelp wanted

Metriche repository

Star
 (3637 star)
Metriche merge PR
 (Metriche PR in attesa)

Descrizione

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

Guida contributor