Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DiDi
nightingale
提交
8ce71de6
N
nightingale
项目概览
DiDi
/
nightingale
12 个月 前同步成功
通知
46
Star
7053
Fork
1161
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
N
nightingale
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
8ce71de6
编写于
3月 21, 2022
作者:
U
Ulric Qin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
code refactor for append labels
上级
6d9846f1
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
47 addition
and
50 deletion
+47
-50
src/server/common/label_append.go
src/server/common/label_append.go
+36
-0
src/server/idents/idents.go
src/server/idents/idents.go
+3
-13
src/server/memsto/target_cache.go
src/server/memsto/target_cache.go
+0
-13
src/server/router/router_datadog.go
src/server/router/router_datadog.go
+2
-6
src/server/router/router_openfalcon.go
src/server/router/router_openfalcon.go
+2
-6
src/server/router/router_opentsdb.go
src/server/router/router_opentsdb.go
+2
-6
src/server/router/router_prom.go
src/server/router/router_prom.go
+2
-6
未找到文件。
src/server/common/label_append.go
0 → 100644
浏览文件 @
8ce71de6
package
common
import
(
"github.com/didi/nightingale/v5/src/models"
"github.com/didi/nightingale/v5/src/server/memsto"
"github.com/prometheus/prometheus/prompb"
)
func
AppendLabels
(
pt
*
prompb
.
TimeSeries
,
target
*
models
.
Target
)
{
if
target
==
nil
{
return
}
for
key
,
value
:=
range
target
.
TagsMap
{
pt
.
Labels
=
append
(
pt
.
Labels
,
&
prompb
.
Label
{
Name
:
key
,
Value
:
value
,
})
}
if
target
.
GroupId
>
0
{
bg
:=
memsto
.
BusiGroupCache
.
GetByBusiGroupId
(
target
.
GroupId
)
if
bg
==
nil
{
return
}
if
bg
.
LabelEnable
==
0
{
return
}
pt
.
Labels
=
append
(
pt
.
Labels
,
&
prompb
.
Label
{
Name
:
"busigroup"
,
Value
:
bg
.
LabelValue
,
})
}
}
src/server/idents/idents.go
浏览文件 @
8ce71de6
...
...
@@ -12,6 +12,7 @@ import (
"github.com/toolkits/pkg/logger"
"github.com/didi/nightingale/v5/src/models"
"github.com/didi/nightingale/v5/src/server/common"
"github.com/didi/nightingale/v5/src/server/config"
"github.com/didi/nightingale/v5/src/server/memsto"
"github.com/didi/nightingale/v5/src/server/naming"
...
...
@@ -166,13 +167,7 @@ func pushMetrics() {
logger
.
Errorf
(
"handle_idents: insert target(%s) fail: %v"
,
active
,
err
)
}
}
else
{
// target already exists
for
label
,
value
:=
range
target
.
TagsMap
{
pt
.
Labels
=
append
(
pt
.
Labels
,
&
prompb
.
Label
{
Name
:
label
,
Value
:
value
,
})
}
common
.
AppendLabels
(
pt
,
target
)
}
series
=
append
(
series
,
pt
)
...
...
@@ -199,12 +194,7 @@ func pushMetrics() {
Value
:
ident
,
})
for
label
,
value
:=
range
dead
.
TagsMap
{
pt
.
Labels
=
append
(
pt
.
Labels
,
&
prompb
.
Label
{
Name
:
label
,
Value
:
value
,
})
}
common
.
AppendLabels
(
pt
,
dead
)
series
=
append
(
series
,
pt
)
}
...
...
src/server/memsto/target_cache.go
浏览文件 @
8ce71de6
...
...
@@ -123,19 +123,6 @@ func syncTargets() error {
lst
[
i
]
.
TagsMap
[
arr
[
0
]]
=
arr
[
1
]
}
// handle BusiGroup's LabelValue
// BusiGroup的LabelValue就相当于一个特殊的标签来对待
if
lst
[
i
]
.
GroupId
>
0
{
bg
:=
BusiGroupCache
.
GetByBusiGroupId
(
lst
[
i
]
.
GroupId
)
if
bg
==
nil
{
return
errors
.
New
(
"busi group cache not ready"
)
}
if
bg
.
LabelEnable
==
1
{
lst
[
i
]
.
TagsMap
[
"busigroup"
]
=
bg
.
LabelValue
}
}
m
[
lst
[
i
]
.
Ident
]
=
lst
[
i
]
}
...
...
src/server/router/router_datadog.go
浏览文件 @
8ce71de6
...
...
@@ -10,6 +10,7 @@ import (
"strings"
"time"
"github.com/didi/nightingale/v5/src/server/common"
"github.com/didi/nightingale/v5/src/server/config"
"github.com/didi/nightingale/v5/src/server/idents"
"github.com/didi/nightingale/v5/src/server/memsto"
...
...
@@ -238,12 +239,7 @@ func datadogSeries(c *gin.Context) {
// fill tags
target
,
has
:=
memsto
.
TargetCache
.
Get
(
ident
)
if
has
{
for
key
,
value
:=
range
target
.
TagsMap
{
pt
.
Labels
=
append
(
pt
.
Labels
,
&
prompb
.
Label
{
Name
:
key
,
Value
:
value
,
})
}
common
.
AppendLabels
(
pt
,
target
)
}
}
...
...
src/server/router/router_openfalcon.go
浏览文件 @
8ce71de6
...
...
@@ -10,6 +10,7 @@ import (
"strings"
"time"
"github.com/didi/nightingale/v5/src/server/common"
"github.com/didi/nightingale/v5/src/server/config"
"github.com/didi/nightingale/v5/src/server/idents"
"github.com/didi/nightingale/v5/src/server/memsto"
...
...
@@ -206,12 +207,7 @@ func falconPush(c *gin.Context) {
// fill tags
target
,
has
:=
memsto
.
TargetCache
.
Get
(
ident
)
if
has
{
for
key
,
value
:=
range
target
.
TagsMap
{
pt
.
Labels
=
append
(
pt
.
Labels
,
&
prompb
.
Label
{
Name
:
key
,
Value
:
value
,
})
}
common
.
AppendLabels
(
pt
,
target
)
}
}
...
...
src/server/router/router_opentsdb.go
浏览文件 @
8ce71de6
...
...
@@ -14,6 +14,7 @@ import (
"github.com/prometheus/common/model"
"github.com/prometheus/prometheus/prompb"
"github.com/didi/nightingale/v5/src/server/common"
"github.com/didi/nightingale/v5/src/server/config"
"github.com/didi/nightingale/v5/src/server/idents"
"github.com/didi/nightingale/v5/src/server/memsto"
...
...
@@ -190,12 +191,7 @@ func handleOpenTSDB(c *gin.Context) {
// fill tags
target
,
has
:=
memsto
.
TargetCache
.
Get
(
host
)
if
has
{
for
key
,
value
:=
range
target
.
TagsMap
{
pt
.
Labels
=
append
(
pt
.
Labels
,
&
prompb
.
Label
{
Name
:
key
,
Value
:
value
,
})
}
common
.
AppendLabels
(
pt
,
target
)
}
}
...
...
src/server/router/router_prom.go
浏览文件 @
8ce71de6
...
...
@@ -12,6 +12,7 @@ import (
"github.com/prometheus/prometheus/prompb"
"github.com/toolkits/pkg/ginx"
"github.com/didi/nightingale/v5/src/server/common"
"github.com/didi/nightingale/v5/src/server/config"
"github.com/didi/nightingale/v5/src/server/engine"
"github.com/didi/nightingale/v5/src/server/idents"
...
...
@@ -92,12 +93,7 @@ func remoteWrite(c *gin.Context) {
// fill tags
target
,
has
:=
memsto
.
TargetCache
.
Get
(
ident
)
if
has
{
for
key
,
value
:=
range
target
.
TagsMap
{
req
.
Timeseries
[
i
]
.
Labels
=
append
(
req
.
Timeseries
[
i
]
.
Labels
,
&
prompb
.
Label
{
Name
:
key
,
Value
:
value
,
})
}
common
.
AppendLabels
(
req
.
Timeseries
[
i
],
target
)
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录