Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
C
Coredns
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Railgun
Coredns
Commits
634e3fe8
Commit
634e3fe8
authored
Mar 19, 2021
by
Miek Gieben
Committed by
GitHub
Mar 19, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
plugin/health: add logging for local health request (#4533)
parent
8faca268
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
4 deletions
+9
-4
plugin/health/README.md
plugin/health/README.md
+2
-2
plugin/health/overloaded.go
plugin/health/overloaded.go
+7
-2
No files found.
plugin/health/README.md
View file @
634e3fe8
...
@@ -27,7 +27,7 @@ health [ADDRESS] {
...
@@ -27,7 +27,7 @@ health [ADDRESS] {
~~~
~~~
*
Where
`lameduck`
will delay shutdown for
**DURATION**
. /health will still answer 200 OK.
*
Where
`lameduck`
will delay shutdown for
**DURATION**
. /health will still answer 200 OK.
Note: The
*ready*
plugin will not answer OK while CoreDNS is in lameduck mode prior to shutdown.
Note: The
*ready*
plugin will not answer OK while CoreDNS is in lame
duck mode prior to shutdown.
If you have multiple Server Blocks,
*health*
can only be enabled in one of them (as it is process
If you have multiple Server Blocks,
*health*
can only be enabled in one of them (as it is process
wide). If you really need multiple endpoints, you must run health endpoints on different ports:
wide). If you really need multiple endpoints, you must run health endpoints on different ports:
...
@@ -67,7 +67,7 @@ Run another health endpoint on http://localhost:8091.
...
@@ -67,7 +67,7 @@ Run another health endpoint on http://localhost:8091.
}
}
~~~
~~~
Set a lameduck duration of 1 second:
Set a lame
duck duration of 1 second:
~~~
corefile
~~~
corefile
. {
. {
...
...
plugin/health/overloaded.go
View file @
634e3fe8
...
@@ -12,7 +12,7 @@ import (
...
@@ -12,7 +12,7 @@ import (
// overloaded queries the health end point and updates a metrics showing how long it took.
// overloaded queries the health end point and updates a metrics showing how long it took.
func
(
h
*
health
)
overloaded
()
{
func
(
h
*
health
)
overloaded
()
{
timeout
:=
time
.
Duration
(
5
*
time
.
Second
)
timeout
:=
time
.
Duration
(
3
*
time
.
Second
)
client
:=
http
.
Client
{
client
:=
http
.
Client
{
Timeout
:
timeout
,
Timeout
:
timeout
,
}
}
...
@@ -27,10 +27,15 @@ func (h *health) overloaded() {
...
@@ -27,10 +27,15 @@ func (h *health) overloaded() {
resp
,
err
:=
client
.
Get
(
url
)
resp
,
err
:=
client
.
Get
(
url
)
if
err
!=
nil
{
if
err
!=
nil
{
HealthDuration
.
Observe
(
timeout
.
Seconds
())
HealthDuration
.
Observe
(
timeout
.
Seconds
())
log
.
Warningf
(
"Local health request to %q failed: %s"
,
url
,
err
)
continue
continue
}
}
resp
.
Body
.
Close
()
resp
.
Body
.
Close
()
HealthDuration
.
Observe
(
time
.
Since
(
start
)
.
Seconds
())
elapsed
:=
time
.
Since
(
start
)
HealthDuration
.
Observe
(
elapsed
.
Seconds
())
if
elapsed
>
time
.
Second
{
// 1s is pretty random, but a *local* scrape taking that long isn't good
log
.
Warningf
(
"Local health request to %q took more than 1s: %s"
,
url
,
elapsed
)
}
case
<-
h
.
stop
:
case
<-
h
.
stop
:
return
return
...
...
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