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
0
Merge Requests
0
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
Boxiang Sun
gitlab-ce
Commits
249c9a8c
Commit
249c9a8c
authored
Jan 02, 2018
by
Pawel Chojnacki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Auto enable prometheus service if Prometheus is Installed
parent
0c802f4f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
4 deletions
+6
-4
app/models/project_services/prometheus_service.rb
app/models/project_services/prometheus_service.rb
+6
-4
No files found.
app/models/project_services/prometheus_service.rb
View file @
249c9a8c
...
...
@@ -8,6 +8,7 @@ class PrometheusService < MonitoringService
# Access to prometheus is directly through the API
prop_accessor
:api_url
boolean_accessor
:manual_configuration
boolean_accessor
:prometheus_installed
with_options
presence:
true
,
if: :manual_configuration?
do
validates
:api_url
,
url:
true
...
...
@@ -20,7 +21,7 @@ class PrometheusService < MonitoringService
def
initialize_properties
if
properties
.
nil?
self
.
properties
=
{}
self
.
properties
=
{
prometheus_installed:
false
}
end
end
...
...
@@ -118,7 +119,7 @@ class PrometheusService < MonitoringService
if
manual_configuration?
Gitlab
::
PrometheusClient
.
new
(
RestClient
::
Resource
.
new
(
api_url
))
else
cluster
=
find_
cluster_with_prometheus
(
environment_id
)
cluster
=
cluster_with_prometheus
(
environment_id
)
raise
Gitlab
::
PrometheusError
,
"couldn't find cluster with Prometheus installed"
unless
cluster
Gitlab
::
PrometheusClient
.
new
(
cluster
.
application_prometheus
.
proxy_client
)
...
...
@@ -127,7 +128,7 @@ class PrometheusService < MonitoringService
private
def
find_cluster_with_prometheus
(
environment_id
)
def
cluster_with_prometheus
(
environment_id
=
nil
)
clusters
=
if
environment_id
::
Environment
.
find_by
(
id:
environment_id
).
try
(
:enabled_clusters
)
||
[]
else
...
...
@@ -143,6 +144,7 @@ class PrometheusService < MonitoringService
end
def
synchronize_service_state!
self
.
active
=
manual_configuration
self
.
active
=
prometheus_installed?
||
manual_configuration?
||
cluster_with_prometheus
.
present?
self
.
prometheus_installed
=
!
manual_configuration?
&&
cluster_with_prometheus
.
present?
end
end
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