Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
23b9f658
Commit
23b9f658
authored
Feb 14, 2018
by
Joe Betz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
In etcd-version-monitor, Remove grpc labels used only in etcd 3 format when…
In etcd-version-monitor, Remove grpc labels used only in etcd 3 format when translating metric back to 3.0 format
parent
c007efcc
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
68 additions
and
2 deletions
+68
-2
BUILD
cluster/images/etcd-version-monitor/BUILD
+1
-0
Makefile
cluster/images/etcd-version-monitor/Makefile
+1
-1
etcd-version-monitor.go
cluster/images/etcd-version-monitor/etcd-version-monitor.go
+65
-0
etcd-version-monitor.yaml
...ter/images/etcd-version-monitor/etcd-version-monitor.yaml
+1
-1
No files found.
cluster/images/etcd-version-monitor/BUILD
View file @
23b9f658
...
@@ -17,6 +17,7 @@ go_library(
...
@@ -17,6 +17,7 @@ go_library(
srcs = ["etcd-version-monitor.go"],
srcs = ["etcd-version-monitor.go"],
importpath = "k8s.io/kubernetes/cluster/images/etcd-version-monitor",
importpath = "k8s.io/kubernetes/cluster/images/etcd-version-monitor",
deps = [
deps = [
"//vendor/github.com/gogo/protobuf/proto:go_default_library",
"//vendor/github.com/golang/glog:go_default_library",
"//vendor/github.com/golang/glog:go_default_library",
"//vendor/github.com/prometheus/client_golang/prometheus:go_default_library",
"//vendor/github.com/prometheus/client_golang/prometheus:go_default_library",
"//vendor/github.com/prometheus/client_golang/prometheus/promhttp:go_default_library",
"//vendor/github.com/prometheus/client_golang/prometheus/promhttp:go_default_library",
...
...
cluster/images/etcd-version-monitor/Makefile
View file @
23b9f658
...
@@ -20,7 +20,7 @@
...
@@ -20,7 +20,7 @@
ARCH
:=
amd64
ARCH
:=
amd64
GOLANG_VERSION
?=
1.8.3
GOLANG_VERSION
?=
1.8.3
REGISTRY
?=
staging-k8s.gcr.io
REGISTRY
?=
staging-k8s.gcr.io
TAG
?=
0.1.
1
TAG
?=
0.1.
2
IMAGE
:=
$(REGISTRY)
/etcd-version-monitor:
$(TAG)
IMAGE
:=
$(REGISTRY)
/etcd-version-monitor:
$(TAG)
CURRENT_DIR
:=
$(pwd)
CURRENT_DIR
:=
$(pwd)
TEMP_DIR
:=
$(
shell
mktemp
-d
)
TEMP_DIR
:=
$(
shell
mktemp
-d
)
...
...
cluster/images/etcd-version-monitor/etcd-version-monitor.go
View file @
23b9f658
...
@@ -17,12 +17,14 @@ limitations under the License.
...
@@ -17,12 +17,14 @@ limitations under the License.
package
main
package
main
import
(
import
(
"bytes"
"encoding/json"
"encoding/json"
goflag
"flag"
goflag
"flag"
"fmt"
"fmt"
"net/http"
"net/http"
"time"
"time"
"github.com/gogo/protobuf/proto"
"github.com/golang/glog"
"github.com/golang/glog"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"
"github.com/prometheus/client_golang/prometheus/promhttp"
...
@@ -97,6 +99,13 @@ var (
...
@@ -97,6 +99,13 @@ var (
"grpc_method"
:
"method"
,
"grpc_method"
:
"method"
,
"grpc_service"
:
"service"
,
"grpc_service"
:
"service"
,
})
})
filterMetricsByLabels
(
mf
,
map
[
string
]
string
{
"grpc_type"
:
"unary"
,
})
groupCounterMetricsByLabels
(
mf
,
map
[
string
]
bool
{
"grpc_type"
:
true
,
"grpc_code"
:
true
,
})
return
mf
,
nil
return
mf
,
nil
},
},
},
},
...
@@ -280,6 +289,62 @@ func renameLabels(mf *dto.MetricFamily, nameMapping map[string]string) {
...
@@ -280,6 +289,62 @@ func renameLabels(mf *dto.MetricFamily, nameMapping map[string]string) {
}
}
}
}
func
filterMetricsByLabels
(
mf
*
dto
.
MetricFamily
,
labelValues
map
[
string
]
string
)
{
buf
:=
mf
.
Metric
[
:
0
]
for
_
,
m
:=
range
mf
.
Metric
{
shouldRemove
:=
false
for
_
,
lbl
:=
range
m
.
Label
{
if
val
,
ok
:=
labelValues
[
*
lbl
.
Name
];
ok
&&
val
!=
*
lbl
.
Value
{
shouldRemove
=
true
break
}
}
if
!
shouldRemove
{
buf
=
append
(
buf
,
m
)
}
}
mf
.
Metric
=
buf
}
func
groupCounterMetricsByLabels
(
mf
*
dto
.
MetricFamily
,
names
map
[
string
]
bool
)
{
buf
:=
mf
.
Metric
[
:
0
]
deleteLabels
(
mf
,
names
)
byLabels
:=
map
[
string
]
*
dto
.
Metric
{}
for
_
,
m
:=
range
mf
.
Metric
{
if
metric
,
ok
:=
byLabels
[
labelsKey
(
m
.
Label
)];
ok
{
metric
.
Counter
.
Value
=
proto
.
Float64
(
*
metric
.
Counter
.
Value
+
*
m
.
Counter
.
Value
)
}
else
{
byLabels
[
labelsKey
(
m
.
Label
)]
=
m
buf
=
append
(
buf
,
m
)
}
}
mf
.
Metric
=
buf
}
func
labelsKey
(
lbls
[]
*
dto
.
LabelPair
)
string
{
var
buf
bytes
.
Buffer
for
i
,
lbl
:=
range
lbls
{
buf
.
WriteString
(
lbl
.
String
())
if
i
<
len
(
lbls
)
-
1
{
buf
.
WriteString
(
","
)
}
}
return
buf
.
String
()
}
func
deleteLabels
(
mf
*
dto
.
MetricFamily
,
names
map
[
string
]
bool
)
{
for
_
,
m
:=
range
mf
.
Metric
{
buf
:=
m
.
Label
[
:
0
]
for
_
,
lbl
:=
range
m
.
Label
{
shouldRemove
:=
names
[
*
lbl
.
Name
]
if
!
shouldRemove
{
buf
=
append
(
buf
,
lbl
)
}
}
m
.
Label
=
buf
}
}
func
identity
(
mf
*
dto
.
MetricFamily
)
(
*
dto
.
MetricFamily
,
error
)
{
func
identity
(
mf
*
dto
.
MetricFamily
)
(
*
dto
.
MetricFamily
,
error
)
{
return
mf
,
nil
return
mf
,
nil
}
}
...
...
cluster/images/etcd-version-monitor/etcd-version-monitor.yaml
View file @
23b9f658
...
@@ -7,7 +7,7 @@ spec:
...
@@ -7,7 +7,7 @@ spec:
hostNetwork
:
true
hostNetwork
:
true
containers
:
containers
:
-
name
:
etcd-version-monitor
-
name
:
etcd-version-monitor
image
:
k8s.gcr.io/etcd-version-monitor:0.1.
0
image
:
k8s.gcr.io/etcd-version-monitor:0.1.
2
command
:
command
:
-
/etcd-version-monitor
-
/etcd-version-monitor
-
--logtostderr
-
--logtostderr
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment