Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
jobily
Nightingale
提交
dd67efe0
N
Nightingale
项目概览
jobily
/
Nightingale
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
N
Nightingale
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
dd67efe0
编写于
11月 12, 2020
作者:
Y
yubo
提交者:
GitHub
11月 12, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
support time limit for m3db query (#396)
上级
033383ee
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
38 addition
and
19 deletion
+38
-19
.gitignore
.gitignore
+1
-1
etc/rdb.yml
etc/rdb.yml
+2
-3
src/modules/transfer/backend/m3db/m3db.go
src/modules/transfer/backend/m3db/m3db.go
+24
-9
src/modules/transfer/backend/m3db/query.go
src/modules/transfer/backend/m3db/query.go
+4
-4
src/modules/transfer/backend/m3db/test/04-query-metrics.sh
src/modules/transfer/backend/m3db/test/04-query-metrics.sh
+1
-1
src/modules/transfer/http/routes/query_router.go
src/modules/transfer/http/routes/query_router.go
+6
-1
未找到文件。
.gitignore
浏览文件 @
dd67efe0
...
...
@@ -54,4 +54,4 @@ _test
/src/modules/transfer/transfer
/src/modules/tsdb/tsdb
tmp/
etc/rdb.yml
浏览文件 @
dd67efe0
...
...
@@ -10,9 +10,8 @@ http:
sso
:
enable
:
false
ssoAddr
:
"
http://10.1.2.3:8071"
# TODO: redirectURL: "http://10.1.2.3:8072/auth-callback"
redirectURL
:
"
http://10.1.2.3:8072/api/rdb/auth/callback"
ssoAddr
:
"
http://{sso-host}"
redirectURL
:
"
http://{rdb-host}/auth-callback"
clientId
:
"
"
clientSecret
:
"
"
apiKey
:
"
"
...
...
src/modules/transfer/backend/m3db/m3db.go
浏览文件 @
dd67efe0
...
...
@@ -25,6 +25,7 @@ const (
METRIC_NAME
=
"__name__"
SERIES_LIMIT
=
1000
DOCS_LIMIT
=
100
MAX_PONINTS
=
720
)
type
M3dbSection
struct
{
...
...
@@ -51,6 +52,10 @@ type Client struct {
namespaceID
ident
.
ID
}
func
indexStartTime
()
time
.
Time
{
return
time
.
Now
()
.
Add
(
-
time
.
Hour
*
25
)
}
func
NewClient
(
cfg
M3dbSection
)
(
*
Client
,
error
)
{
client
,
err
:=
cfg
.
Config
.
NewClient
(
client
.
ConfigurationParameters
{})
if
err
!=
nil
{
...
...
@@ -267,7 +272,6 @@ func (p *Client) queryIndexByFullTags(session client.Session, input dataobj.Inde
ret
=
dataobj
.
IndexByFullTagsResp
{
Metric
:
input
.
Metric
,
Tags
:
[]
string
{},
Step
:
10
,
DsType
:
"GAUGE"
,
}
...
...
@@ -285,20 +289,22 @@ func (p *Client) queryIndexByFullTags(session client.Session, input dataobj.Inde
}
ret
.
Endpoints
=
input
.
Endpoints
tags
:=
map
[
string
]
struct
{}{}
for
iter
.
Next
()
{
log
.
Printf
(
"iter.next() "
)
_
,
_
,
tagIter
:=
iter
.
Current
()
resp
:=
xcludeResp
(
tagIter
)
if
len
(
resp
.
Tags
)
>
0
{
ret
.
Tags
=
append
(
ret
.
Tags
,
resp
.
Tags
[
0
])
if
len
(
resp
.
Tags
)
>
0
&&
len
(
resp
.
Tags
[
0
])
>
0
{
tags
[
resp
.
Tags
[
0
]]
=
struct
{}{}
}
}
for
k
,
_
:=
range
tags
{
ret
.
Tags
=
append
(
ret
.
Tags
,
k
)
}
if
err
:=
iter
.
Err
();
err
!=
nil
{
logger
.
Errorf
(
"FetchTaggedIDs iter:"
,
err
)
}
return
ret
}
// GetInstance: && (metric) (endpoint) (&& tags...)
...
...
@@ -438,12 +444,21 @@ func seriesIterWalk(iter encoding.SeriesIterator) (out *dataobj.TsdbQueryRespons
tagsIter
:=
iter
.
Tags
()
tags
:=
map
[
string
]
string
{}
var
metric
,
endpoint
string
for
tagsIter
.
Next
()
{
tag
:=
tagsIter
.
Current
()
tags
[
tag
.
Name
.
String
()]
=
tag
.
Value
.
String
()
k
:=
tag
.
Name
.
String
()
v
:=
tag
.
Value
.
String
()
switch
k
{
case
METRIC_NAME
:
metric
=
v
case
ENDPOINT_NAME
,
NID_NAME
:
endpoint
=
v
default
:
tags
[
k
]
=
v
}
}
metric
:=
tags
[
METRIC_NAME
]
endpoint
:=
tags
[
ENDPOINT_NAME
]
counter
,
err
:=
dataobj
.
GetCounter
(
metric
,
""
,
tags
)
return
&
dataobj
.
TsdbQueryResponse
{
...
...
@@ -483,7 +498,7 @@ func (cfg M3dbSection) validateTime(start, end int64, step *int) error {
}
if
*
step
==
0
{
*
step
=
int
((
end
-
start
)
/
720
)
*
step
=
int
((
end
-
start
)
/
MAX_PONINTS
)
}
if
*
step
>
cfg
.
MinStep
{
...
...
src/modules/transfer/backend/m3db/query.go
浏览文件 @
dd67efe0
...
...
@@ -134,7 +134,7 @@ func (cfg M3dbSection) queryMetricsOptions(input dataobj.EndpointsRecv) (index.Q
)},
index
.
AggregationOptions
{
QueryOptions
:
index
.
QueryOptions
{
StartInclusive
:
time
.
Time
{}
,
StartInclusive
:
indexStartTime
()
,
EndExclusive
:
time
.
Now
(),
SeriesLimit
:
cfg
.
SeriesLimit
,
DocsLimit
:
cfg
.
DocsLimit
,
...
...
@@ -153,7 +153,7 @@ func (cfg M3dbSection) queryTagPairsOptions(input dataobj.EndpointMetricRecv) (i
return
index
.
Query
{
idx
.
NewConjunctionQuery
(
q1
,
q2
)},
index
.
AggregationOptions
{
QueryOptions
:
index
.
QueryOptions
{
StartInclusive
:
time
.
Time
{}
,
StartInclusive
:
indexStartTime
()
,
EndExclusive
:
time
.
Now
(),
SeriesLimit
:
cfg
.
SeriesLimit
,
DocsLimit
:
cfg
.
DocsLimit
,
...
...
@@ -188,7 +188,7 @@ func (cfg M3dbSection) queryIndexByCludeOptions(input dataobj.CludeRecv) (index.
}
return
query
,
index
.
QueryOptions
{
StartInclusive
:
time
.
Time
{}
,
StartInclusive
:
indexStartTime
()
,
EndExclusive
:
time
.
Now
(),
SeriesLimit
:
cfg
.
SeriesLimit
,
DocsLimit
:
cfg
.
DocsLimit
,
...
...
@@ -218,7 +218,7 @@ func (cfg M3dbSection) queryIndexByFullTagsOptions(input dataobj.IndexByFullTags
}
return
query
,
index
.
QueryOptions
{
StartInclusive
:
time
.
Time
{}
,
StartInclusive
:
indexStartTime
()
,
EndExclusive
:
time
.
Now
(),
SeriesLimit
:
cfg
.
SeriesLimit
,
DocsLimit
:
cfg
.
DocsLimit
,
...
...
src/modules/transfer/backend/m3db/test/04-query-metrics.sh
浏览文件 @
dd67efe0
...
...
@@ -7,7 +7,7 @@
curl
-X
POST
\
http://localhost:8008/api/index/metrics
\
-d
'{
"endpoints": []
"endpoints": [
"10.178.24.116"
]
}'
src/modules/transfer/http/routes/query_router.go
浏览文件 @
dd67efe0
...
...
@@ -148,5 +148,10 @@ func GetIndexByFullTags(c *gin.Context) {
}
resp
:=
dataSource
.
QueryIndexByFullTags
(
recvs
)
render
.
Data
(
c
,
resp
,
nil
)
render
.
Data
(
c
,
&
listResp
{
List
:
resp
,
Count
:
len
(
resp
)},
nil
)
}
type
listResp
struct
{
List
interface
{}
`json:"list"`
Count
int
`json:"count"`
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录