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

Fix Prometheus node/cluster labels #839

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/lavinmq/config.cr
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ module LavinMQ
property free_disk_min : Int64 = 0 # bytes
property free_disk_warn : Int64 = 0 # bytes
property? clustering = false
property clustering_name = ""
property clustering_etcd_prefix = "lavinmq"
property clustering_etcd_endpoints = "localhost:2379"
property clustering_advertised_uri : String? = nil
Expand Down Expand Up @@ -122,6 +123,9 @@ module LavinMQ
p.on("--clustering", "Enable clustering") do
@clustering = true
end
p.on("--clustering-name=NAME", "Cluster name, currently only used to group Prometheus metrics (default: \"\")") do |v|
@clustering_name = v
end
p.on("--clustering-advertised-uri=URI", "Advertised URI for the clustering server") do |v|
@clustering_advertised_uri = v
end
Expand Down Expand Up @@ -241,6 +245,7 @@ module LavinMQ
settings.each do |config, v|
case config
when "enabled" then @clustering = true?(v)
when "name" then @clustering_name = v
when "etcd_prefix" then @clustering_etcd_prefix = v
when "etcd_endpoints" then @clustering_etcd_endpoints = v
when "advertised_uri" then @clustering_advertised_uri = v
Expand Down
3 changes: 2 additions & 1 deletion src/lavinmq/http/controller/prometheus.cr
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,8 @@ module LavinMQ
help: "System information",
labels: {
"#{writer.prefix}_version" => LavinMQ::VERSION,
"#{writer.prefix}_cluster" => System.hostname,
"#{writer.prefix}_node" => System.hostname,
"#{writer.prefix}_cluster" => Config.instance.clustering_name,
}})

writer.write({name: "connections_opened_total",
Expand Down
Loading