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
120fa9d9
Commit
120fa9d9
authored
Jan 19, 2021
by
Vitali Tatarintev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Pass the custom mapping fields to frontend
Pass alert fields and types as custom mapping attributes to frontend
parent
ee29b690
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
107 additions
and
14 deletions
+107
-14
ee/app/graphql/types/alert_management/payload_alert_field_name_enum.rb
...l/types/alert_management/payload_alert_field_name_enum.rb
+3
-12
ee/app/helpers/ee/operations_helper.rb
ee/app/helpers/ee/operations_helper.rb
+9
-1
ee/lib/gitlab/alert_management.rb
ee/lib/gitlab/alert_management.rb
+69
-0
ee/spec/helpers/ee/operations_helper_spec.rb
ee/spec/helpers/ee/operations_helper_spec.rb
+26
-1
No files found.
ee/app/graphql/types/alert_management/payload_alert_field_name_enum.rb
View file @
120fa9d9
...
...
@@ -6,18 +6,9 @@ module Types
graphql_name
'AlertManagementPayloadAlertFieldName'
description
'Values for alert field names used in the custom mapping'
# The complete list of fields can be found in:
# https://docs.gitlab.com/ee/operations/incident_management/alert_integrations.html#customize-the-alert-payload-outside-of-gitlab
value
'TITLE'
,
'The title of the incident.'
,
value:
'title'
value
'DESCRIPTION'
,
'A high-level summary of the problem.'
,
value:
'description'
value
'START_TIME'
,
'The time of the incident.'
,
value:
'start_time'
value
'END_TIME'
,
'The resolved time of the incident.'
,
value:
'end_time'
value
'SERVICE'
,
'The affected service.'
,
value:
'service'
value
'MONITORING_TOOL'
,
'The name of the associated monitoring tool.'
,
value:
'monitoring_tool'
value
'HOSTS'
,
'One or more hosts, as to where this incident occurred.'
,
value:
'hosts'
value
'SEVERITY'
,
'The severity of the alert.'
,
value:
'severity'
value
'FINGERPRINT'
,
'The unique identifier of the alert. This can be used to group occurrences of the same alert.'
,
value:
'fingerprint'
value
'GITLAB_ENVIRONMENT_NAME'
,
'The name of the associated GitLab environment.'
,
value:
'gitlab_environment_name'
::
Gitlab
::
AlertManagement
.
alert_fields
.
each
do
|
field
|
value
field
[
:name
].
upcase
,
field
[
:description
],
value:
field
[
:name
]
end
end
end
end
ee/app/helpers/ee/operations_helper.rb
View file @
120fa9d9
...
...
@@ -37,7 +37,7 @@ module EE
override
:alerts_settings_data
def
alerts_settings_data
(
disabled:
false
)
super
.
merge
(
alert_management_multiple_integrations_data
)
super
.
merge
(
alert_management_multiple_integrations_data
,
alert_fields
)
end
override
:operations_settings_data
...
...
@@ -66,5 +66,13 @@ module EE
'multi_integrations'
=>
@project
.
feature_available?
(
:multiple_alert_http_integrations
).
to_s
}
end
def
alert_fields
return
{}
unless
::
Gitlab
::
AlertManagement
.
custom_mapping_available?
(
@project
)
{
'alert_fields'
=>
::
Gitlab
::
AlertManagement
.
alert_fields
.
map
{
|
f
|
f
.
slice
(
:name
,
:label
,
:types
)
}.
to_json
}
end
end
end
ee/lib/gitlab/alert_management.rb
View file @
120fa9d9
...
...
@@ -6,5 +6,74 @@ module Gitlab
::
Feature
.
enabled?
(
:multiple_http_integrations_custom_mapping
,
project
)
&&
project
.
feature_available?
(
:multiple_alert_http_integrations
)
end
# Returns the complete list of alert fields for the custom mapping to be consumed by the frontend and the GraphQL API.
#
# @see https://docs.gitlab.com/ee/operations/incident_management/alert_integrations.html#customize-the-alert-payload-outside-of-gitlab
# @return [Array<Hash>]
def
self
.
alert_fields
[
{
name:
'title'
,
label:
'Title'
,
description:
'The title of the incident.'
,
types:
%w[string]
},
{
name:
'description'
,
label:
'Description'
,
description:
'A high-level summary of the problem.'
,
types:
%w[string]
},
{
name:
'start_time'
,
label:
'Start time'
,
description:
'The time of the incident.'
,
types:
%w[datetime]
},
{
name:
'end_time'
,
label:
'End time'
,
description:
'The resolved time of the incident.'
,
types:
%w[datetime]
},
{
name:
'service'
,
label:
'Service'
,
description:
'The affected service.'
,
types:
%w[string]
},
{
name:
'monitoring_tool'
,
label:
'Monitoring tool'
,
description:
'The name of the associated monitoring tool.'
,
types:
%w[string]
},
{
name:
'hosts'
,
label:
'Hosts'
,
description:
'One or more hosts, as to where this incident occurred.'
,
types:
%w[string array]
},
{
name:
'severity'
,
label:
'Severity'
,
description:
'The severity of the alert.'
,
types:
%w[string]
},
{
name:
'fingerprint'
,
label:
'Fingerprint'
,
description:
'The unique identifier of the alert. This can be used to group occurrences of the same alert.'
,
types:
%w[string array]
},
{
name:
'gitlab_environment_name'
,
label:
'Environment'
,
description:
'The name of the associated GitLab environment.'
,
types:
%w[string]
}
]
end
end
end
ee/spec/helpers/ee/operations_helper_spec.rb
View file @
120fa9d9
...
...
@@ -73,7 +73,7 @@ RSpec.describe OperationsHelper, :routing do
end
describe
'#alerts_settings_data'
do
subject
{
helper
.
alerts_settings_data
}
subject
(
:alerts_settings_data
)
{
helper
.
alerts_settings_data
}
describe
'Multiple Integrations Support'
do
before
do
...
...
@@ -84,12 +84,37 @@ RSpec.describe OperationsHelper, :routing do
let
(
:multi_integrations
)
{
true
}
it
{
is_expected
.
to
include
(
'multi_integrations'
=>
'true'
)
}
context
'with multiple_http_integrations_custom_mapping feature flag enabled'
do
before
do
stub_feature_flags
(
multiple_http_integrations_custom_mapping:
true
)
end
it
'has the correct list of fields'
,
:aggregate_failures
do
fields
=
Gitlab
::
Json
.
parse
(
alerts_settings_data
[
'alert_fields'
])
expect
(
fields
.
count
).
to
eq
(
10
)
expect
(
fields
.
first
.
keys
).
to
eq
(
%w[name label types]
)
expect
(
fields
.
map
{
|
f
|
f
[
'name'
]
}).
to
match_array
(
%w[title description start_time end_time service monitoring_tool hosts severity fingerprint gitlab_environment_name]
)
end
end
context
'with multiple_http_integrations_custom_mapping feature flag disabled'
do
before
do
stub_feature_flags
(
multiple_http_integrations_custom_mapping:
false
)
end
it
{
is_expected
.
not_to
have_key
(
'alert_fields'
)
}
end
end
context
'when not available'
do
let
(
:multi_integrations
)
{
false
}
it
{
is_expected
.
to
include
(
'multi_integrations'
=>
'false'
)
}
it
{
is_expected
.
not_to
have_key
(
'alert_fields'
)
}
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