Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lua script metric support custom attribute #922

Open
kunlun122 opened this issue Jul 16, 2024 · 3 comments
Open

lua script metric support custom attribute #922

kunlun122 opened this issue Jul 16, 2024 · 3 comments

Comments

@kunlun122
Copy link

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

@oliver006
Copy link
Owner

🧈

I like the idea, adding this makes sense. I currently do not have the time to implement this but a PR for this feature would be great and I can help with reviewing this.

@kunlun122
Copy link
Author

But I am a Java developer ...

@wilkice
Copy link
Contributor

wilkice commented Jul 20, 2024

Prometheus currently seems don't support dynamic label for metrics. So this is hard to implement now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants