Commit 5cccbde4 authored by kushalpandya's avatar kushalpandya

Populate Missing env var panel

parent c3c644c7
...@@ -12,7 +12,10 @@ export default class PrometheusMetrics { ...@@ -12,7 +12,10 @@ export default class PrometheusMetrics {
this.$monitoredMetricsEmpty = this.$monitoredMetricsPanel.find('.js-empty-metrics'); this.$monitoredMetricsEmpty = this.$monitoredMetricsPanel.find('.js-empty-metrics');
this.$monitoredMetricsList = this.$monitoredMetricsPanel.find('.js-metrics-list'); this.$monitoredMetricsList = this.$monitoredMetricsPanel.find('.js-metrics-list');
this.$panelToggle = this.$wrapper.find('.js-panel-toggle'); this.$missingEnvVarPanel = this.$wrapper.find('.js-panel-missing-env-vars');
this.$panelToggle = this.$missingEnvVarPanel.find('.js-panel-toggle');
this.$missingEnvVarMetricCount = this.$missingEnvVarPanel.find('.js-env-var-count');
this.$missingEnvVarMetricsList = this.$missingEnvVarPanel.find('.js-missing-var-metrics-list');
this.activeMetricsEndpoint = this.$monitoredMetricsPanel.data('active-metrics'); this.activeMetricsEndpoint = this.$monitoredMetricsPanel.data('active-metrics');
} }
...@@ -35,14 +38,25 @@ export default class PrometheusMetrics { ...@@ -35,14 +38,25 @@ export default class PrometheusMetrics {
populateActiveMetrics(metrics) { populateActiveMetrics(metrics) {
let totalMonitoredMetrics = 0; let totalMonitoredMetrics = 0;
let totalMissingEnvVarMetrics = 0;
metrics.forEach((metric) => { metrics.forEach((metric) => {
this.$monitoredMetricsList.append(`<li>${metric.group}<span class="badge-count">${metric.active_metrics}</span></li>`); this.$monitoredMetricsList.append(`<li>${metric.group}<span class="badge-count">${metric.active_metrics}</span></li>`);
totalMonitoredMetrics += metric.active_metrics; totalMonitoredMetrics += metric.active_metrics;
if (metric.metrics_missing_requirements > 0) {
this.$missingEnvVarMetricsList.append(`<li>${metric.group}</li>`);
totalMissingEnvVarMetrics += 1;
}
}); });
this.$monitoredMetricsCount.text(totalMonitoredMetrics); this.$monitoredMetricsCount.text(totalMonitoredMetrics);
this.$monitoredMetricsLoading.addClass('hidden'); this.$monitoredMetricsLoading.addClass('hidden');
this.$monitoredMetricsList.removeClass('hidden'); this.$monitoredMetricsList.removeClass('hidden');
if (totalMissingEnvVarMetrics > 0) {
this.$missingEnvVarPanel.removeClass('hidden');
this.$missingEnvVarMetricCount.text(totalMissingEnvVarMetrics);
}
} }
loadActiveMetrics() { loadActiveMetrics() {
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
%p %p
Metrics are automatically configured and monitored Metrics are automatically configured and monitored
based on a library of metrics from popular exporters. based on a library of metrics from popular exporters.
More information = link_to 'More information', '#'
.col-lg-9 .col-lg-9
.panel.panel-default.js-panel-monitored-metrics{ data: { "active-metrics" => "#{namespace_project_prometheus_active_metrics_path(@project.namespace, @project)}.json" } } .panel.panel-default.js-panel-monitored-metrics{ data: { "active-metrics" => "#{namespace_project_prometheus_active_metrics_path(@project.namespace, @project)}.json" } }
...@@ -27,12 +27,19 @@ ...@@ -27,12 +27,19 @@
View environments View environments
%ul.metrics-list.hidden.js-metrics-list %ul.metrics-list.hidden.js-metrics-list
.panel.panel-default.js-panel-missing-env-vars .panel.panel-default.hidden.js-panel-missing-env-vars
.panel-heading .panel-heading
%h3.panel-title %h3.panel-title
= icon('caret-right lg', class: 'panel-toggle js-panel-toggle', 'aria-label' => 'Toggle panel') = icon('caret-right lg', class: 'panel-toggle js-panel-toggle', 'aria-label' => 'Toggle panel')
Missing environment variable(s) Missing environment variable(s)
%span.badge-count.js-env-var-count 0 %span.badge-count.js-env-var-count 0
.panel-body.hidden .panel-body.hidden
.empty-metrics .flash-container
%p Nothing to show here at the moment .flash-notice
\ No newline at end of file .flash-text
To set up automatic monitoring, add the environment variable
%code
$CI_ENVIRONMENT_SLUG
to exporter's queries.
= link_to 'More information', '#'
%ul.metrics-list.js-missing-var-metrics-list
\ No newline at end of file
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