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
0c802f4f
Commit
0c802f4f
authored
Jan 02, 2018
by
Pawel Chojnacki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Manual Configuration instead of Activation. Prometheus Service just got a bit weirder
parent
b38b5ceb
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
8 deletions
+29
-8
app/controllers/concerns/service_params.rb
app/controllers/concerns/service_params.rb
+1
-0
app/models/project_services/prometheus_service.rb
app/models/project_services/prometheus_service.rb
+28
-8
No files found.
app/controllers/concerns/service_params.rb
View file @
0c802f4f
...
@@ -32,6 +32,7 @@ module ServiceParams
...
@@ -32,6 +32,7 @@ module ServiceParams
:issues_events
,
:issues_events
,
:issues_url
,
:issues_url
,
:jira_issue_transition_id
,
:jira_issue_transition_id
,
:manual_configuration
,
:merge_requests_events
,
:merge_requests_events
,
:mock_service_url
,
:mock_service_url
,
:namespace
,
:namespace
,
...
...
app/models/project_services/prometheus_service.rb
View file @
0c802f4f
...
@@ -7,19 +7,27 @@ class PrometheusService < MonitoringService
...
@@ -7,19 +7,27 @@ class PrometheusService < MonitoringService
# Access to prometheus is directly through the API
# Access to prometheus is directly through the API
prop_accessor
:api_url
prop_accessor
:api_url
boolean_accessor
:manual_configuration
with_options
presence:
true
,
if: :
activated
?
do
with_options
presence:
true
,
if: :
manual_configuration
?
do
validates
:api_url
,
url:
true
validates
:api_url
,
url:
true
end
end
before_save
:synchronize_service_state!
after_save
:clear_reactive_cache!
after_save
:clear_reactive_cache!
def
initialize_properties
def
initialize_properties
if
properties
.
nil?
if
properties
.
nil?
self
.
properties
=
{}
self
.
properties
=
{}
end
end
end
end
def
show_active_box?
false
end
def
title
def
title
'Prometheus'
'Prometheus'
end
end
...
@@ -34,6 +42,18 @@ class PrometheusService < MonitoringService
...
@@ -34,6 +42,18 @@ class PrometheusService < MonitoringService
def
fields
def
fields
[
[
{
type:
'fieldset'
,
legend:
'Manual Configuration'
,
fields:
[
{
type:
'checkbox'
,
name:
'manual_configuration'
,
title:
s_
(
'PrometheusService|Active'
),
required:
true
}
]
},
{
{
type:
'text'
,
type:
'text'
,
name:
'api_url'
,
name:
'api_url'
,
...
@@ -79,16 +99,11 @@ class PrometheusService < MonitoringService
...
@@ -79,16 +99,11 @@ class PrometheusService < MonitoringService
with_reactive_cache
(
Gitlab
::
Prometheus
::
Queries
::
MatchedMetricsQuery
.
name
,
nil
,
&
:itself
)
with_reactive_cache
(
Gitlab
::
Prometheus
::
Queries
::
MatchedMetricsQuery
.
name
,
nil
,
&
:itself
)
end
end
def
manual_mode?
false
end
# Cache metrics for specific environment
# Cache metrics for specific environment
def
calculate_reactive_cache
(
query_class_name
,
environment_id
,
*
args
)
def
calculate_reactive_cache
(
query_class_name
,
environment_id
,
*
args
)
return
unless
active?
&&
project
&&
!
project
.
pending_delete?
return
unless
active?
&&
project
&&
!
project
.
pending_delete?
client
=
client
(
environment_id
)
client
=
client
(
environment_id
)
data
=
Kernel
.
const_get
(
query_class_name
).
new
(
client
).
query
(
environment_id
,
*
args
)
data
=
Kernel
.
const_get
(
query_class_name
).
new
(
client
).
query
(
environment_id
,
*
args
)
{
{
success:
true
,
success:
true
,
...
@@ -100,12 +115,13 @@ class PrometheusService < MonitoringService
...
@@ -100,12 +115,13 @@ class PrometheusService < MonitoringService
end
end
def
client
(
environment_id
)
def
client
(
environment_id
)
if
manual_
mode
?
if
manual_
configuration
?
Gitlab
::
PrometheusClient
.
new
(
RestClient
::
Resource
.
new
(
api_url
))
Gitlab
::
PrometheusClient
.
new
(
RestClient
::
Resource
.
new
(
api_url
))
else
else
cluster
=
find_cluster_with_prometheus
(
environment_id
)
cluster
=
find_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
)
if
cluster
Gitlab
::
PrometheusClient
.
new
(
cluster
.
application_prometheus
.
proxy_client
)
end
end
end
end
...
@@ -125,4 +141,8 @@ class PrometheusService < MonitoringService
...
@@ -125,4 +141,8 @@ class PrometheusService < MonitoringService
metrics
[
:metrics
]
=
metrics
.
delete
:data
metrics
[
:metrics
]
=
metrics
.
delete
:data
metrics
metrics
end
end
def
synchronize_service_state!
self
.
active
=
manual_configuration
end
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