Skip to content

lua script metric support custom attribute #922

@kunlun122

Description

@kunlun122

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

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions