From 6f66b022bc46a1a852ea465c0dcd3a56ec9afb39 Mon Sep 17 00:00:00 2001 From: Ulric Qin Date: Mon, 23 Mar 2020 13:16:28 +0800 Subject: [PATCH 1/2] use aliyun mirror when build --- README.md | 5 ++++- README_ZH.md | 5 ++++- control | 1 - 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 8ac237f8..bd3cd667 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,10 @@ Nightingale user manual: [https://n9e.didiyun.com/](https://n9e.didiyun.com/) mkdir -p $GOPATH/src/github.com/didi cd $GOPATH/src/github.com/didi git clone https://github.com/didi/nightingale.git -cd nightingale && ./control build +cd nightingale +# export env[GOPROXY] if your network is not good +# export GOPROXY=https://mirrors.aliyun.com/goproxy/ +./control build ``` ## Team diff --git a/README_ZH.md b/README_ZH.md index cda73e57..1a1b3140 100644 --- a/README_ZH.md +++ b/README_ZH.md @@ -15,7 +15,10 @@ Nightingale是一套衍生自Open-Falcon的互联网监控解决方案,融入 mkdir -p $GOPATH/src/github.com/didi cd $GOPATH/src/github.com/didi git clone https://github.com/didi/nightingale.git -cd nightingale && ./control build +cd nightingale +# 如果网络环境不好可以尝试aliyun的mirror +# export GOPROXY=https://mirrors.aliyun.com/goproxy/ +./control build ``` ## 团队 diff --git a/control b/control index accb98c6..5aa36f04 100755 --- a/control +++ b/control @@ -142,7 +142,6 @@ build_one() build() { export GO111MODULE=on - export GOPROXY=https://mirrors.aliyun.com/goproxy/ mod=$1 if [ "x${mod}" = "x" ]; then From 450f94ff3229ac37db1fb177b3d9d64731b2fe9b Mon Sep 17 00:00:00 2001 From: 710leo <710leo@gmail.com> Date: Mon, 23 Mar 2020 14:14:11 +0800 Subject: [PATCH 2/2] feat: support comparison graph --- src/dataobj/query_item.go | 11 +++++ .../transfer/http/routes/query_router.go | 42 ++++++++++++++++--- 2 files changed, 48 insertions(+), 5 deletions(-) diff --git a/src/dataobj/query_item.go b/src/dataobj/query_item.go index f149ae7a..442a4b10 100644 --- a/src/dataobj/query_item.go +++ b/src/dataobj/query_item.go @@ -24,6 +24,17 @@ type QueryDataForUI struct { Comparisons []int64 `json:"comparisons"` //环比多少时间 } +type QueryDataForUIResp struct { + Start int64 `json:"start"` + End int64 `json:"end"` + Endpoint string `json:"endpoint"` + Counter string `json:"counter"` + DsType string `json:"dstype"` + Step int `json:"step"` + Values []*RRDData `json:"values"` + Comparison int64 `json:"comparison"` +} + type QueryDataResp struct { Data []*TsdbQueryResponse Msg string diff --git a/src/modules/transfer/http/routes/query_router.go b/src/modules/transfer/http/routes/query_router.go index 9591d402..2be8f9fe 100644 --- a/src/modules/transfer/http/routes/query_router.go +++ b/src/modules/transfer/http/routes/query_router.go @@ -46,18 +46,50 @@ func QueryData(c *gin.Context) { func QueryDataForUI(c *gin.Context) { stats.Counter.Set("data.ui.qp10s", 1) var input dataobj.QueryDataForUI - + var respData []*dataobj.QueryDataForUIResp errors.Dangerous(c.ShouldBindJSON(&input)) + start := input.Start + end := input.End resp := backend.FetchDataForUI(input) + for _, d := range resp { + data := &dataobj.QueryDataForUIResp{ + Start: d.Start, + End: d.End, + Endpoint: d.Endpoint, + Counter: d.Counter, + DsType: d.DsType, + Step: d.Step, + Values: d.Values, + } + respData = append(respData, data) + } + if len(input.Comparisons) > 1 { for i := 1; i < len(input.Comparisons); i++ { - input.Start = input.Start - input.Comparisons[i] - input.End = input.End - input.Comparisons[i] + comparison := input.Comparisons[i] + input.Start = start - comparison + input.End = end - comparison res := backend.FetchDataForUI(input) - resp = append(resp, res...) + for _, d := range res { + for j := range d.Values { + d.Values[j].Timestamp += comparison + } + + data := &dataobj.QueryDataForUIResp{ + Start: d.Start, + End: d.End, + Endpoint: d.Endpoint, + Counter: d.Counter, + DsType: d.DsType, + Step: d.Step, + Values: d.Values, + Comparison: comparison, + } + respData = append(respData, data) + } } } - render.Data(c, resp, nil) + render.Data(c, respData, nil) }