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
6c5860d3
Commit
6c5860d3
authored
Sep 12, 2016
by
bergquist
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(metrics): measure proxy requests
parent
eb673fd1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
60 additions
and
24 deletions
+60
-24
pkg/metrics/metrics.go
+17
-4
pkg/middleware/request_metrics.go
+43
-20
No files found.
pkg/metrics/metrics.go
View file @
6c5860d3
...
...
@@ -13,9 +13,15 @@ var (
M_Page_Status_200
Counter
M_Page_Status_500
Counter
M_Page_Status_404
Counter
M_Api_Status_500
Counter
M_Api_Status_404
Counter
M_Page_Status_Unknown
Counter
M_Api_Status_200
Counter
M_Api_Status_404
Counter
M_Api_Status_500
Counter
M_Api_Status_Unknown
Counter
M_Proxy_Status_200
Counter
M_Proxy_Status_404
Counter
M_Proxy_Status_500
Counter
M_Proxy_Status_Unknown
Counter
M_Api_User_SignUpStarted
Counter
M_Api_User_SignUpCompleted
Counter
M_Api_User_SignUpInvite
Counter
...
...
@@ -55,10 +61,17 @@ func initMetricVars(settings *MetricSettings) {
M_Page_Status_200
=
RegCounter
(
"page.resp_status"
,
"code"
,
"200"
)
M_Page_Status_500
=
RegCounter
(
"page.resp_status"
,
"code"
,
"500"
)
M_Page_Status_404
=
RegCounter
(
"page.resp_status"
,
"code"
,
"404"
)
M_Page_Status_Unknown
=
RegCounter
(
"page.resp_status"
,
"code"
,
"unknown"
)
M_Api_Status_500
=
RegCounter
(
"api.resp_status"
,
"code"
,
"500"
)
M_Api_Status_404
=
RegCounter
(
"api.resp_status"
,
"code"
,
"404"
)
M_Api_Status_200
=
RegCounter
(
"api.resp_status"
,
"code"
,
"200"
)
M_Api_Status_404
=
RegCounter
(
"api.resp_status"
,
"code"
,
"404"
)
M_Api_Status_500
=
RegCounter
(
"api.resp_status"
,
"code"
,
"500"
)
M_Api_Status_Unknown
=
RegCounter
(
"api.resp_status"
,
"code"
,
"unknown"
)
M_Proxy_Status_200
=
RegCounter
(
"proxy.resp_status"
,
"code"
,
"200"
)
M_Proxy_Status_404
=
RegCounter
(
"proxy.resp_status"
,
"code"
,
"404"
)
M_Proxy_Status_500
=
RegCounter
(
"proxy.resp_status"
,
"code"
,
"500"
)
M_Proxy_Status_Unknown
=
RegCounter
(
"proxy.resp_status"
,
"code"
,
"unknown"
)
M_Api_User_SignUpStarted
=
RegCounter
(
"api.user.signup_started"
)
M_Api_User_SignUpCompleted
=
RegCounter
(
"api.user.signup_completed"
)
...
...
pkg/middleware/request_metrics.go
View file @
6c5860d3
...
...
@@ -16,27 +16,50 @@ func RequestMetrics() macaron.Handler {
status
:=
rw
.
Status
()
if
strings
.
HasPrefix
(
req
.
RequestURI
,
"/api/datasources/proxy"
)
{
return
}
if
strings
.
HasPrefix
(
req
.
RequestURI
,
"/api/"
)
{
switch
status
{
case
200
:
metrics
.
M_Api_Status_200
.
Inc
(
1
)
case
404
:
metrics
.
M_Api_Status_404
.
Inc
(
1
)
case
500
:
metrics
.
M_Api_Status_500
.
Inc
(
1
)
}
countProxyRequests
(
status
)
}
else
if
strings
.
HasPrefix
(
req
.
RequestURI
,
"/api/"
)
{
countApiRequests
(
status
)
}
else
{
switch
status
{
case
200
:
metrics
.
M_Page_Status_200
.
Inc
(
1
)
case
404
:
metrics
.
M_Page_Status_404
.
Inc
(
1
)
case
500
:
metrics
.
M_Page_Status_500
.
Inc
(
1
)
}
countPageRequests
(
status
)
}
}
}
func
countApiRequests
(
status
int
)
{
switch
status
{
case
200
:
metrics
.
M_Api_Status_200
.
Inc
(
1
)
case
404
:
metrics
.
M_Api_Status_404
.
Inc
(
1
)
case
500
:
metrics
.
M_Api_Status_500
.
Inc
(
1
)
default
:
metrics
.
M_Api_Status_Unknown
.
Inc
(
1
)
}
}
func
countPageRequests
(
status
int
)
{
switch
status
{
case
200
:
metrics
.
M_Page_Status_200
.
Inc
(
1
)
case
404
:
metrics
.
M_Page_Status_404
.
Inc
(
1
)
case
500
:
metrics
.
M_Page_Status_500
.
Inc
(
1
)
default
:
metrics
.
M_Page_Status_Unknown
.
Inc
(
1
)
}
}
func
countProxyRequests
(
status
int
)
{
switch
status
{
case
200
:
metrics
.
M_Proxy_Status_200
.
Inc
(
1
)
case
404
:
metrics
.
M_Proxy_Status_404
.
Inc
(
1
)
case
500
:
metrics
.
M_Proxy_Status_500
.
Inc
(
1
)
default
:
metrics
.
M_Proxy_Status_Unknown
.
Inc
(
1
)
}
}
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