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
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
8 deletions
+44
-8
pkg/metrics/metrics.go
+17
-4
pkg/middleware/request_metrics.go
+27
-4
No files found.
pkg/metrics/metrics.go
View file @
6c5860d3
...
@@ -13,9 +13,15 @@ var (
...
@@ -13,9 +13,15 @@ var (
M_Page_Status_200
Counter
M_Page_Status_200
Counter
M_Page_Status_500
Counter
M_Page_Status_500
Counter
M_Page_Status_404
Counter
M_Page_Status_404
Counter
M_Api_Status_500
Counter
M_Page_Status_Unknown
Counter
M_Api_Status_404
Counter
M_Api_Status_200
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_SignUpStarted
Counter
M_Api_User_SignUpCompleted
Counter
M_Api_User_SignUpCompleted
Counter
M_Api_User_SignUpInvite
Counter
M_Api_User_SignUpInvite
Counter
...
@@ -55,10 +61,17 @@ func initMetricVars(settings *MetricSettings) {
...
@@ -55,10 +61,17 @@ func initMetricVars(settings *MetricSettings) {
M_Page_Status_200
=
RegCounter
(
"page.resp_status"
,
"code"
,
"200"
)
M_Page_Status_200
=
RegCounter
(
"page.resp_status"
,
"code"
,
"200"
)
M_Page_Status_500
=
RegCounter
(
"page.resp_status"
,
"code"
,
"500"
)
M_Page_Status_500
=
RegCounter
(
"page.resp_status"
,
"code"
,
"500"
)
M_Page_Status_404
=
RegCounter
(
"page.resp_status"
,
"code"
,
"404"
)
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_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_SignUpStarted
=
RegCounter
(
"api.user.signup_started"
)
M_Api_User_SignUpCompleted
=
RegCounter
(
"api.user.signup_completed"
)
M_Api_User_SignUpCompleted
=
RegCounter
(
"api.user.signup_completed"
)
...
...
pkg/middleware/request_metrics.go
View file @
6c5860d3
...
@@ -16,10 +16,16 @@ func RequestMetrics() macaron.Handler {
...
@@ -16,10 +16,16 @@ func RequestMetrics() macaron.Handler {
status
:=
rw
.
Status
()
status
:=
rw
.
Status
()
if
strings
.
HasPrefix
(
req
.
RequestURI
,
"/api/datasources/proxy"
)
{
if
strings
.
HasPrefix
(
req
.
RequestURI
,
"/api/datasources/proxy"
)
{
return
countProxyRequests
(
status
)
}
else
if
strings
.
HasPrefix
(
req
.
RequestURI
,
"/api/"
)
{
countApiRequests
(
status
)
}
else
{
countPageRequests
(
status
)
}
}
}
}
if
strings
.
HasPrefix
(
req
.
RequestURI
,
"/api/"
)
{
func
countApiRequests
(
status
int
)
{
switch
status
{
switch
status
{
case
200
:
case
200
:
metrics
.
M_Api_Status_200
.
Inc
(
1
)
metrics
.
M_Api_Status_200
.
Inc
(
1
)
...
@@ -27,8 +33,12 @@ func RequestMetrics() macaron.Handler {
...
@@ -27,8 +33,12 @@ func RequestMetrics() macaron.Handler {
metrics
.
M_Api_Status_404
.
Inc
(
1
)
metrics
.
M_Api_Status_404
.
Inc
(
1
)
case
500
:
case
500
:
metrics
.
M_Api_Status_500
.
Inc
(
1
)
metrics
.
M_Api_Status_500
.
Inc
(
1
)
default
:
metrics
.
M_Api_Status_Unknown
.
Inc
(
1
)
}
}
}
else
{
}
func
countPageRequests
(
status
int
)
{
switch
status
{
switch
status
{
case
200
:
case
200
:
metrics
.
M_Page_Status_200
.
Inc
(
1
)
metrics
.
M_Page_Status_200
.
Inc
(
1
)
...
@@ -36,7 +46,20 @@ func RequestMetrics() macaron.Handler {
...
@@ -36,7 +46,20 @@ func RequestMetrics() macaron.Handler {
metrics
.
M_Page_Status_404
.
Inc
(
1
)
metrics
.
M_Page_Status_404
.
Inc
(
1
)
case
500
:
case
500
:
metrics
.
M_Page_Status_500
.
Inc
(
1
)
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