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
32c66c2b
Commit
32c66c2b
authored
Jan 16, 2018
by
Marek Grabowski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add apiserver metric for number of requests dropped by 'inflight-request' filters.
parent
0770ef06
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
1 deletion
+24
-1
metrics.go
...ing/src/k8s.io/apiserver/pkg/endpoints/metrics/metrics.go
+16
-0
maxinflight.go
...ng/src/k8s.io/apiserver/pkg/server/filters/maxinflight.go
+8
-1
No files found.
staging/src/k8s.io/apiserver/pkg/endpoints/metrics/metrics.go
View file @
32c66c2b
...
@@ -78,9 +78,24 @@ var (
...
@@ -78,9 +78,24 @@ var (
},
},
[]
string
{
"verb"
,
"resource"
,
"subresource"
,
"scope"
},
[]
string
{
"verb"
,
"resource"
,
"subresource"
,
"scope"
},
)
)
// DroppedRequests is a number of requests dropped with 'Try again later' reponse"
DroppedRequests
=
prometheus
.
NewCounterVec
(
prometheus
.
CounterOpts
{
Name
:
"apiserver_dropped_requests"
,
Help
:
"Number of requests dropped with 'Try again later' reponse"
,
},
[]
string
{
"requestKind"
},
)
kubectlExeRegexp
=
regexp
.
MustCompile
(
`^.*((?i:kubectl\.exe))`
)
kubectlExeRegexp
=
regexp
.
MustCompile
(
`^.*((?i:kubectl\.exe))`
)
)
)
const
(
// ReadOnlyKind is a string identifying read only request kind
ReadOnlyKind
=
"readOnly"
// MutatingKind is a string identifying mutating request kind
MutatingKind
=
"mutating"
)
func
init
()
{
func
init
()
{
// Register all metrics.
// Register all metrics.
prometheus
.
MustRegister
(
requestCounter
)
prometheus
.
MustRegister
(
requestCounter
)
...
@@ -88,6 +103,7 @@ func init() {
...
@@ -88,6 +103,7 @@ func init() {
prometheus
.
MustRegister
(
requestLatencies
)
prometheus
.
MustRegister
(
requestLatencies
)
prometheus
.
MustRegister
(
requestLatenciesSummary
)
prometheus
.
MustRegister
(
requestLatenciesSummary
)
prometheus
.
MustRegister
(
responseSizes
)
prometheus
.
MustRegister
(
responseSizes
)
prometheus
.
MustRegister
(
DroppedRequests
)
}
}
// Record records a single request to the standard metrics endpoints. For use by handlers that perform their own
// Record records a single request to the standard metrics endpoints. For use by handlers that perform their own
...
...
staging/src/k8s.io/apiserver/pkg/server/filters/maxinflight.go
View file @
32c66c2b
...
@@ -79,7 +79,8 @@ func WithMaxInFlightLimit(
...
@@ -79,7 +79,8 @@ func WithMaxInFlightLimit(
}
}
var
c
chan
bool
var
c
chan
bool
if
!
nonMutatingRequestVerbs
.
Has
(
requestInfo
.
Verb
)
{
isMutatingRequest
:=
!
nonMutatingRequestVerbs
.
Has
(
requestInfo
.
Verb
)
if
isMutatingRequest
{
c
=
mutatingChan
c
=
mutatingChan
}
else
{
}
else
{
c
=
nonMutatingChan
c
=
nonMutatingChan
...
@@ -95,6 +96,12 @@ func WithMaxInFlightLimit(
...
@@ -95,6 +96,12 @@ func WithMaxInFlightLimit(
handler
.
ServeHTTP
(
w
,
r
)
handler
.
ServeHTTP
(
w
,
r
)
default
:
default
:
// We need to split this data between buckets used for throttling.
if
isMutatingRequest
{
metrics
.
DroppedRequests
.
WithLabelValues
(
metrics
.
MutatingKind
)
.
Inc
()
}
else
{
metrics
.
DroppedRequests
.
WithLabelValues
(
metrics
.
ReadOnlyKind
)
.
Inc
()
}
// at this point we're about to return a 429, BUT not all actors should be rate limited. A system:master is so powerful
// at this point we're about to return a 429, BUT not all actors should be rate limited. A system:master is so powerful
// that he should always get an answer. It's a super-admin or a loopback connection.
// that he should always get an answer. It's a super-admin or a loopback connection.
if
currUser
,
ok
:=
apirequest
.
UserFrom
(
ctx
);
ok
{
if
currUser
,
ok
:=
apirequest
.
UserFrom
(
ctx
);
ok
{
...
...
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