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
45d212da
Commit
45d212da
authored
Dec 03, 2019
by
Etienne Baqué
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added configured? method to PrometheusAdapter
parent
3cb5e9e0
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
18 additions
and
2 deletions
+18
-2
app/models/clusters/applications/prometheus.rb
app/models/clusters/applications/prometheus.rb
+4
-0
app/models/concerns/prometheus_adapter.rb
app/models/concerns/prometheus_adapter.rb
+8
-0
app/models/environment.rb
app/models/environment.rb
+2
-2
app/models/project_services/prometheus_service.rb
app/models/project_services/prometheus_service.rb
+4
-0
No files found.
app/models/clusters/applications/prometheus.rb
View file @
45d212da
...
...
@@ -91,6 +91,10 @@ module Clusters
# we need to silence the exceptions
end
def
configured?
kube_client
.
present?
&&
available?
end
private
def
disable_prometheus_integration
...
...
app/models/concerns/prometheus_adapter.rb
View file @
45d212da
...
...
@@ -16,6 +16,14 @@ module PrometheusAdapter
raise
NotImplementedError
end
# This is a light-weight check if a prometheus client is properly configured.
def
configured?
raise
NotImplemented
end
# This is a heavy-weight check if a prometheus is properly configured and accesible from GitLab.
# This actually sends a request to an external service and often it could take a long time,
# Please consider using `configured?` instead if the process is running on unicorn/puma threads.
def
can_query?
prometheus_client
.
present?
end
...
...
app/models/environment.rb
View file @
45d212da
...
...
@@ -193,11 +193,11 @@ class Environment < ApplicationRecord
end
def
has_metrics?
available?
&&
prometheus_adapter
&
.
c
an_query
?
available?
&&
prometheus_adapter
&
.
c
onfigured
?
end
def
metrics
prometheus_adapter
.
query
(
:environment
,
self
)
if
has_metrics?
prometheus_adapter
.
query
(
:environment
,
self
)
if
has_metrics?
&&
prometheus_adapter
.
can_query?
end
def
prometheus_status
...
...
app/models/project_services/prometheus_service.rb
View file @
45d212da
...
...
@@ -95,6 +95,10 @@ class PrometheusService < MonitoringService
self_monitoring_project?
&&
internal_prometheus_url?
end
def
configured?
should_return_client?
end
private
def
self_monitoring_project?
...
...
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