Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
a28a2fba
Unverified
Commit
a28a2fba
authored
Oct 02, 2020
by
Carl Bergquist
Committed by
GitHub
Oct 02, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
healthchecks should work regardless domain (#27981)
parent
845bc7c4
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
4 deletions
+15
-4
pkg/api/api.go
+0
-4
pkg/api/http_server.go
+15
-0
No files found.
pkg/api/api.go
View file @
a28a2fba
...
...
@@ -436,9 +436,5 @@ func (hs *HTTPServer) registerRoutes() {
r
.
Get
(
"/api/snapshots-delete/:deleteKey"
,
reqSnapshotPublicModeOrSignedIn
,
Wrap
(
DeleteDashboardSnapshotByDeleteKey
))
r
.
Delete
(
"/api/snapshots/:key"
,
reqEditorRole
,
Wrap
(
DeleteDashboardSnapshot
))
// Health check
r
.
Get
(
"/api/health"
,
hs
.
apiHealthHandler
)
r
.
Get
(
"/healthz"
,
hs
.
healthzHandler
)
r
.
Get
(
"/*"
,
reqSignedIn
,
hs
.
Index
)
}
pkg/api/http_server.go
View file @
a28a2fba
...
...
@@ -332,7 +332,12 @@ func (hs *HTTPServer) addMiddlewaresAndStaticRoutes() {
Delims
:
macaron
.
Delims
{
Left
:
"[["
,
Right
:
"]]"
},
}))
// These endpoints are used for monitoring the Grafana instance
// and should not be redirect or rejected.
m
.
Use
(
hs
.
healthzHandler
)
m
.
Use
(
hs
.
apiHealthHandler
)
m
.
Use
(
hs
.
metricsEndpoint
)
m
.
Use
(
middleware
.
GetContextHandler
(
hs
.
AuthTokenService
,
hs
.
RemoteCacheService
,
...
...
@@ -373,6 +378,11 @@ func (hs *HTTPServer) metricsEndpoint(ctx *macaron.Context) {
// healthzHandler always return 200 - Ok if Grafana's web server is running
func
(
hs
*
HTTPServer
)
healthzHandler
(
ctx
*
macaron
.
Context
)
{
notHeadOrGet
:=
ctx
.
Req
.
Method
!=
http
.
MethodGet
&&
ctx
.
Req
.
Method
!=
http
.
MethodHead
if
notHeadOrGet
||
ctx
.
Req
.
URL
.
Path
!=
"/healthz"
{
return
}
ctx
.
WriteHeader
(
200
)
_
,
err
:=
ctx
.
Resp
.
Write
([]
byte
(
"Ok"
))
if
err
!=
nil
{
...
...
@@ -384,6 +394,11 @@ func (hs *HTTPServer) healthzHandler(ctx *macaron.Context) {
// can access the database. If the database cannot be access it will return
// http status code 503.
func
(
hs
*
HTTPServer
)
apiHealthHandler
(
ctx
*
macaron
.
Context
)
{
notHeadOrGet
:=
ctx
.
Req
.
Method
!=
http
.
MethodGet
&&
ctx
.
Req
.
Method
!=
http
.
MethodHead
if
notHeadOrGet
||
ctx
.
Req
.
URL
.
Path
!=
"/api/health"
{
return
}
data
:=
simplejson
.
New
()
data
.
Set
(
"database"
,
"ok"
)
if
!
hs
.
Cfg
.
AnonymousHideVersion
{
...
...
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