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
56766e21
Commit
56766e21
authored
Jul 09, 2020
by
Olena Horal-Koretska
Committed by
Illya Klymov
Jul 09, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Alert metrics chart
parent
8a8bf427
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
144 additions
and
2 deletions
+144
-2
app/assets/javascripts/alert_management/components/alert_details.vue
...javascripts/alert_management/components/alert_details.vue
+6
-0
app/assets/javascripts/alert_management/components/alert_metrics.vue
...javascripts/alert_management/components/alert_metrics.vue
+56
-0
app/assets/javascripts/alert_management/graphql/fragments/detail_item.fragment.graphql
...management/graphql/fragments/detail_item.fragment.graphql
+2
-0
app/assets/javascripts/monitoring/stores/actions.js
app/assets/javascripts/monitoring/stores/actions.js
+2
-2
changelogs/unreleased/217768-surface-link-to-chart.yml
changelogs/unreleased/217768-surface-link-to-chart.yml
+5
-0
locale/gitlab.pot
locale/gitlab.pot
+6
-0
spec/frontend/alert_management/components/alert_metrics_spec.js
...rontend/alert_management/components/alert_metrics_spec.js
+67
-0
No files found.
app/assets/javascripts/alert_management/components/alert_details.vue
View file @
56766e21
...
@@ -26,6 +26,7 @@ import Tracking from '~/tracking';
...
@@ -26,6 +26,7 @@ import Tracking from '~/tracking';
import
{
toggleContainerClasses
}
from
'
~/lib/utils/dom_utils
'
;
import
{
toggleContainerClasses
}
from
'
~/lib/utils/dom_utils
'
;
import
SystemNote
from
'
./system_notes/system_note.vue
'
;
import
SystemNote
from
'
./system_notes/system_note.vue
'
;
import
AlertSidebar
from
'
./alert_sidebar.vue
'
;
import
AlertSidebar
from
'
./alert_sidebar.vue
'
;
import
AlertMetrics
from
'
./alert_metrics.vue
'
;
const
containerEl
=
document
.
querySelector
(
'
.page-with-contextual-sidebar
'
);
const
containerEl
=
document
.
querySelector
(
'
.page-with-contextual-sidebar
'
);
...
@@ -36,6 +37,7 @@ export default {
...
@@ -36,6 +37,7 @@ export default {
),
),
fullAlertDetailsTitle
:
s__
(
'
AlertManagement|Alert details
'
),
fullAlertDetailsTitle
:
s__
(
'
AlertManagement|Alert details
'
),
overviewTitle
:
s__
(
'
AlertManagement|Overview
'
),
overviewTitle
:
s__
(
'
AlertManagement|Overview
'
),
metricsTitle
:
s__
(
'
AlertManagement|Metrics
'
),
reportedAt
:
s__
(
'
AlertManagement|Reported %{when}
'
),
reportedAt
:
s__
(
'
AlertManagement|Reported %{when}
'
),
reportedAtWithTool
:
s__
(
'
AlertManagement|Reported %{when} by %{tool}
'
),
reportedAtWithTool
:
s__
(
'
AlertManagement|Reported %{when} by %{tool}
'
),
},
},
...
@@ -53,6 +55,7 @@ export default {
...
@@ -53,6 +55,7 @@ export default {
TimeAgoTooltip
,
TimeAgoTooltip
,
AlertSidebar
,
AlertSidebar
,
SystemNote
,
SystemNote
,
AlertMetrics
,
},
},
inject
:
{
inject
:
{
projectPath
:
{
projectPath
:
{
...
@@ -329,6 +332,9 @@ export default {
...
@@ -329,6 +332,9 @@ export default {
</
template
>
</
template
>
</gl-table>
</gl-table>
</gl-tab>
</gl-tab>
<gl-tab
data-testId=
"metricsTab"
:title=
"$options.i18n.metricsTitle"
>
<alert-metrics
:dashboard-url=
"alert.metricsDashboardUrl"
/>
</gl-tab>
</gl-tabs>
</gl-tabs>
<alert-sidebar
<alert-sidebar
:alert=
"alert"
:alert=
"alert"
...
...
app/assets/javascripts/alert_management/components/alert_metrics.vue
0 → 100644
View file @
56766e21
<
script
>
import
Vue
from
'
vue
'
;
import
Vuex
from
'
vuex
'
;
import
*
as
Sentry
from
'
@sentry/browser
'
;
Vue
.
use
(
Vuex
);
export
default
{
props
:
{
dashboardUrl
:
{
type
:
String
,
required
:
false
,
default
:
''
,
},
},
data
()
{
return
{
metricEmbedComponent
:
null
,
namespace
:
'
alertMetrics
'
,
};
},
mounted
()
{
if
(
this
.
dashboardUrl
)
{
Promise
.
all
([
import
(
'
~/monitoring/components/embeds/metric_embed.vue
'
),
import
(
'
~/monitoring/stores
'
),
])
.
then
(([{
default
:
MetricEmbed
},
{
monitoringDashboard
}])
=>
{
this
.
$store
=
new
Vuex
.
Store
({
modules
:
{
[
this
.
namespace
]:
monitoringDashboard
,
},
});
this
.
metricEmbedComponent
=
MetricEmbed
;
})
.
catch
(
e
=>
Sentry
.
captureException
(
e
));
}
},
};
</
script
>
<
template
>
<div
class=
"gl-py-3"
>
<div
v-if=
"dashboardUrl"
ref=
"metricsChart"
>
<component
:is=
"metricEmbedComponent"
v-if=
"metricEmbedComponent"
:dashboard-url=
"dashboardUrl"
:namespace=
"namespace"
/>
</div>
<div
v-else
ref=
"emptyState"
>
{{
s__
(
"
AlertManagement|Metrics weren't available in the alerts payload.
"
)
}}
</div>
</div>
</
template
>
app/assets/javascripts/alert_management/graphql/fragments/detail_item.fragment.graphql
View file @
56766e21
...
@@ -5,6 +5,7 @@ fragment AlertDetailItem on AlertManagementAlert {
...
@@ -5,6 +5,7 @@ fragment AlertDetailItem on AlertManagementAlert {
...
AlertListItem
...
AlertListItem
createdAt
createdAt
monitoringTool
monitoringTool
metricsDashboardUrl
service
service
description
description
updatedAt
updatedAt
...
@@ -15,4 +16,5 @@ fragment AlertDetailItem on AlertManagementAlert {
...
@@ -15,4 +16,5 @@ fragment AlertDetailItem on AlertManagementAlert {
...
AlertNote
...
AlertNote
}
}
}
}
}
}
app/assets/javascripts/monitoring/stores/actions.js
View file @
56766e21
...
@@ -374,8 +374,8 @@ export const fetchDashboardValidationWarnings = ({ state, dispatch }) => {
...
@@ -374,8 +374,8 @@ export const fetchDashboardValidationWarnings = ({ state, dispatch }) => {
},
},
})
})
.
then
(
resp
=>
resp
.
data
?.
project
?.
environments
?.
nodes
?.[
0
]?.
metricsDashboard
)
.
then
(
resp
=>
resp
.
data
?.
project
?.
environments
?.
nodes
?.[
0
]?.
metricsDashboard
)
.
then
(({
schemaValidationWarnings
})
=>
{
.
then
(({
schemaValidationWarnings
}
=
{}
)
=>
{
const
hasWarnings
=
schemaValidationWarnings
&&
schemaValidationWarnings
.
length
!==
0
;
const
hasWarnings
=
schemaValidationWarnings
?
.
length
!==
0
;
/**
/**
* The payload of the dispatch is a boolean, because at the moment a standard
* The payload of the dispatch is a boolean, because at the moment a standard
* warning message is shown instead of the warnings the BE returns
* warning message is shown instead of the warnings the BE returns
...
...
changelogs/unreleased/217768-surface-link-to-chart.yml
0 → 100644
View file @
56766e21
---
title
:
Surface metrics charts on the alert detail page
merge_request
:
35044
author
:
type
:
added
locale/gitlab.pot
View file @
56766e21
...
@@ -1993,6 +1993,12 @@ msgstr ""
...
@@ -1993,6 +1993,12 @@ msgstr ""
msgid "AlertManagement|Medium"
msgid "AlertManagement|Medium"
msgstr ""
msgstr ""
msgid "AlertManagement|Metrics"
msgstr ""
msgid "AlertManagement|Metrics weren't available in the alerts payload."
msgstr ""
msgid "AlertManagement|More information"
msgid "AlertManagement|More information"
msgstr ""
msgstr ""
...
...
spec/frontend/alert_management/components/alert_metrics_spec.js
0 → 100644
View file @
56766e21
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
waitForPromises
from
'
helpers/wait_for_promises
'
;
import
AlertMetrics
from
'
~/alert_management/components/alert_metrics.vue
'
;
import
MockAdapter
from
'
axios-mock-adapter
'
;
import
axios
from
'
axios
'
;
jest
.
mock
(
'
~/monitoring/stores
'
,
()
=>
({
monitoringDashboard
:
{},
}));
const
mockEmbedName
=
'
MetricsEmbedStub
'
;
jest
.
mock
(
'
~/monitoring/components/embeds/metric_embed.vue
'
,
()
=>
({
name
:
mockEmbedName
,
render
(
h
)
{
return
h
(
'
div
'
);
},
}));
describe
(
'
Alert Metrics
'
,
()
=>
{
let
wrapper
;
const
mock
=
new
MockAdapter
(
axios
);
function
mountComponent
({
props
}
=
{})
{
wrapper
=
shallowMount
(
AlertMetrics
,
{
propsData
:
{
...
props
,
},
stubs
:
{
MetricEmbed
:
true
,
},
});
}
const
findChart
=
()
=>
wrapper
.
find
({
name
:
mockEmbedName
});
const
findEmptyState
=
()
=>
wrapper
.
find
({
ref
:
'
emptyState
'
});
afterEach
(()
=>
{
if
(
wrapper
)
{
wrapper
.
destroy
();
}
});
afterAll
(()
=>
{
mock
.
restore
();
});
describe
(
'
Empty state
'
,
()
=>
{
it
(
'
should display a message when metrics dashboard url is not provided
'
,
()
=>
{
mountComponent
();
expect
(
findChart
().
exists
()).
toBe
(
false
);
expect
(
findEmptyState
().
text
()).
toBe
(
"
Metrics weren't available in the alerts payload.
"
);
});
});
describe
(
'
Chart
'
,
()
=>
{
it
(
'
should be rendered when dashboard url is provided
'
,
async
()
=>
{
mountComponent
({
props
:
{
dashboardUrl
:
'
metrics.url
'
}
});
await
waitForPromises
();
await
wrapper
.
vm
.
$nextTick
();
expect
(
findEmptyState
().
exists
()).
toBe
(
false
);
expect
(
findChart
().
exists
()).
toBe
(
true
);
});
});
});
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