示例#1
0
文件: perfdash.go 项目: sk163/bonito
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
}
示例#2
0
文件: perfdash.go 项目: sk163/bonito
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
}