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
6c98301e
Commit
6c98301e
authored
6 years ago
by
Peter Leitzen
Committed by
Sean McGivern
6 years ago
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Resolve "Alert notification not working for managed Prometheus installations"
parent
072e9f54
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
34 additions
and
13 deletions
+34
-13
ee/app/services/clusters/applications/prometheus_config_service.rb
...rvices/clusters/applications/prometheus_config_service.rb
+15
-8
ee/app/services/clusters/applications/prometheus_update_service.rb
...rvices/clusters/applications/prometheus_update_service.rb
+1
-1
ee/changelogs/unreleased/9558-alert-notification-not-working-for-managed-prometheus-installations.yml
...tion-not-working-for-managed-prometheus-installations.yml
+5
-0
ee/spec/services/clusters/applications/prometheus_config_service_spec.rb
...s/clusters/applications/prometheus_config_service_spec.rb
+12
-3
ee/spec/services/clusters/applications/prometheus_update_service_spec.rb
...s/clusters/applications/prometheus_update_service_spec.rb
+1
-1
No files found.
ee/app/services/clusters/applications/prometheus_config_service.rb
View file @
6c98301e
...
...
@@ -3,9 +3,10 @@
module
Clusters
module
Applications
class
PrometheusConfigService
def
initialize
(
project
,
cluster
)
def
initialize
(
project
,
cluster
,
app
)
@project
=
project
@cluster
=
cluster
@app
=
app
end
def
execute
(
config
)
...
...
@@ -18,7 +19,7 @@ module Clusters
private
attr_reader
:project
,
:cluster
attr_reader
:project
,
:cluster
,
:app
def
reset_alert_manager
(
config
)
config
=
set_alert_manager_enabled
(
config
,
false
)
...
...
@@ -80,13 +81,22 @@ module Clusters
'webhook_configs'
=>
[
{
'url'
=>
notify_url
,
'send_resolved'
=>
true
'send_resolved'
=>
true
,
'http_config'
=>
{
'bearer_token'
=>
alert_manager_token
}
}
]
}
]
end
def
alert_manager_token
app
.
generate_alert_manager_token!
app
.
alert_manager_token
end
def
alert_manager_route_params
{
'receiver'
=>
'gitlab'
,
...
...
@@ -97,11 +107,8 @@ module Clusters
end
def
notify_url
::
Gitlab
::
Routing
.
url_helpers
.
notify_namespace_project_prometheus_alerts_url
(
namespace_id:
project
.
namespace
.
path
,
project_id:
project
.
path
,
format: :json
)
::
Gitlab
::
Routing
.
url_helpers
.
notify_project_prometheus_alerts_url
(
project
,
format: :json
)
end
def
has_alerts?
...
...
This diff is collapsed.
Click to expand it.
ee/app/services/clusters/applications/prometheus_update_service.rb
View file @
6c98301e
...
...
@@ -34,7 +34,7 @@ module Clusters
def
update_config
(
config
)
PrometheusConfigService
.
new
(
project
,
cluster
)
.
new
(
project
,
cluster
,
app
)
.
execute
(
config
)
end
end
...
...
This diff is collapsed.
Click to expand it.
ee/changelogs/unreleased/9558-alert-notification-not-working-for-managed-prometheus-installations.yml
0 → 100644
View file @
6c98301e
---
title
:
Fix alert notifications for managed Prometheus
merge_request
:
9402
author
:
type
:
fixed
This diff is collapsed.
Click to expand it.
ee/spec/services/clusters/applications/prometheus_config_service_spec.rb
View file @
6c98301e
...
...
@@ -3,11 +3,17 @@
require
'spec_helper'
describe
Clusters
::
Applications
::
PrometheusConfigService
do
include
Gitlab
::
Routing
.
url_helpers
set
(
:project
)
{
create
(
:project
)
}
set
(
:production
)
{
create
(
:environment
,
project:
project
)
}
set
(
:cluster
)
{
create
(
:cluster
,
:provided_by_user
,
projects:
[
project
])
}
subject
{
described_class
.
new
(
project
,
cluster
).
execute
(
input
)
}
let
(
:application
)
do
create
(
:clusters_applications_prometheus
,
:installed
,
cluster:
cluster
)
end
subject
{
described_class
.
new
(
project
,
cluster
,
application
).
execute
(
input
)
}
describe
'#execute'
do
let
(
:input
)
do
...
...
@@ -37,7 +43,7 @@ describe Clusters::Applications::PrometheusConfigService do
let
(
:webhook_config
)
{
receiver
.
dig
(
'webhook_configs'
,
0
)
}
let
(
:notify_url
)
do
"http://localhost/
#{
project
.
namespace
.
name
}
/
#{
project
.
name
}
/prometheus/alerts/notify.json"
notify_project_prometheus_alerts_url
(
project
,
format: :json
)
end
it
'sets receiver'
do
...
...
@@ -47,7 +53,10 @@ describe Clusters::Applications::PrometheusConfigService do
it
'sets webhook_config'
do
expect
(
webhook_config
).
to
eq
(
'url'
=>
notify_url
,
'send_resolved'
=>
true
'send_resolved'
=>
true
,
'http_config'
=>
{
'bearer_token'
=>
application
.
alert_manager_token
}
)
end
end
...
...
This diff is collapsed.
Click to expand it.
ee/spec/services/clusters/applications/prometheus_update_service_spec.rb
View file @
6c98301e
...
...
@@ -42,7 +42,7 @@ describe Clusters::Applications::PrometheusUpdateService do
expect
(
Clusters
::
Applications
::
PrometheusConfigService
)
.
to
receive
(
:new
)
.
with
(
project
,
cluster
)
.
with
(
project
,
cluster
,
application
)
.
and_return
(
prometheus_config_service
)
expect
(
prometheus_config_service
)
...
...
This diff is collapsed.
Click to expand it.
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