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
990a82f9
Commit
990a82f9
authored
Jun 04, 2020
by
Allison Browne
Committed by
Peter Leitzen
Jun 04, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add new start_time display value
Add start_time to the alert presenter
parent
b8b06f53
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
34 additions
and
19 deletions
+34
-19
app/presenters/projects/prometheus/alert_presenter.rb
app/presenters/projects/prometheus/alert_presenter.rb
+4
-4
changelogs/unreleased/214109-date-time-format-should-be-consistent-in-the-incident.yml
...date-time-format-should-be-consistent-in-the-incident.yml
+5
-0
lib/gitlab/alerting/alert.rb
lib/gitlab/alerting/alert.rb
+4
-1
spec/presenters/projects/prometheus/alert_presenter_spec.rb
spec/presenters/projects/prometheus/alert_presenter_spec.rb
+21
-14
No files found.
app/presenters/projects/prometheus/alert_presenter.rb
View file @
990a82f9
...
...
@@ -45,8 +45,8 @@ module Projects
project_issues_url
(
project
,
label_name:
INCIDENT_LABEL_NAME
)
end
def
start
s_at
s
uper
&
.
rfc3339
def
start
_time
s
tarts_at
&
.
strftime
(
'%d %B %Y, %-l:%M%p (%Z)'
)
end
def
issue_summary_markdown
...
...
@@ -73,7 +73,7 @@ module Projects
def
metadata_list
metadata
=
[]
metadata
<<
list_item
(
'Start time'
,
start
s_at
)
if
starts_at
metadata
<<
list_item
(
'Start time'
,
start
_time
)
if
start_time
metadata
<<
list_item
(
'full_query'
,
backtick
(
full_query
))
if
full_query
metadata
<<
list_item
(
service
.
label
.
humanize
,
service
.
value
)
if
service
metadata
<<
list_item
(
monitoring_tool
.
label
.
humanize
,
monitoring_tool
.
value
)
if
monitoring_tool
...
...
@@ -149,7 +149,7 @@ module Projects
end
def
embed_time
starts_at
?
Time
.
rfc3339
(
starts_at
)
:
Time
.
current
starts_at
||
Time
.
current
end
def
alert_embed_window_params
(
time
)
...
...
changelogs/unreleased/214109-date-time-format-should-be-consistent-in-the-incident.yml
0 → 100644
View file @
990a82f9
---
title
:
Add timezone display to alert based issue start time
merge_request
:
32702
author
:
type
:
added
lib/gitlab/alerting/alert.rb
View file @
990a82f9
...
...
@@ -173,7 +173,10 @@ module Gitlab
value
=
payload
&
.
dig
(
field
)
return
unless
value
Time
.
rfc3339
(
value
)
# value is a rfc3339 timestamp
# Timestamps from Prometheus and Alertmanager are UTC RFC3339 timestamps like: '2018-03-12T09:06:00Z' (Z represents 0 offset or UTC)
# .utc sets the datetime zone to `UTC`
Time
.
rfc3339
(
value
).
utc
rescue
ArgumentError
end
...
...
spec/presenters/projects/prometheus/alert_presenter_spec.rb
View file @
990a82f9
...
...
@@ -24,18 +24,25 @@ describe Projects::Prometheus::AlertPresenter do
it
{
is_expected
.
to
eq
(
project
.
full_path
)
}
end
describe
'#starts_at'
do
subject
{
presenter
.
starts_at
}
describe
'#start_time'
do
subject
{
presenter
.
start_time
}
let
(
:starts_at
)
{
'2020-10-31T14:02:04Z'
}
before
do
payload
[
'startsAt'
]
=
starts_at
end
context
'with valid datetime'
do
let
(
:datetime
)
{
Time
.
now
}
let
(
:starts_at
)
{
datetime
.
rfc3339
}
context
'with valid utc datetime'
do
it
{
is_expected
.
to
eq
(
'31 October 2020, 2:02PM (UTC)'
)
}
it
{
is_expected
.
to
eq
(
datetime
.
rfc3339
)
}
context
'with admin time zone not UTC'
do
before
do
allow
(
Time
).
to
receive
(
:zone
).
and_return
(
ActiveSupport
::
TimeZone
.
new
(
'Perth'
))
end
it
{
is_expected
.
to
eq
(
'31 October 2020, 2:02PM (UTC)'
)
}
end
end
context
'with invalid datetime'
do
...
...
@@ -56,7 +63,7 @@ describe Projects::Prometheus::AlertPresenter do
<<~
MARKDOWN
.
chomp
#### Summary
**Start time:**
#{
presenter
.
start
s_at
}
**Start time:**
#{
presenter
.
start
_time
}
MARKDOWN
)
...
...
@@ -73,7 +80,7 @@ describe Projects::Prometheus::AlertPresenter do
<<~
MARKDOWN
.
chomp
#### Summary
**Start time:**
#{
presenter
.
start
s_at
}
**Start time:**
#{
presenter
.
start
_time
}
#### Alert Details
...
...
@@ -94,7 +101,7 @@ describe Projects::Prometheus::AlertPresenter do
<<~
MARKDOWN
.
chomp
#### Summary
**Start time:**
#{
presenter
.
start
s_at
}#{
markdown_line_break
}
**Start time:**
#{
presenter
.
start
_time
}#{
markdown_line_break
}
**full_query:** `query`
MARKDOWN
...
...
@@ -122,7 +129,7 @@ describe Projects::Prometheus::AlertPresenter do
<<~
MARKDOWN
.
chomp
#### Summary
**Start time:**
#{
presenter
.
start
s_at
}#{
markdown_line_break
}
**Start time:**
#{
presenter
.
start
_time
}#{
markdown_line_break
}
**Service:** service_name
#{
markdown_line_break
}
**Monitoring tool:** monitoring_tool_name
#{
markdown_line_break
}
**Hosts:** http://localhost:3000 http://localhost:3001
...
...
@@ -144,7 +151,7 @@ describe Projects::Prometheus::AlertPresenter do
<<~
MARKDOWN
.
chomp
#### Summary
**Start time:**
#{
presenter
.
start
s_at
}#{
markdown_line_break
}
**Start time:**
#{
presenter
.
start
_time
}#{
markdown_line_break
}
**Hosts:** http://localhost:3000
MARKDOWN
...
...
@@ -161,7 +168,7 @@ describe Projects::Prometheus::AlertPresenter do
<<~
MARKDOWN
.
chomp
#### Summary
**Start time:**
#{
presenter
.
start
s_at
}#{
markdown_line_break
}
**Start time:**
#{
presenter
.
start
_time
}#{
markdown_line_break
}
**full_query:** `avg(metric) > 1.0`
[](
#{
url
}
)
...
...
@@ -253,7 +260,7 @@ describe Projects::Prometheus::AlertPresenter do
<<~
MARKDOWN
.
chomp
#### Summary
**Start time:**
#{
presenter
.
start
s_at
}#{
markdown_line_break
}
**Start time:**
#{
presenter
.
start
_time
}#{
markdown_line_break
}
**full_query:** `avg(metric) > 1.0`
MARKDOWN
...
...
@@ -280,7 +287,7 @@ describe Projects::Prometheus::AlertPresenter do
<<~
MARKDOWN
.
chomp
#### Summary
**Start time:**
#{
presenter
.
start
s_at
}
**Start time:**
#{
presenter
.
start
_time
}
MARKDOWN
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