func (api *PerfDashApi) buildEsAggs(req *PerfDashRequest) (MapStr, error) { aggs := MapStr{} for _, metric := range req.Metrics { agg, err := api.metrics.BuildEsAggs(metrics.ConfigRaw(metric)) if err != nil { return nil, fmt.Errorf("Metric '%s' error: %v", metric.Name, err) } aggs.update(MapStr(agg)) } for _, dim := range req.Dimensions { for _, metric := range dim.Metrics { agg, err := api.metrics.BuildEsAggs(metrics.ConfigRaw(metric)) if err != nil { return nil, fmt.Errorf("Dim '%s' metric '%s': %v", dim.Name, metric.Name, err) } aggs.update(MapStr(agg)) } } return aggs, nil }
func (api *PerfDashApi) metricsFromEsResponse(resp map[string]json.RawMessage, configs []ConfigRaw, interval metrics.Interval) (MapStr, error) { result := MapStr{} for _, metric := range configs { res, err := api.metrics.FromEsResponse(resp, metrics.ConfigRaw(metric), interval) if err != nil { return nil, err } result[metric.Name] = res } return result, nil }