Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
doodoocoder
prometheus
提交
1a185941
P
prometheus
项目概览
doodoocoder
/
prometheus
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
prometheus
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
1a185941
编写于
2月 06, 2020
作者:
B
Ben Ye
提交者:
GitHub
2月 06, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
keep kubernetes metrics in global vars (#6765)
Signed-off-by:
N
yeya24
<
yb532204897@gmail.com
>
上级
641676b3
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
48 addition
and
18 deletion
+48
-18
discovery/kubernetes/endpoints.go
discovery/kubernetes/endpoints.go
+12
-6
discovery/kubernetes/ingress.go
discovery/kubernetes/ingress.go
+9
-3
discovery/kubernetes/node.go
discovery/kubernetes/node.go
+9
-3
discovery/kubernetes/pod.go
discovery/kubernetes/pod.go
+9
-3
discovery/kubernetes/service.go
discovery/kubernetes/service.go
+9
-3
未找到文件。
discovery/kubernetes/endpoints.go
浏览文件 @
1a185941
...
...
@@ -29,6 +29,12 @@ import (
"github.com/prometheus/prometheus/discovery/targetgroup"
)
var
(
epAddCount
=
eventCount
.
WithLabelValues
(
"endpoints"
,
"add"
)
epUpdateCount
=
eventCount
.
WithLabelValues
(
"endpoints"
,
"update"
)
epDeleteCount
=
eventCount
.
WithLabelValues
(
"endpoints"
,
"delete"
)
)
// Endpoints discovers new endpoint targets.
type
Endpoints
struct
{
logger
log
.
Logger
...
...
@@ -62,15 +68,15 @@ func NewEndpoints(l log.Logger, svc, eps, pod cache.SharedInformer) *Endpoints {
e
.
endpointsInf
.
AddEventHandler
(
cache
.
ResourceEventHandlerFuncs
{
AddFunc
:
func
(
o
interface
{})
{
e
ventCount
.
WithLabelValues
(
"endpoints"
,
"add"
)
.
Inc
()
e
pAddCount
.
Inc
()
e
.
enqueue
(
o
)
},
UpdateFunc
:
func
(
_
,
o
interface
{})
{
e
ventCount
.
WithLabelValues
(
"endpoints"
,
"update"
)
.
Inc
()
e
pUpdateCount
.
Inc
()
e
.
enqueue
(
o
)
},
DeleteFunc
:
func
(
o
interface
{})
{
e
ventCount
.
WithLabelValues
(
"endpoints"
,
"delete"
)
.
Inc
()
e
pDeleteCount
.
Inc
()
e
.
enqueue
(
o
)
},
})
...
...
@@ -98,15 +104,15 @@ func NewEndpoints(l log.Logger, svc, eps, pod cache.SharedInformer) *Endpoints {
// TODO(fabxc): potentially remove add and delete event handlers. Those should
// be triggered via the endpoint handlers already.
AddFunc
:
func
(
o
interface
{})
{
eventCount
.
WithLabelValues
(
"service"
,
"add"
)
.
Inc
()
svcAddCount
.
Inc
()
serviceUpdate
(
o
)
},
UpdateFunc
:
func
(
_
,
o
interface
{})
{
eventCount
.
WithLabelValues
(
"service"
,
"update"
)
.
Inc
()
svcUpdateCount
.
Inc
()
serviceUpdate
(
o
)
},
DeleteFunc
:
func
(
o
interface
{})
{
eventCount
.
WithLabelValues
(
"service"
,
"delete"
)
.
Inc
()
svcDeleteCount
.
Inc
()
serviceUpdate
(
o
)
},
})
...
...
discovery/kubernetes/ingress.go
浏览文件 @
1a185941
...
...
@@ -28,6 +28,12 @@ import (
"github.com/prometheus/prometheus/util/strutil"
)
var
(
ingressAddCount
=
eventCount
.
WithLabelValues
(
"ingress"
,
"add"
)
ingressUpdateCount
=
eventCount
.
WithLabelValues
(
"ingress"
,
"update"
)
ingressDeleteCount
=
eventCount
.
WithLabelValues
(
"ingress"
,
"delete"
)
)
// Ingress implements discovery of Kubernetes ingress.
type
Ingress
struct
{
logger
log
.
Logger
...
...
@@ -41,15 +47,15 @@ func NewIngress(l log.Logger, inf cache.SharedInformer) *Ingress {
s
:=
&
Ingress
{
logger
:
l
,
informer
:
inf
,
store
:
inf
.
GetStore
(),
queue
:
workqueue
.
NewNamed
(
"ingress"
)}
s
.
informer
.
AddEventHandler
(
cache
.
ResourceEventHandlerFuncs
{
AddFunc
:
func
(
o
interface
{})
{
eventCount
.
WithLabelValues
(
"ingress"
,
"add"
)
.
Inc
()
ingressAddCount
.
Inc
()
s
.
enqueue
(
o
)
},
DeleteFunc
:
func
(
o
interface
{})
{
eventCount
.
WithLabelValues
(
"ingress"
,
"delete"
)
.
Inc
()
ingressDeleteCount
.
Inc
()
s
.
enqueue
(
o
)
},
UpdateFunc
:
func
(
_
,
o
interface
{})
{
eventCount
.
WithLabelValues
(
"ingress"
,
"update"
)
.
Inc
()
ingressUpdateCount
.
Inc
()
s
.
enqueue
(
o
)
},
})
...
...
discovery/kubernetes/node.go
浏览文件 @
1a185941
...
...
@@ -34,6 +34,12 @@ const (
NodeLegacyHostIP
=
"LegacyHostIP"
)
var
(
nodeAddCount
=
eventCount
.
WithLabelValues
(
"node"
,
"add"
)
nodeUpdateCount
=
eventCount
.
WithLabelValues
(
"node"
,
"update"
)
nodeDeleteCount
=
eventCount
.
WithLabelValues
(
"node"
,
"delete"
)
)
// Node discovers Kubernetes nodes.
type
Node
struct
{
logger
log
.
Logger
...
...
@@ -50,15 +56,15 @@ func NewNode(l log.Logger, inf cache.SharedInformer) *Node {
n
:=
&
Node
{
logger
:
l
,
informer
:
inf
,
store
:
inf
.
GetStore
(),
queue
:
workqueue
.
NewNamed
(
"node"
)}
n
.
informer
.
AddEventHandler
(
cache
.
ResourceEventHandlerFuncs
{
AddFunc
:
func
(
o
interface
{})
{
eventCount
.
WithLabelValues
(
"node"
,
"add"
)
.
Inc
()
nodeAddCount
.
Inc
()
n
.
enqueue
(
o
)
},
DeleteFunc
:
func
(
o
interface
{})
{
eventCount
.
WithLabelValues
(
"node"
,
"delete"
)
.
Inc
()
nodeDeleteCount
.
Inc
()
n
.
enqueue
(
o
)
},
UpdateFunc
:
func
(
_
,
o
interface
{})
{
eventCount
.
WithLabelValues
(
"node"
,
"update"
)
.
Inc
()
nodeUpdateCount
.
Inc
()
n
.
enqueue
(
o
)
},
})
...
...
discovery/kubernetes/pod.go
浏览文件 @
1a185941
...
...
@@ -32,6 +32,12 @@ import (
"github.com/prometheus/prometheus/util/strutil"
)
var
(
podAddCount
=
eventCount
.
WithLabelValues
(
"pod"
,
"add"
)
podUpdateCount
=
eventCount
.
WithLabelValues
(
"pod"
,
"update"
)
podDeleteCount
=
eventCount
.
WithLabelValues
(
"pod"
,
"delete"
)
)
// Pod discovers new pod targets.
type
Pod
struct
{
informer
cache
.
SharedInformer
...
...
@@ -53,15 +59,15 @@ func NewPod(l log.Logger, pods cache.SharedInformer) *Pod {
}
p
.
informer
.
AddEventHandler
(
cache
.
ResourceEventHandlerFuncs
{
AddFunc
:
func
(
o
interface
{})
{
eventCount
.
WithLabelValues
(
"pod"
,
"add"
)
.
Inc
()
podAddCount
.
Inc
()
p
.
enqueue
(
o
)
},
DeleteFunc
:
func
(
o
interface
{})
{
eventCount
.
WithLabelValues
(
"pod"
,
"delete"
)
.
Inc
()
podDeleteCount
.
Inc
()
p
.
enqueue
(
o
)
},
UpdateFunc
:
func
(
_
,
o
interface
{})
{
eventCount
.
WithLabelValues
(
"pod"
,
"update"
)
.
Inc
()
podUpdateCount
.
Inc
()
p
.
enqueue
(
o
)
},
})
...
...
discovery/kubernetes/service.go
浏览文件 @
1a185941
...
...
@@ -30,6 +30,12 @@ import (
"github.com/prometheus/prometheus/util/strutil"
)
var
(
svcAddCount
=
eventCount
.
WithLabelValues
(
"service"
,
"add"
)
svcUpdateCount
=
eventCount
.
WithLabelValues
(
"service"
,
"update"
)
svcDeleteCount
=
eventCount
.
WithLabelValues
(
"service"
,
"delete"
)
)
// Service implements discovery of Kubernetes services.
type
Service
struct
{
logger
log
.
Logger
...
...
@@ -46,15 +52,15 @@ func NewService(l log.Logger, inf cache.SharedInformer) *Service {
s
:=
&
Service
{
logger
:
l
,
informer
:
inf
,
store
:
inf
.
GetStore
(),
queue
:
workqueue
.
NewNamed
(
"service"
)}
s
.
informer
.
AddEventHandler
(
cache
.
ResourceEventHandlerFuncs
{
AddFunc
:
func
(
o
interface
{})
{
eventCount
.
WithLabelValues
(
"service"
,
"add"
)
.
Inc
()
svcAddCount
.
Inc
()
s
.
enqueue
(
o
)
},
DeleteFunc
:
func
(
o
interface
{})
{
eventCount
.
WithLabelValues
(
"service"
,
"delete"
)
.
Inc
()
svcDeleteCount
.
Inc
()
s
.
enqueue
(
o
)
},
UpdateFunc
:
func
(
_
,
o
interface
{})
{
eventCount
.
WithLabelValues
(
"service"
,
"update"
)
.
Inc
()
svcUpdateCount
.
Inc
()
s
.
enqueue
(
o
)
},
})
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录