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
10c819d3
Commit
10c819d3
authored
Oct 21, 2019
by
Kirstie Cook
Committed by
Mayra Cabrera
Oct 21, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Expose prometheus state to monitor dashboard
Add tests for presence and absence of cluster and deployment platform
parent
72104c3b
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
56 additions
and
0 deletions
+56
-0
app/helpers/environments_helper.rb
app/helpers/environments_helper.rb
+1
-0
app/models/environment.rb
app/models/environment.rb
+4
-0
changelogs/unreleased/show-prometheus-is-updating.yml
changelogs/unreleased/show-prometheus-is-updating.yml
+5
-0
spec/helpers/environments_helper_spec.rb
spec/helpers/environments_helper_spec.rb
+1
-0
spec/models/environment_spec.rb
spec/models/environment_spec.rb
+45
-0
No files found.
app/helpers/environments_helper.rb
View file @
10c819d3
...
@@ -34,6 +34,7 @@ module EnvironmentsHelper
...
@@ -34,6 +34,7 @@ module EnvironmentsHelper
"project-path"
=>
project_path
(
project
),
"project-path"
=>
project_path
(
project
),
"tags-path"
=>
project_tags_path
(
project
),
"tags-path"
=>
project_tags_path
(
project
),
"has-metrics"
=>
"
#{
environment
.
has_metrics?
}
"
,
"has-metrics"
=>
"
#{
environment
.
has_metrics?
}
"
,
"prometheus-status"
=>
"
#{
environment
.
prometheus_status
}
"
,
"external-dashboard-url"
=>
project
.
metrics_setting_external_dashboard_url
"external-dashboard-url"
=>
project
.
metrics_setting_external_dashboard_url
}
}
end
end
...
...
app/models/environment.rb
View file @
10c819d3
...
@@ -188,6 +188,10 @@ class Environment < ApplicationRecord
...
@@ -188,6 +188,10 @@ class Environment < ApplicationRecord
prometheus_adapter
.
query
(
:environment
,
self
)
if
has_metrics?
prometheus_adapter
.
query
(
:environment
,
self
)
if
has_metrics?
end
end
def
prometheus_status
deployment_platform
&
.
cluster
&
.
application_prometheus
&
.
status_name
end
def
additional_metrics
(
*
args
)
def
additional_metrics
(
*
args
)
return
unless
has_metrics?
return
unless
has_metrics?
...
...
changelogs/unreleased/show-prometheus-is-updating.yml
0 → 100644
View file @
10c819d3
---
title
:
Expose prometheus status to monitor dashboard
merge_request
:
18289
author
:
type
:
fixed
spec/helpers/environments_helper_spec.rb
View file @
10c819d3
...
@@ -32,6 +32,7 @@ describe EnvironmentsHelper do
...
@@ -32,6 +32,7 @@ describe EnvironmentsHelper do
'project-path'
=>
project_path
(
project
),
'project-path'
=>
project_path
(
project
),
'tags-path'
=>
project_tags_path
(
project
),
'tags-path'
=>
project_tags_path
(
project
),
'has-metrics'
=>
"
#{
environment
.
has_metrics?
}
"
,
'has-metrics'
=>
"
#{
environment
.
has_metrics?
}
"
,
'prometheus-status'
=>
"
#{
environment
.
prometheus_status
}
"
,
'external-dashboard-url'
=>
nil
'external-dashboard-url'
=>
nil
)
)
end
end
...
...
spec/models/environment_spec.rb
View file @
10c819d3
...
@@ -727,6 +727,51 @@ describe Environment, :use_clean_rails_memory_store_caching do
...
@@ -727,6 +727,51 @@ describe Environment, :use_clean_rails_memory_store_caching do
end
end
end
end
describe
'#prometheus_status'
do
context
'when a cluster is present'
do
context
'when a deployment platform is present'
do
let
(
:cluster
)
{
create
(
:cluster
,
:provided_by_user
,
:project
)
}
let
(
:environment
)
{
create
(
:environment
,
project:
cluster
.
project
)
}
subject
{
environment
.
prometheus_status
}
context
'when the prometheus application status is :updating'
do
let!
(
:prometheus
)
{
create
(
:clusters_applications_prometheus
,
:updating
,
cluster:
cluster
)
}
it
{
is_expected
.
to
eq
(
:updating
)
}
end
context
'when the prometheus application state is :updated'
do
let!
(
:prometheus
)
{
create
(
:clusters_applications_prometheus
,
:updated
,
cluster:
cluster
)
}
it
{
is_expected
.
to
eq
(
:updated
)
}
end
context
'when the prometheus application is not installed'
do
it
{
is_expected
.
to
be_nil
}
end
end
context
'when a deployment platform is not present'
do
let
(
:cluster
)
{
create
(
:cluster
,
:project
)
}
let
(
:environment
)
{
create
(
:environment
,
project:
cluster
.
project
)
}
subject
{
environment
.
prometheus_status
}
it
{
is_expected
.
to
be_nil
}
end
end
context
'when a cluster is not present'
do
let
(
:project
)
{
create
(
:project
,
:stubbed_repository
)
}
let
(
:environment
)
{
create
(
:environment
,
project:
project
)
}
subject
{
environment
.
prometheus_status
}
it
{
is_expected
.
to
be_nil
}
end
end
describe
'#additional_metrics'
do
describe
'#additional_metrics'
do
let
(
:project
)
{
create
(
:prometheus_project
)
}
let
(
:project
)
{
create
(
:prometheus_project
)
}
let
(
:metric_params
)
{
[]
}
let
(
:metric_params
)
{
[]
}
...
...
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