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
c873783c
Commit
c873783c
authored
Jun 04, 2020
by
Sean Arnold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Schedule update for prometheus after alert creation
parent
0813a73d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
0 deletions
+33
-0
app/services/prometheus/create_default_alerts_service.rb
app/services/prometheus/create_default_alerts_service.rb
+8
-0
spec/factories/clusters/clusters.rb
spec/factories/clusters/clusters.rb
+4
-0
spec/services/prometheus/create_default_alerts_service_spec.rb
...services/prometheus/create_default_alerts_service_spec.rb
+21
-0
No files found.
app/services/prometheus/create_default_alerts_service.rb
View file @
c873783c
...
...
@@ -33,6 +33,7 @@ module Prometheus
return
ServiceResponse
.
error
(
message:
'Invalid environment'
)
unless
environment
create_alerts
schedule_prometheus_update
ServiceResponse
.
success
end
...
...
@@ -51,6 +52,13 @@ module Prometheus
end
end
def
schedule_prometheus_update
project
.
all_clusters
.
with_application_prometheus
.
each
do
|
cluster
|
application
=
cluster
.
application_prometheus
::
Clusters
::
Applications
::
ScheduleUpdateService
.
new
(
application
,
project
).
execute
end
end
def
metrics_by_identifier
strong_memoize
(
:metrics_by_identifier
)
do
metric_identifiers
=
DEFAULT_ALERTS
.
map
{
|
alert
|
alert
[
:identifier
]
}
...
...
spec/factories/clusters/clusters.rb
View file @
c873783c
...
...
@@ -86,6 +86,10 @@ FactoryBot.define do
application_helm
factory:
%i(clusters_applications_helm installed)
end
trait
:with_installed_prometheus
do
application_prometheus
factory:
%i(clusters_applications_prometheus installed)
end
trait
:with_all_applications
do
application_helm
factory:
%i(clusters_applications_helm installed)
application_ingress
factory:
%i(clusters_applications_ingress installed)
...
...
spec/services/prometheus/create_default_alerts_service_spec.rb
View file @
c873783c
...
...
@@ -45,6 +45,27 @@ describe Prometheus::CreateDefaultAlertsService do
.
by
(
expected_alerts
.
size
)
end
it
'does not schedule an update to prometheus'
do
expect
(
::
Clusters
::
Applications
::
ScheduleUpdateService
).
not_to
receive
(
:new
)
execute
end
context
'cluster with prometheus exists'
do
let!
(
:cluster
)
do
cluster
=
create
(
:cluster
,
:with_installed_prometheus
)
cluster
.
projects
<<
project
cluster
end
it
'schedules an update to prometheus'
do
expect_next_instance_of
(
::
Clusters
::
Applications
::
ScheduleUpdateService
)
do
|
instance
|
expect
(
instance
).
to
receive
(
:execute
)
end
execute
end
end
context
'multiple environments'
do
let!
(
:production
)
{
create
(
:environment
,
project:
project
,
name:
'production'
)
}
...
...
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