Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
bb65cb1f
Commit
bb65cb1f
authored
Jul 12, 2018
by
Andrew Newdigate
Committed by
Robert Speicher
Jul 12, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove healthchecks from prometheus endpoint
parent
07866b04
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
64 deletions
+11
-64
app/services/metrics_service.rb
app/services/metrics_service.rb
+1
-20
changelogs/unreleased/an-no-healthcheck-until-brooklyn.yml
changelogs/unreleased/an-no-healthcheck-until-brooklyn.yml
+5
-0
spec/controllers/metrics_controller_spec.rb
spec/controllers/metrics_controller_spec.rb
+5
-44
No files found.
app/services/metrics_service.rb
View file @
bb65cb1f
require
'prometheus/client/formats/text'
require
'prometheus/client/formats/text'
class
MetricsService
class
MetricsService
CHECKS
=
[
Gitlab
::
HealthChecks
::
DbCheck
,
Gitlab
::
HealthChecks
::
Redis
::
RedisCheck
,
Gitlab
::
HealthChecks
::
Redis
::
CacheCheck
,
Gitlab
::
HealthChecks
::
Redis
::
QueuesCheck
,
Gitlab
::
HealthChecks
::
Redis
::
SharedStateCheck
,
Gitlab
::
HealthChecks
::
GitalyCheck
].
freeze
def
prometheus_metrics_text
def
prometheus_metrics_text
Prometheus
::
Client
::
Formats
::
Text
.
marshal_multiprocess
(
multiprocess_metrics_path
)
Prometheus
::
Client
::
Formats
::
Text
.
marshal_multiprocess
(
multiprocess_metrics_path
)
end
end
def
health_metrics_text
metrics
=
CHECKS
.
flat_map
(
&
:metrics
)
formatter
.
marshal
(
metrics
)
end
def
metrics_text
def
metrics_text
prometheus_metrics_text
.
concat
(
health_metrics_text
)
prometheus_metrics_text
end
end
private
private
def
formatter
@formatter
||=
Gitlab
::
HealthChecks
::
PrometheusTextFormat
.
new
end
def
multiprocess_metrics_path
def
multiprocess_metrics_path
::
Prometheus
::
Client
.
configuration
.
multiprocess_files_dir
::
Prometheus
::
Client
.
configuration
.
multiprocess_files_dir
end
end
...
...
changelogs/unreleased/an-no-healthcheck-until-brooklyn.yml
0 → 100644
View file @
bb65cb1f
---
title
:
Remove healthchecks from prometheus endpoint
merge_request
:
20565
author
:
type
:
fixed
spec/controllers/metrics_controller_spec.rb
View file @
bb65cb1f
...
@@ -15,55 +15,16 @@ describe MetricsController do
...
@@ -15,55 +15,16 @@ describe MetricsController do
allow
(
Prometheus
::
Client
.
configuration
).
to
receive
(
:multiprocess_files_dir
).
and_return
(
metrics_multiproc_dir
)
allow
(
Prometheus
::
Client
.
configuration
).
to
receive
(
:multiprocess_files_dir
).
and_return
(
metrics_multiproc_dir
)
allow
(
Gitlab
::
Metrics
).
to
receive
(
:prometheus_metrics_enabled?
).
and_return
(
true
)
allow
(
Gitlab
::
Metrics
).
to
receive
(
:prometheus_metrics_enabled?
).
and_return
(
true
)
allow
(
Settings
.
monitoring
).
to
receive
(
:ip_whitelist
).
and_return
([
whitelisted_ip
,
whitelisted_ip_range
])
allow
(
Settings
.
monitoring
).
to
receive
(
:ip_whitelist
).
and_return
([
whitelisted_ip
,
whitelisted_ip_range
])
allow_any_instance_of
(
MetricsService
).
to
receive
(
:metrics_text
).
and_return
(
"prometheus_counter 1"
)
end
end
describe
'#index'
do
describe
'#index'
do
shared_examples_for
'endpoint providing metrics'
do
shared_examples_for
'endpoint providing metrics'
do
it
'returns
DB ping
metrics'
do
it
'returns
prometheus
metrics'
do
get
:index
get
:index
expect
(
response
.
body
).
to
match
(
/^db_ping_timeout 0$/
)
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
response
.
body
).
to
match
(
/^db_ping_success 1$/
)
expect
(
response
.
body
).
to
match
(
/^prometheus_counter 1$/
)
expect
(
response
.
body
).
to
match
(
/^db_ping_latency_seconds [0-9\.]+$/
)
end
it
'returns Redis ping metrics'
do
get
:index
expect
(
response
.
body
).
to
match
(
/^redis_ping_timeout 0$/
)
expect
(
response
.
body
).
to
match
(
/^redis_ping_success 1$/
)
expect
(
response
.
body
).
to
match
(
/^redis_ping_latency_seconds [0-9\.]+$/
)
end
it
'returns Caching ping metrics'
do
get
:index
expect
(
response
.
body
).
to
match
(
/^redis_cache_ping_timeout 0$/
)
expect
(
response
.
body
).
to
match
(
/^redis_cache_ping_success 1$/
)
expect
(
response
.
body
).
to
match
(
/^redis_cache_ping_latency_seconds [0-9\.]+$/
)
end
it
'returns Queues ping metrics'
do
get
:index
expect
(
response
.
body
).
to
match
(
/^redis_queues_ping_timeout 0$/
)
expect
(
response
.
body
).
to
match
(
/^redis_queues_ping_success 1$/
)
expect
(
response
.
body
).
to
match
(
/^redis_queues_ping_latency_seconds [0-9\.]+$/
)
end
it
'returns SharedState ping metrics'
do
get
:index
expect
(
response
.
body
).
to
match
(
/^redis_shared_state_ping_timeout 0$/
)
expect
(
response
.
body
).
to
match
(
/^redis_shared_state_ping_success 1$/
)
expect
(
response
.
body
).
to
match
(
/^redis_shared_state_ping_latency_seconds [0-9\.]+$/
)
end
it
'returns Gitaly metrics'
do
get
:index
expect
(
response
.
body
).
to
match
(
/^gitaly_health_check_success{shard="default"} 1$/
)
expect
(
response
.
body
).
to
match
(
/^gitaly_health_check_latency_seconds{shard="default"} [0-9\.]+$/
)
end
end
context
'prometheus metrics are disabled'
do
context
'prometheus metrics are disabled'
do
...
@@ -101,7 +62,7 @@ describe MetricsController do
...
@@ -101,7 +62,7 @@ describe MetricsController do
allow
(
Gitlab
::
RequestContext
).
to
receive
(
:client_ip
).
and_return
(
not_whitelisted_ip
)
allow
(
Gitlab
::
RequestContext
).
to
receive
(
:client_ip
).
and_return
(
not_whitelisted_ip
)
end
end
it
'returns
prope
r response'
do
it
'returns
the expected erro
r response'
do
get
:index
get
:index
expect
(
response
.
status
).
to
eq
(
404
)
expect
(
response
.
status
).
to
eq
(
404
)
...
...
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