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
56f7bd67
Commit
56f7bd67
authored
May 06, 2020
by
Vitali Tatarintev
Committed by
Peter Leitzen
May 06, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add AlertManagement::Alert#details method
Renders the alert payload as inline hash, and skips alert attributes
parent
d1618331
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
183 additions
and
2 deletions
+183
-2
app/graphql/types/alert_management/alert_type.rb
app/graphql/types/alert_management/alert_type.rb
+25
-0
app/models/alert_management/alert.rb
app/models/alert_management/alert.rb
+6
-0
changelogs/unreleased/expose-more-fields-in-alert-management-alert-graphql.yml
.../expose-more-fields-in-alert-management-alert-graphql.yml
+5
-0
doc/api/graphql/reference/gitlab_schema.graphql
doc/api/graphql/reference/gitlab_schema.graphql
+25
-0
doc/api/graphql/reference/gitlab_schema.json
doc/api/graphql/reference/gitlab_schema.json
+78
-0
doc/api/graphql/reference/index.md
doc/api/graphql/reference/index.md
+5
-0
spec/graphql/types/alert_management/alert_type_spec.rb
spec/graphql/types/alert_management/alert_type_spec.rb
+5
-0
spec/models/alert_management/alert_spec.rb
spec/models/alert_management/alert_spec.rb
+26
-0
spec/requests/api/graphql/project/alert_management/alerts_spec.rb
...uests/api/graphql/project/alert_management/alerts_spec.rb
+8
-2
No files found.
app/graphql/types/alert_management/alert_type.rb
View file @
56f7bd67
...
...
@@ -18,6 +18,11 @@ module Types
null:
true
,
description:
'Title of the alert'
field
:description
,
GraphQL
::
STRING_TYPE
,
null:
true
,
description:
'Description of the alert'
field
:severity
,
AlertManagement
::
SeverityEnum
,
null:
true
,
...
...
@@ -38,6 +43,11 @@ module Types
null:
true
,
description:
'Monitoring tool the alert came from'
field
:hosts
,
[
GraphQL
::
STRING_TYPE
],
null:
true
,
description:
'List of hosts the alert came from'
field
:started_at
,
Types
::
TimeType
,
null:
true
,
...
...
@@ -53,6 +63,21 @@ module Types
null:
true
,
description:
'Number of events of this alert'
,
method: :events
field
:details
,
GraphQL
::
Types
::
JSON
,
null:
true
,
description:
'Alert details'
field
:created_at
,
Types
::
TimeType
,
null:
true
,
description:
'Timestamp the alert was created'
field
:updated_at
,
Types
::
TimeType
,
null:
true
,
description:
'Timestamp the alert was last updated'
end
end
end
app/models/alert_management/alert.rb
View file @
56f7bd67
...
...
@@ -53,6 +53,12 @@ module AlertManagement
end
end
def
details
details_payload
=
payload
.
except
(
*
attributes
.
keys
)
Gitlab
::
Utils
::
InlineHash
.
merge_keys
(
details_payload
)
end
private
def
hosts_length
...
...
changelogs/unreleased/expose-more-fields-in-alert-management-alert-graphql.yml
0 → 100644
View file @
56f7bd67
---
title
:
Exposes description, hosts, details, and timestamps for Alert Management Alert GraphQL
merge_request
:
31091
author
:
type
:
changed
doc/api/graphql/reference/gitlab_schema.graphql
View file @
56f7bd67
...
...
@@ -142,6 +142,21 @@ type AdminSidekiqQueuesDeleteJobsPayload {
Describes an alert from the project's Alert Management
"""
type
AlertManagementAlert
{
"""
Timestamp
the
alert
was
created
"""
createdAt
:
Time
"""
Description
of
the
alert
"""
description
:
String
"""
Alert
details
"""
details
:
JSON
"""
Timestamp
the
alert
ended
"""
...
...
@@ -152,6 +167,11 @@ type AlertManagementAlert {
"""
eventCount
:
Int
"""
List
of
hosts
the
alert
came
from
"""
hosts
:
[
String
!]
"""
Internal
ID
of
the
alert
"""
...
...
@@ -186,6 +206,11 @@ type AlertManagementAlert {
Title
of
the
alert
"""
title
:
String
"""
Timestamp
the
alert
was
last
updated
"""
updatedAt
:
Time
}
"""
...
...
doc/api/graphql/reference/gitlab_schema.json
View file @
56f7bd67
...
...
@@ -394,6 +394,48 @@
"name"
:
"AlertManagementAlert"
,
"description"
:
"Describes an alert from the project's Alert Management"
,
"fields"
:
[
{
"name"
:
"createdAt"
,
"description"
:
"Timestamp the alert was created"
,
"args"
:
[
],
"type"
:
{
"kind"
:
"SCALAR"
,
"name"
:
"Time"
,
"ofType"
:
null
},
"isDeprecated"
:
false
,
"deprecationReason"
:
null
},
{
"name"
:
"description"
,
"description"
:
"Description of the alert"
,
"args"
:
[
],
"type"
:
{
"kind"
:
"SCALAR"
,
"name"
:
"String"
,
"ofType"
:
null
},
"isDeprecated"
:
false
,
"deprecationReason"
:
null
},
{
"name"
:
"details"
,
"description"
:
"Alert details"
,
"args"
:
[
],
"type"
:
{
"kind"
:
"SCALAR"
,
"name"
:
"JSON"
,
"ofType"
:
null
},
"isDeprecated"
:
false
,
"deprecationReason"
:
null
},
{
"name"
:
"endedAt"
,
"description"
:
"Timestamp the alert ended"
,
...
...
@@ -422,6 +464,28 @@
"isDeprecated"
:
false
,
"deprecationReason"
:
null
},
{
"name"
:
"hosts"
,
"description"
:
"List of hosts the alert came from"
,
"args"
:
[
],
"type"
:
{
"kind"
:
"LIST"
,
"name"
:
null
,
"ofType"
:
{
"kind"
:
"NON_NULL"
,
"name"
:
null
,
"ofType"
:
{
"kind"
:
"SCALAR"
,
"name"
:
"String"
,
"ofType"
:
null
}
}
},
"isDeprecated"
:
false
,
"deprecationReason"
:
null
},
{
"name"
:
"iid"
,
"description"
:
"Internal ID of the alert"
,
...
...
@@ -523,6 +587,20 @@
},
"isDeprecated"
:
false
,
"deprecationReason"
:
null
},
{
"name"
:
"updatedAt"
,
"description"
:
"Timestamp the alert was last updated"
,
"args"
:
[
],
"type"
:
{
"kind"
:
"SCALAR"
,
"name"
:
"Time"
,
"ofType"
:
null
},
"isDeprecated"
:
false
,
"deprecationReason"
:
null
}
],
"inputFields"
:
null
,
...
...
doc/api/graphql/reference/index.md
View file @
56f7bd67
...
...
@@ -52,8 +52,12 @@ Describes an alert from the project's Alert Management
| Name | Type | Description |
| --- | ---- | ---------- |
|
`createdAt`
| Time | Timestamp the alert was created |
|
`description`
| String | Description of the alert |
|
`details`
| JSON | Alert details |
|
`endedAt`
| Time | Timestamp the alert ended |
|
`eventCount`
| Int | Number of events of this alert |
|
`hosts`
| String! => Array | List of hosts the alert came from |
|
`iid`
| ID! | Internal ID of the alert |
|
`monitoringTool`
| String | Monitoring tool the alert came from |
|
`service`
| String | Service the alert came from |
...
...
@@ -61,6 +65,7 @@ Describes an alert from the project's Alert Management
|
`startedAt`
| Time | Timestamp the alert was raised |
|
`status`
| AlertManagementStatus | Status of the alert |
|
`title`
| String | Title of the alert |
|
`updatedAt`
| Time | Timestamp the alert was last updated |
## AwardEmoji
...
...
spec/graphql/types/alert_management/alert_type_spec.rb
View file @
56f7bd67
...
...
@@ -11,13 +11,18 @@ describe GitlabSchema.types['AlertManagementAlert'] do
expected_fields
=
%i[
iid
title
description
severity
status
service
monitoring_tool
hosts
started_at
ended_at
event_count
details
created_at
updated_at
]
expect
(
described_class
).
to
have_graphql_fields
(
*
expected_fields
)
...
...
spec/models/alert_management/alert_spec.rb
View file @
56f7bd67
...
...
@@ -126,4 +126,30 @@ describe AlertManagement::Alert do
it
{
is_expected
.
to
match_array
(
alert_1
)
}
end
describe
'.details'
do
let
(
:payload
)
do
{
'title'
=>
'Details title'
,
'custom'
=>
{
'alert'
=>
{
'fields'
=>
%w[one two]
}
},
'yet'
=>
{
'another'
=>
'field'
}
}
end
let
(
:alert
)
{
build
(
:alert_management_alert
,
title:
'Details title'
,
payload:
payload
)
}
subject
{
alert
.
details
}
it
'renders the payload as inline hash'
do
is_expected
.
to
eq
(
'custom.alert.fields'
=>
%w[one two]
,
'yet.another'
=>
'field'
)
end
end
end
spec/requests/api/graphql/project/alert_management/alerts_spec.rb
View file @
56f7bd67
...
...
@@ -4,10 +4,11 @@ require 'spec_helper'
describe
'getting Alert Management Alerts'
do
include
GraphqlHelpers
let_it_be
(
:payload
)
{
{
'custom'
=>
{
'alert'
=>
'payload'
}
}
}
let_it_be
(
:project
)
{
create
(
:project
,
:repository
)
}
let_it_be
(
:current_user
)
{
create
(
:user
)
}
let_it_be
(
:alert_1
)
{
create
(
:alert_management_alert
,
:all_fields
,
project:
project
)
}
let_it_be
(
:alert_2
)
{
create
(
:alert_management_alert
,
:all_fields
,
project:
project
)
}
let_it_be
(
:alert_2
)
{
create
(
:alert_management_alert
,
:all_fields
,
project:
project
,
payload:
payload
)
}
let
(
:fields
)
do
<<~
QUERY
...
...
@@ -55,13 +56,18 @@ describe 'getting Alert Management Alerts' do
expect
(
first_alert
).
to
include
(
'iid'
=>
alert_2
.
iid
.
to_s
,
'title'
=>
alert_2
.
title
,
'description'
=>
alert_2
.
description
,
'severity'
=>
alert_2
.
severity
.
upcase
,
'status'
=>
alert_2
.
status
.
upcase
,
'monitoringTool'
=>
alert_2
.
monitoring_tool
,
'service'
=>
alert_2
.
service
,
'hosts'
=>
alert_2
.
hosts
,
'eventCount'
=>
alert_2
.
events
,
'startedAt'
=>
alert_2
.
started_at
.
strftime
(
'%Y-%m-%dT%H:%M:%SZ'
),
'endedAt'
=>
alert_2
.
ended_at
.
strftime
(
'%Y-%m-%dT%H:%M:%SZ'
)
'endedAt'
=>
alert_2
.
ended_at
.
strftime
(
'%Y-%m-%dT%H:%M:%SZ'
),
'details'
=>
{
'custom.alert'
=>
'payload'
},
'createdAt'
=>
alert_2
.
created_at
.
strftime
(
'%Y-%m-%dT%H:%M:%SZ'
),
'updatedAt'
=>
alert_2
.
updated_at
.
strftime
(
'%Y-%m-%dT%H:%M:%SZ'
)
)
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