Commit ef5d7bb9 authored by Adriel Santiago's avatar Adriel Santiago Committed by Tim Zallmann

Add threshold lines in metrics graph

parent 0c1d6be1
...@@ -6,6 +6,7 @@ export default { ...@@ -6,6 +6,7 @@ export default {
components: { components: {
GlAreaChart, GlAreaChart,
}, },
inheritAttrs: false,
props: { props: {
graphData: { graphData: {
type: Object, type: Object,
...@@ -25,6 +26,11 @@ export default { ...@@ -25,6 +26,11 @@ export default {
); );
}, },
}, },
alertData: {
type: Object,
required: false,
default: () => ({}),
},
}, },
computed: { computed: {
chartData() { chartData() {
...@@ -74,9 +80,6 @@ export default { ...@@ -74,9 +80,6 @@ export default {
const [date, value] = params; const [date, value] = params;
return [dateFormat(date, 'dd mmm yyyy, h:MMtt'), value.toFixed(3)]; return [dateFormat(date, 'dd mmm yyyy, h:MMtt'), value.toFixed(3)];
}, },
onCreated(chart) {
this.$emit('created', chart);
},
}, },
}; };
</script> </script>
...@@ -88,10 +91,11 @@ export default { ...@@ -88,10 +91,11 @@ export default {
<div class="prometheus-graph-widgets"><slot></slot></div> <div class="prometheus-graph-widgets"><slot></slot></div>
</div> </div>
<gl-area-chart <gl-area-chart
v-bind="$attrs"
:data="chartData" :data="chartData"
:option="chartOptions" :option="chartOptions"
:format-tooltip-text="formatTooltipText" :format-tooltip-text="formatTooltipText"
@created="onCreated" :thresholds="alertData"
/> />
</div> </div>
</template> </template>
...@@ -144,6 +144,9 @@ export default { ...@@ -144,6 +144,9 @@ export default {
} }
}, },
methods: { methods: {
getGraphAlerts(graphId) {
return this.alertData ? this.alertData[graphId] || {} : {};
},
getGraphsData() { getGraphsData() {
this.state = 'loading'; this.state = 'loading';
Promise.all([ Promise.all([
...@@ -223,6 +226,8 @@ export default { ...@@ -223,6 +226,8 @@ export default {
:tags-path="tagsPath" :tags-path="tagsPath"
:show-legend="showLegend" :show-legend="showLegend"
:small-graph="forceSmallGraph" :small-graph="forceSmallGraph"
:alert-data="getGraphAlerts(graphData.id)"
group-id="monitor-area-chart"
> >
<!-- EE content --> <!-- EE content -->
{{ null }} {{ null }}
......
...@@ -641,10 +641,10 @@ ...@@ -641,10 +641,10 @@
resolved "https://registry.yarnpkg.com/@gitlab/svgs/-/svgs-1.47.0.tgz#c03dda41aefd3889cbfed95a391836106ae2ac4d" resolved "https://registry.yarnpkg.com/@gitlab/svgs/-/svgs-1.47.0.tgz#c03dda41aefd3889cbfed95a391836106ae2ac4d"
integrity sha512-0Bx/HxqR8xpqqaLnZiFAHIh1jTAFQPFToVZ6Wi3QyhsAwmXRAbgw1SlkRMZ7w3e6l+G71Wnw+GnI4rx1gK8JLQ== integrity sha512-0Bx/HxqR8xpqqaLnZiFAHIh1jTAFQPFToVZ6Wi3QyhsAwmXRAbgw1SlkRMZ7w3e6l+G71Wnw+GnI4rx1gK8JLQ==
"@gitlab/ui@^1.18.0": "@gitlab/ui@^1.20.0":
version "1.18.0" version "1.20.0"
resolved "https://registry.yarnpkg.com/@gitlab/ui/-/ui-1.18.0.tgz#5cc591b2c7958e59fa7b1b443d4235e0e8f956c9" resolved "https://registry.yarnpkg.com/@gitlab/ui/-/ui-1.20.0.tgz#50bd4b092646a2c6337f0f462779af8e702dda05"
integrity sha512-JqmiRSGYmK0DbGBQJBpjeRrcgjK25rCqG6QW6/GPTVLtRjbPPZYGvVg5PyA6nJUGAnwFoeApUZVML6X3OpnV1Q== integrity sha512-EJgrqon/tYCUPoOgnNNAXbrDXOEAajJwKHr4aR2R6vkJI3kVZiq66RNIe5ftGIUoNqYCDnRIkpLyo7MqzJPgcw==
dependencies: dependencies:
babel-standalone "^6.26.0" babel-standalone "^6.26.0"
bootstrap-vue "^2.0.0-rc.11" bootstrap-vue "^2.0.0-rc.11"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment