prometheus-junkyard / promdash

Prometheus Dashboard Builder
http://prometheus.io/
Apache License 2.0
271 stars 48 forks source link

Support multiple servers for the same dashboard #180

Open grobie opened 10 years ago

grobie commented 10 years ago

As a developer, Given I deploy my services in multiple zones, I want to have one dashboard And switch between the data collected by different prometheus servers in each zone.

stuartnelson3 commented 10 years ago

you want to have a single dashboard that's looking at e.g. routing information, and without changing any of your graphs you switch between routing-x, routing-y, and routing-z (in different zones) and the graphs automatically update to the data from those servers?

mwitkow commented 9 years ago

A great way to solve it would be through adding template variables in server URLs. It's becoming a real maintenance burden not having this functionality.

juliusv commented 9 years ago

@mwitkow-io Agreed on being a maintenance burden (for us too!), and on doing it via template variables. Now we just have to figure out a good UI and JSON encoding for doing that. Currently servers for each expression are saved by their ID. Now they'd need to (optionally) be referred to by a string with some template variables inside instead, which then resolves (hopefully) to an existing server. Biggest challenge is the UI, I think: how to keep the simple case simple with just a dropdown, as it is now, but make it easy to use template variables for servers in individual graphs/expressions instead? I guess which type of UI to use would not be a per-graph/per-expression setting, but a global one (as otherwise it'd become quite cumbersome). So maybe it could be just a global setting which chooses the type of UI to use? Hrm... better ideas?

matthiasr commented 9 years ago

Maybe add the templating only on the URL side of the server, then automatically import all variables there into the dashboard and from that point on treat them as if they were a dashboard variable?

matthiasr commented 9 years ago

i.e. you'd have one server definition for "prometheus-routing", pointing at http://prometheus-routing-{{zone}}:9090, then once you use that in a dashboard that dashboard automatically grows a zone template variable.

Obviously you could not use different zone variables for other things in the dashboard then but you could use the same one. I think that is a good thing.

juliusv commented 9 years ago

@matthiasr Oh, that's a great idea! Thank you. I'm sold! :)

And it even keeps PromDash completely agnostic about the concept of a zone. It'd just be an arbitrary template variable used in the server name.

mwitkow commented 9 years ago

Is anyone working on this? @matthiasr

stuartnelson3 commented 9 years ago

this issue is not currently being worked on

mwitkow commented 9 years ago

K, I think we'll hack on it in our spare time.

Can you drop some pointers for "hacking noobs" as to where to start? :)

stuartnelson3 commented 9 years ago

the URLGenerator would be a good place to implement the logic that looks for the double curlies {{}}. Add an additional parameter that is an object with currently available template variables (i think those will be available already as $scope.vars), and then sub those in using the [VariableInterpolator] like we do in expression.js.erb

you'll have to scan the list of servers in shared_graph_behavior.js and check for any interpolation, then automatically add that as a key to $scope.vars if it isn't already there.

that should get you going

mwitkow commented 9 years ago

So I made a first pass at this. As I'm pretty unused to AngularJS or Ruby, this was both fun and confusing.

grobie commented 9 years ago

Great work! That solves the first part of the problem I tried to describe above. I filed #375 with an idea how to solve the rest.

mwitkow commented 9 years ago

And there was much rejoicing! Thanks!

grobie commented 9 years ago

This issue specifies the acceptance criteria to switch between different instances/profiles of the same dashboard. Let's wait until #375 is merged before we close this issue here.