Commit 33618519 authored by rpereira2's avatar rpereira2

Recognize other out-of-the-box metrics dashboards

Instead of recognizing only the common_metrics dashboard, allow any
dashboard defined under config/prometheus folder.
parent 4aca628f
...@@ -208,6 +208,14 @@ export const annotationsSymbolIcon = 'path://m5 229 5 8h-10z'; ...@@ -208,6 +208,14 @@ export const annotationsSymbolIcon = 'path://m5 229 5 8h-10z';
*/ */
export const DEFAULT_DASHBOARD_PATH = 'config/prometheus/common_metrics.yml'; export const DEFAULT_DASHBOARD_PATH = 'config/prometheus/common_metrics.yml';
/**
* GitLab provide metrics dashboards that are available to a user once
* the Prometheus managed app has been installed, without any extra setup
* required. These "out of the box" dashboards are defined under the
* `config/prometheus` path.
*/
export const OUT_OF_THE_BOX_DASHBOARDS_PATH_PREFIX = 'config/prometheus/';
export const OPERATORS = { export const OPERATORS = {
greaterThan: '>', greaterThan: '>',
equalTo: '==', equalTo: '==',
......
...@@ -6,7 +6,7 @@ import { mergeURLVariables, parseTemplatingVariables } from './variable_mapping' ...@@ -6,7 +6,7 @@ import { mergeURLVariables, parseTemplatingVariables } from './variable_mapping'
import { DATETIME_RANGE_TYPES } from '~/lib/utils/constants'; import { DATETIME_RANGE_TYPES } from '~/lib/utils/constants';
import { timeRangeToParams, getRangeType } from '~/lib/utils/datetime_range'; import { timeRangeToParams, getRangeType } from '~/lib/utils/datetime_range';
import { isSafeURL, mergeUrlParams } from '~/lib/utils/url_utility'; import { isSafeURL, mergeUrlParams } from '~/lib/utils/url_utility';
import { NOT_IN_DB_PREFIX, linkTypes, DEFAULT_DASHBOARD_PATH } from '../constants'; import { NOT_IN_DB_PREFIX, linkTypes, OUT_OF_THE_BOX_DASHBOARDS_PATH_PREFIX } from '../constants';
export const gqClient = createGqClient( export const gqClient = createGqClient(
{}, {},
...@@ -479,7 +479,7 @@ export const normalizeCustomDashboardPath = (dashboard, dashboardPrefix = '') => ...@@ -479,7 +479,7 @@ export const normalizeCustomDashboardPath = (dashboard, dashboardPrefix = '') =>
dashboardPath = ''; dashboardPath = '';
} else if ( } else if (
currDashboard.startsWith(dashboardPrefix) || currDashboard.startsWith(dashboardPrefix) ||
currDashboard.startsWith(DEFAULT_DASHBOARD_PATH) currDashboard.startsWith(OUT_OF_THE_BOX_DASHBOARDS_PATH_PREFIX)
) { ) {
dashboardPath = currDashboard; dashboardPath = currDashboard;
} }
......
...@@ -877,6 +877,8 @@ describe('normalizeCustomDashboardPath', () => { ...@@ -877,6 +877,8 @@ describe('normalizeCustomDashboardPath', () => {
${['.gitlab/dashboards/links.yml', '.gitlab/dashboards']} | ${'.gitlab/dashboards/links.yml'} ${['.gitlab/dashboards/links.yml', '.gitlab/dashboards']} | ${'.gitlab/dashboards/links.yml'}
${['.gitlab/dashboards/dir1/links.yml', '.gitlab/dashboards']} | ${'.gitlab/dashboards/dir1/links.yml'} ${['.gitlab/dashboards/dir1/links.yml', '.gitlab/dashboards']} | ${'.gitlab/dashboards/dir1/links.yml'}
${['.gitlab/dashboards/dir1/dir2/links.yml', '.gitlab/dashboards']} | ${'.gitlab/dashboards/dir1/dir2/links.yml'} ${['.gitlab/dashboards/dir1/dir2/links.yml', '.gitlab/dashboards']} | ${'.gitlab/dashboards/dir1/dir2/links.yml'}
${['config/prometheus/pod_metrics.yml', '.gitlab/dashboards']} | ${'config/prometheus/pod_metrics.yml'}
${['config/prometheus/pod_metrics.yml']} | ${'config/prometheus/pod_metrics.yml'}
`(`normalizeCustomDashboardPath returns $expected for $input`, ({ input, expected }) => { `(`normalizeCustomDashboardPath returns $expected for $input`, ({ input, expected }) => {
expect(normalizeCustomDashboardPath(...input)).toEqual(expected); expect(normalizeCustomDashboardPath(...input)).toEqual(expected);
}); });
......
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