Skip to content

Instantly share code, notes, and snippets.

@ton31337
Last active February 15, 2016 20:40
Show Gist options
  • Save ton31337/eb235ef3a8386df9f96d to your computer and use it in GitHub Desktop.
Save ton31337/eb235ef3a8386df9f96d to your computer and use it in GitHub Desktop.
def prometheus_nodes_by_role(role = '*', port = 9100)
servers = []
search(:node, "role:#{role}").each do |server|
servers << "'#{to_ipv6(server.ipv6_ips.first)}:#{port}'" if server.ipv6_ips.any?
servers << "'#{server.ipv4_ips.private.first}:#{port}'" unless server.ipv6_ips.any?
end
servers
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment