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
e7354c57
Commit
e7354c57
authored
Dec 03, 2020
by
can eldem
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add domain column to alerts table
Add enum type to model
parent
157d1a60
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
53 additions
and
1 deletion
+53
-1
app/models/alert_management/alert.rb
app/models/alert_management/alert.rb
+5
-0
changelogs/unreleased/add-domain-type-to-alerts.yml
changelogs/unreleased/add-domain-type-to-alerts.yml
+5
-0
db/migrate/20201203123524_add_domain_enum_to_alerts.rb
db/migrate/20201203123524_add_domain_enum_to_alerts.rb
+19
-0
db/migrate/20201203171631_add_index_to_domain.rb
db/migrate/20201203171631_add_index_to_domain.rb
+17
-0
db/schema_migrations/20201203123524
db/schema_migrations/20201203123524
+1
-0
db/schema_migrations/20201203171631
db/schema_migrations/20201203171631
+1
-0
db/structure.sql
db/structure.sql
+3
-0
spec/services/projects/alerting/notify_service_spec.rb
spec/services/projects/alerting/notify_service_spec.rb
+2
-1
No files found.
app/models/alert_management/alert.rb
View file @
e7354c57
...
@@ -69,6 +69,11 @@ module AlertManagement
...
@@ -69,6 +69,11 @@ module AlertManagement
unknown:
5
unknown:
5
}
}
enum
domain:
{
operations:
0
,
threat_monitoring:
1
}
state_machine
:status
,
initial: :triggered
do
state_machine
:status
,
initial: :triggered
do
state
:triggered
,
value:
STATUSES
[
:triggered
]
state
:triggered
,
value:
STATUSES
[
:triggered
]
...
...
changelogs/unreleased/add-domain-type-to-alerts.yml
0 → 100644
View file @
e7354c57
---
title
:
Add domain column to alerts table
merge_request
:
49120
author
:
type
:
added
db/migrate/20201203123524_add_domain_enum_to_alerts.rb
0 → 100644
View file @
e7354c57
# frozen_string_literal: true
class
AddDomainEnumToAlerts
<
ActiveRecord
::
Migration
[
6.0
]
include
Gitlab
::
Database
::
MigrationHelpers
DOWNTIME
=
false
def
up
with_lock_retries
do
add_column
:alert_management_alerts
,
:domain
,
:integer
,
limit:
2
,
default:
0
end
end
def
down
with_lock_retries
do
remove_column
:alert_management_alerts
,
:domain
,
:integer
,
limit:
2
end
end
end
db/migrate/20201203171631_add_index_to_domain.rb
0 → 100644
View file @
e7354c57
# frozen_string_literal: true
class
AddIndexToDomain
<
ActiveRecord
::
Migration
[
6.0
]
include
Gitlab
::
Database
::
MigrationHelpers
DOWNTIME
=
false
INDEX_NAME
=
'index_alert_management_alerts_on_domain'
disable_ddl_transaction!
def
up
add_concurrent_index
:alert_management_alerts
,
:domain
,
name:
INDEX_NAME
end
def
down
remove_concurrent_index
:alert_management_alerts
,
:domain
,
name:
INDEX_NAME
end
end
db/schema_migrations/20201203123524
0 → 100644
View file @
e7354c57
4bb54293c339e20082a739f7724b02141d8fb3b0b140e21ac2acab6cbd2d2f01
\ No newline at end of file
db/schema_migrations/20201203171631
0 → 100644
View file @
e7354c57
3b6d3fb9c279f5e8c76921e654b188a5a5ba0fddd7ff753a03706b41f43240ed
\ No newline at end of file
db/structure.sql
View file @
e7354c57
...
@@ -8811,6 +8811,7 @@ CREATE TABLE alert_management_alerts (
...
@@ -8811,6 +8811,7 @@ CREATE TABLE alert_management_alerts (
payload
jsonb
DEFAULT
'{}'
::
jsonb
NOT
NULL
,
payload
jsonb
DEFAULT
'{}'
::
jsonb
NOT
NULL
,
prometheus_alert_id
integer
,
prometheus_alert_id
integer
,
environment_id
integer
,
environment_id
integer
,
domain
smallint
DEFAULT
0
,
CONSTRAINT
check_2df3e2fdc1
CHECK
((
char_length
(
monitoring_tool
)
<=
100
)),
CONSTRAINT
check_2df3e2fdc1
CHECK
((
char_length
(
monitoring_tool
)
<=
100
)),
CONSTRAINT
check_5e9e57cadb
CHECK
((
char_length
(
description
)
<=
1000
)),
CONSTRAINT
check_5e9e57cadb
CHECK
((
char_length
(
description
)
<=
1000
)),
CONSTRAINT
check_bac14dddde
CHECK
((
char_length
(
service
)
<=
100
)),
CONSTRAINT
check_bac14dddde
CHECK
((
char_length
(
service
)
<=
100
)),
...
@@ -20405,6 +20406,8 @@ CREATE INDEX index_alert_assignees_on_alert_id ON alert_management_alert_assigne
...
@@ -20405,6 +20406,8 @@ CREATE INDEX index_alert_assignees_on_alert_id ON alert_management_alert_assigne
CREATE
UNIQUE
INDEX
index_alert_assignees_on_user_id_and_alert_id
ON
alert_management_alert_assignees
USING
btree
(
user_id
,
alert_id
);
CREATE
UNIQUE
INDEX
index_alert_assignees_on_user_id_and_alert_id
ON
alert_management_alert_assignees
USING
btree
(
user_id
,
alert_id
);
CREATE
INDEX
index_alert_management_alerts_on_domain
ON
alert_management_alerts
USING
btree
(
domain
);
CREATE
INDEX
index_alert_management_alerts_on_environment_id
ON
alert_management_alerts
USING
btree
(
environment_id
)
WHERE
(
environment_id
IS
NOT
NULL
);
CREATE
INDEX
index_alert_management_alerts_on_environment_id
ON
alert_management_alerts
USING
btree
(
environment_id
)
WHERE
(
environment_id
IS
NOT
NULL
);
CREATE
INDEX
index_alert_management_alerts_on_issue_id
ON
alert_management_alerts
USING
btree
(
issue_id
);
CREATE
INDEX
index_alert_management_alerts_on_issue_id
ON
alert_management_alerts
USING
btree
(
issue_id
);
...
...
spec/services/projects/alerting/notify_service_spec.rb
View file @
e7354c57
...
@@ -54,7 +54,6 @@ RSpec.describe Projects::Alerting::NotifyService do
...
@@ -54,7 +54,6 @@ RSpec.describe Projects::Alerting::NotifyService do
shared_examples
'assigns the alert properties'
do
shared_examples
'assigns the alert properties'
do
it
'ensure that created alert has all data properly assigned'
do
it
'ensure that created alert has all data properly assigned'
do
subject
subject
expect
(
last_alert_attributes
).
to
match
(
expect
(
last_alert_attributes
).
to
match
(
project_id:
project
.
id
,
project_id:
project
.
id
,
title:
payload_raw
.
fetch
(
:title
),
title:
payload_raw
.
fetch
(
:title
),
...
@@ -62,6 +61,7 @@ RSpec.describe Projects::Alerting::NotifyService do
...
@@ -62,6 +61,7 @@ RSpec.describe Projects::Alerting::NotifyService do
severity:
payload_raw
.
fetch
(
:severity
),
severity:
payload_raw
.
fetch
(
:severity
),
status:
AlertManagement
::
Alert
.
status_value
(
:triggered
),
status:
AlertManagement
::
Alert
.
status_value
(
:triggered
),
events:
1
,
events:
1
,
domain:
'operations'
,
hosts:
payload_raw
.
fetch
(
:hosts
),
hosts:
payload_raw
.
fetch
(
:hosts
),
payload:
payload_raw
.
with_indifferent_access
,
payload:
payload_raw
.
with_indifferent_access
,
issue_id:
nil
,
issue_id:
nil
,
...
@@ -187,6 +187,7 @@ RSpec.describe Projects::Alerting::NotifyService do
...
@@ -187,6 +187,7 @@ RSpec.describe Projects::Alerting::NotifyService do
status:
AlertManagement
::
Alert
.
status_value
(
:triggered
),
status:
AlertManagement
::
Alert
.
status_value
(
:triggered
),
events:
1
,
events:
1
,
hosts:
[],
hosts:
[],
domain:
'operations'
,
payload:
payload_raw
.
with_indifferent_access
,
payload:
payload_raw
.
with_indifferent_access
,
issue_id:
nil
,
issue_id:
nil
,
description:
nil
,
description:
nil
,
...
...
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