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
314bff1b
Commit
314bff1b
authored
Sep 13, 2017
by
bergquist
Committed by
Carl Bergquist
Sep 14, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adds grafana_ prefix for none standard metrics
parent
9c30bf53
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
112 additions
and
67 deletions
+112
-67
pkg/api/route_register_test.go
+3
-3
pkg/metrics/graphitebridge/graphite.go
+8
-1
pkg/metrics/graphitebridge/graphite_test.go
+3
-3
pkg/metrics/metrics.go
+98
-60
No files found.
pkg/api/route_register_test.go
View file @
314bff1b
...
...
@@ -55,7 +55,7 @@ func TestRouteSimpleRegister(t *testing.T) {
t
.
Errorf
(
"want %v routes, got %v"
,
len
(
testTable
),
len
(
fr
.
route
))
}
for
i
,
_
:=
range
testTable
{
for
i
:=
range
testTable
{
if
testTable
[
i
]
.
method
!=
fr
.
route
[
i
]
.
method
{
t
.
Errorf
(
"want %s got %v"
,
testTable
[
i
]
.
method
,
fr
.
route
[
i
]
.
method
)
}
...
...
@@ -109,7 +109,7 @@ func TestRouteGroupedRegister(t *testing.T) {
t
.
Errorf
(
"want %v routes, got %v"
,
len
(
testTable
),
len
(
fr
.
route
))
}
for
i
,
_
:=
range
testTable
{
for
i
:=
range
testTable
{
if
testTable
[
i
]
.
method
!=
fr
.
route
[
i
]
.
method
{
t
.
Errorf
(
"want %s got %v"
,
testTable
[
i
]
.
method
,
fr
.
route
[
i
]
.
method
)
}
...
...
@@ -165,7 +165,7 @@ func TestNamedMiddlewareRouteRegister(t *testing.T) {
t
.
Errorf
(
"want %v routes, got %v"
,
len
(
testTable
),
len
(
fr
.
route
))
}
for
i
,
_
:=
range
testTable
{
for
i
:=
range
testTable
{
if
testTable
[
i
]
.
method
!=
fr
.
route
[
i
]
.
method
{
t
.
Errorf
(
"want %s got %v"
,
testTable
[
i
]
.
method
,
fr
.
route
[
i
]
.
method
)
}
...
...
pkg/metrics/graphitebridge/graphite.go
View file @
314bff1b
...
...
@@ -54,6 +54,7 @@ const (
)
var
metricCategoryPrefix
[]
string
=
[]
string
{
"proxy_"
,
"api_"
,
"page_"
,
"alerting_"
,
"aws_"
,
"db_"
,
"stat_"
,
"go_"
,
"process_"
}
var
trimMetricPrefix
[]
string
=
[]
string
{
"grafana_"
}
// Config defines the Graphite bridge config.
type
Config
struct
{
...
...
@@ -237,7 +238,13 @@ func writeMetric(buf *bufio.Writer, m model.Metric, mf *dto.MetricFamily) error
for
_
,
v
:=
range
metricCategoryPrefix
{
if
strings
.
HasPrefix
(
string
(
metricName
),
v
)
{
group
:=
strings
.
Replace
(
v
,
"_"
,
" "
,
1
)
metricName
=
model
.
LabelValue
(
strings
.
Replace
(
string
(
metricName
),
v
,
group
,
-
1
))
metricName
=
model
.
LabelValue
(
strings
.
Replace
(
string
(
metricName
),
v
,
group
,
1
))
}
}
for
_
,
v
:=
range
trimMetricPrefix
{
if
strings
.
HasPrefix
(
string
(
metricName
),
v
)
{
metricName
=
model
.
LabelValue
(
strings
.
Replace
(
string
(
metricName
),
v
,
""
,
1
))
}
}
...
...
pkg/metrics/graphitebridge/graphite_test.go
View file @
314bff1b
...
...
@@ -370,10 +370,10 @@ func TestCounter(t *testing.T) {
}
}
func
Test
CanIgnoreSomeMetrics
(
t
*
testing
.
T
)
{
func
Test
TrimGrafanaNamespace
(
t
*
testing
.
T
)
{
cntVec
:=
prometheus
.
NewCounter
(
prometheus
.
CounterOpts
{
Name
:
"http_request_total"
,
Name
:
"
grafana_
http_request_total"
,
Help
:
"docstring"
,
ConstLabels
:
prometheus
.
Labels
{
"constname"
:
"constvalue"
},
})
...
...
@@ -404,7 +404,7 @@ func TestCanIgnoreSomeMetrics(t *testing.T) {
t
.
Fatalf
(
"error: %v"
,
err
)
}
want
:=
""
want
:=
"
prefix.http_request_total.constname.constvalue.count 1 1477043
\n
"
if
got
:=
buf
.
String
();
want
!=
got
{
t
.
Fatalf
(
"wanted
\n
%s
\n
, got
\n
%s
\n
"
,
want
,
got
)
}
...
...
pkg/metrics/metrics.go
View file @
314bff1b
...
...
@@ -15,6 +15,8 @@ import (
"github.com/prometheus/client_golang/prometheus"
)
const
exporterName
=
"grafana"
var
(
M_Instance_Start
prometheus
.
Counter
M_Page_Status
*
prometheus
.
CounterVec
...
...
@@ -58,30 +60,34 @@ var (
func
init
()
{
M_Instance_Start
=
prometheus
.
NewCounter
(
prometheus
.
CounterOpts
{
Name
:
"instance_start_total"
,
Help
:
"counter for started instances"
,
Name
:
"instance_start_total"
,
Help
:
"counter for started instances"
,
Namespace
:
exporterName
,
})
M_Page_Status
=
prometheus
.
NewCounterVec
(
prometheus
.
CounterOpts
{
Name
:
"page_response_status_total"
,
Help
:
"page http response status"
,
Name
:
"page_response_status_total"
,
Help
:
"page http response status"
,
Namespace
:
exporterName
,
},
[]
string
{
"code"
},
)
M_Api_Status
=
prometheus
.
NewCounterVec
(
prometheus
.
CounterOpts
{
Name
:
"api_response_status_total"
,
Help
:
"api http response status"
,
Name
:
"api_response_status_total"
,
Help
:
"api http response status"
,
Namespace
:
exporterName
,
},
[]
string
{
"code"
},
)
M_Proxy_Status
=
prometheus
.
NewCounterVec
(
prometheus
.
CounterOpts
{
Name
:
"proxy_response_status_total"
,
Help
:
"proxy http response status"
,
Name
:
"proxy_response_status_total"
,
Help
:
"proxy http response status"
,
Namespace
:
exporterName
,
},
[]
string
{
"code"
},
)
...
...
@@ -103,127 +109,159 @@ func init() {
)
M_Api_User_SignUpStarted
=
prometheus
.
NewCounter
(
prometheus
.
CounterOpts
{
Name
:
"api_user_signup_started_total"
,
Help
:
"amount of users who started the signup flow"
,
Name
:
"api_user_signup_started_total"
,
Help
:
"amount of users who started the signup flow"
,
Namespace
:
exporterName
,
})
M_Api_User_SignUpCompleted
=
prometheus
.
NewCounter
(
prometheus
.
CounterOpts
{
Name
:
"api_user_signup_completed_total"
,
Help
:
"amount of users who completed the signup flow"
,
Name
:
"api_user_signup_completed_total"
,
Help
:
"amount of users who completed the signup flow"
,
Namespace
:
exporterName
,
})
M_Api_User_SignUpInvite
=
prometheus
.
NewCounter
(
prometheus
.
CounterOpts
{
Name
:
"api_user_signup_invite_total"
,
Help
:
"amount of users who have been invited"
,
Name
:
"api_user_signup_invite_total"
,
Help
:
"amount of users who have been invited"
,
Namespace
:
exporterName
,
})
M_Api_Dashboard_Save
=
prometheus
.
NewSummary
(
prometheus
.
SummaryOpts
{
Name
:
"api_dashboard_save"
,
Help
:
"summary for dashboard save duration"
,
Name
:
"api_dashboard_save"
,
Help
:
"summary for dashboard save duration"
,
Namespace
:
exporterName
,
})
M_Api_Dashboard_Get
=
prometheus
.
NewSummary
(
prometheus
.
SummaryOpts
{
Name
:
"api_dashboard_get"
,
Help
:
"summary for dashboard get duration"
,
Name
:
"api_dashboard_get"
,
Help
:
"summary for dashboard get duration"
,
Namespace
:
exporterName
,
})
M_Api_Dashboard_Search
=
prometheus
.
NewSummary
(
prometheus
.
SummaryOpts
{
Name
:
"api_dashboard_search"
,
Help
:
"summary for dashboard search duration"
,
Name
:
"api_dashboard_search"
,
Help
:
"summary for dashboard search duration"
,
Namespace
:
exporterName
,
})
M_Api_Admin_User_Create
=
prometheus
.
NewCounter
(
prometheus
.
CounterOpts
{
Name
:
"api_admin_user_created_total"
,
Help
:
"api admin user created counter"
,
Name
:
"api_admin_user_created_total"
,
Help
:
"api admin user created counter"
,
Namespace
:
exporterName
,
})
M_Api_Login_Post
=
prometheus
.
NewCounter
(
prometheus
.
CounterOpts
{
Name
:
"api_login_post_total"
,
Help
:
"api login post counter"
,
Name
:
"api_login_post_total"
,
Help
:
"api login post counter"
,
Namespace
:
exporterName
,
})
M_Api_Login_OAuth
=
prometheus
.
NewCounter
(
prometheus
.
CounterOpts
{
Name
:
"api_login_oauth_total"
,
Help
:
"api login oauth counter"
,
Name
:
"api_login_oauth_total"
,
Help
:
"api login oauth counter"
,
Namespace
:
exporterName
,
})
M_Api_Org_Create
=
prometheus
.
NewCounter
(
prometheus
.
CounterOpts
{
Name
:
"api_org_create_total"
,
Help
:
"api org created counter"
,
Name
:
"api_org_create_total"
,
Help
:
"api org created counter"
,
Namespace
:
exporterName
,
})
M_Api_Dashboard_Snapshot_Create
=
prometheus
.
NewCounter
(
prometheus
.
CounterOpts
{
Name
:
"api_dashboard_snapshot_create_total"
,
Help
:
"dashboard snapshots created"
,
Name
:
"api_dashboard_snapshot_create_total"
,
Help
:
"dashboard snapshots created"
,
Namespace
:
exporterName
,
})
M_Api_Dashboard_Snapshot_External
=
prometheus
.
NewCounter
(
prometheus
.
CounterOpts
{
Name
:
"api_dashboard_snapshot_external_total"
,
Help
:
"external dashboard snapshots created"
,
Name
:
"api_dashboard_snapshot_external_total"
,
Help
:
"external dashboard snapshots created"
,
Namespace
:
exporterName
,
})
M_Api_Dashboard_Snapshot_Get
=
prometheus
.
NewCounter
(
prometheus
.
CounterOpts
{
Name
:
"api_dashboard_snapshot_get_total"
,
Help
:
"loaded dashboards"
,
Name
:
"api_dashboard_snapshot_get_total"
,
Help
:
"loaded dashboards"
,
Namespace
:
exporterName
,
})
M_Api_Dashboard_Insert
=
prometheus
.
NewCounter
(
prometheus
.
CounterOpts
{
Name
:
"api_models_dashboard_insert_total"
,
Help
:
"dashboards inserted "
,
Name
:
"api_models_dashboard_insert_total"
,
Help
:
"dashboards inserted "
,
Namespace
:
exporterName
,
})
M_Alerting_Result_State
=
prometheus
.
NewCounterVec
(
prometheus
.
CounterOpts
{
Name
:
"alerting_result_total"
,
Help
:
"alert execution result counter"
,
Name
:
"alerting_result_total"
,
Help
:
"alert execution result counter"
,
Namespace
:
exporterName
,
},
[]
string
{
"state"
})
M_Alerting_Notification_Sent
=
prometheus
.
NewCounterVec
(
prometheus
.
CounterOpts
{
Name
:
"alerting_notification_sent_total"
,
Help
:
"counter for how many alert notifications been sent"
,
Name
:
"alerting_notification_sent_total"
,
Help
:
"counter for how many alert notifications been sent"
,
Namespace
:
exporterName
,
},
[]
string
{
"type"
})
M_Aws_CloudWatch_GetMetricStatistics
=
prometheus
.
NewCounter
(
prometheus
.
CounterOpts
{
Name
:
"aws_cloudwatch_get_metric_statistics_total"
,
Help
:
"counter for getting metric statistics from aws"
,
Name
:
"aws_cloudwatch_get_metric_statistics_total"
,
Help
:
"counter for getting metric statistics from aws"
,
Namespace
:
exporterName
,
})
M_Aws_CloudWatch_ListMetrics
=
prometheus
.
NewCounter
(
prometheus
.
CounterOpts
{
Name
:
"aws_cloudwatch_list_metrics_total"
,
Help
:
"counter for getting list of metrics from aws"
,
Name
:
"aws_cloudwatch_list_metrics_total"
,
Help
:
"counter for getting list of metrics from aws"
,
Namespace
:
exporterName
,
})
M_DB_DataSource_QueryById
=
prometheus
.
NewCounter
(
prometheus
.
CounterOpts
{
Name
:
"db_datasource_query_by_id_total"
,
Help
:
"counter for getting datasource by id"
,
Name
:
"db_datasource_query_by_id_total"
,
Help
:
"counter for getting datasource by id"
,
Namespace
:
exporterName
,
})
M_DataSource_ProxyReq_Timer
=
prometheus
.
NewSummary
(
prometheus
.
SummaryOpts
{
Name
:
"api_dataproxy_request_all"
,
Help
:
"summary for dashboard search duration"
,
Name
:
"api_dataproxy_request_all"
,
Help
:
"summary for dashboard search duration"
,
Namespace
:
exporterName
,
})
M_Alerting_Execution_Time
=
prometheus
.
NewSummary
(
prometheus
.
SummaryOpts
{
Name
:
"alerting_execution_time_seconds"
,
Help
:
"summary of alert exeuction duration"
,
Name
:
"alerting_execution_time_seconds"
,
Help
:
"summary of alert exeuction duration"
,
Namespace
:
exporterName
,
})
M_Alerting_Active_Alerts
=
prometheus
.
NewGauge
(
prometheus
.
GaugeOpts
{
Name
:
"alerting_active_alerts"
,
Help
:
"amount of active alerts"
,
Name
:
"alerting_active_alerts"
,
Help
:
"amount of active alerts"
,
Namespace
:
exporterName
,
})
M_StatTotal_Dashboards
=
prometheus
.
NewGauge
(
prometheus
.
GaugeOpts
{
Name
:
"stat_totals_dashboard"
,
Help
:
"total amount of dashboards"
,
Name
:
"stat_totals_dashboard"
,
Help
:
"total amount of dashboards"
,
Namespace
:
exporterName
,
})
M_StatTotal_Users
=
prometheus
.
NewGauge
(
prometheus
.
GaugeOpts
{
Name
:
"stat_total_users"
,
Help
:
"total amount of users"
,
Name
:
"stat_total_users"
,
Help
:
"total amount of users"
,
Namespace
:
exporterName
,
})
M_StatTotal_Orgs
=
prometheus
.
NewGauge
(
prometheus
.
GaugeOpts
{
Name
:
"stat_total_orgs"
,
Help
:
"total amount of orgs"
,
Name
:
"stat_total_orgs"
,
Help
:
"total amount of orgs"
,
Namespace
:
exporterName
,
})
M_StatTotal_Playlists
=
prometheus
.
NewGauge
(
prometheus
.
GaugeOpts
{
Name
:
"stat_total_playlists"
,
Help
:
"total amount of playlists"
,
Name
:
"stat_total_playlists"
,
Help
:
"total amount of playlists"
,
Namespace
:
exporterName
,
})
}
...
...
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