diff --git a/server/query.go b/server/query.go
index 22385bf07de13e576e03007b179ede5fd6e97000..ad645bd1dbf139887de5f86a8e26bb5af1556b96 100644 (file)
--- a/server/query.go
+++ b/server/query.go
p := struct {
Query, Metrics string
QueryOptions string
- GroupBy string
+ GroupBy []string
+ Attributes map[string]bool
}{
Query: req.r.PostForm.Get("metrics-query"),
- GroupBy: req.r.PostForm.Get("group-by"),
+ GroupBy: req.r.PostForm["group-by"],
}
if req.r.Method == "POST" {
p.Metrics = p.Query
- if p.GroupBy != "" {
- p.QueryOptions += "/g=" + strings.Join(strings.Fields(p.GroupBy), ",")
+ if len(p.GroupBy) > 0 {
+ p.QueryOptions += "/g=" + strings.Join(p.GroupBy, ",")
+ }
+
+ metrics, err := s.queryMetrics(p.Query)
+ if err != nil {
+ return nil, err
+ }
+ p.Attributes = make(map[string]bool)
+ for _, m := range metrics {
+ for a := range m.Attributes {
+ var checked bool
+ for _, g := range p.GroupBy {
+ if a == g {
+ checked = true
+ break
+ }
+ }
+ p.Attributes[a] = checked
+ }
}
}
return tmpl(s.results["graphs"], &p)