constants.js 2.35 KB
Newer Older
1 2
import { __ } from '~/locale';

3 4 5
export const PROMETHEUS_TIMEOUT = 120000; // TWO_MINUTES

/**
6
 * States and error states in Prometheus Queries (PromQL) for metrics
7
 */
8 9 10 11 12 13 14 15 16 17 18
export const metricStates = {
  /**
   * Metric data is available
   */
  OK: 'OK',

  /**
   * Metric data is being fetched
   */
  LOADING: 'LOADING',

19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
  /**
   * Connection timed out to prometheus server
   * the timeout is set to PROMETHEUS_TIMEOUT
   *
   */
  TIMEOUT: 'TIMEOUT',

  /**
   * The prometheus server replies with an empty data set
   */
  NO_DATA: 'NO_DATA',

  /**
   * The prometheus server cannot be reached
   */
  CONNECTION_FAILED: 'CONNECTION_FAILED',

  /**
37
   * The prometheus server was reached but it cannot process
38 39 40 41
   * the query. This can happen for several reasons:
   * - PromQL syntax is incorrect
   * - An operator is not supported
   */
42
  BAD_QUERY: 'BAD_QUERY',
43 44 45 46 47 48 49

  /**
   * No specific reason found for error
   */
  UNKNOWN_ERROR: 'UNKNOWN_ERROR',
};

50 51
export const sidebarAnimationDuration = 300; // milliseconds.

52 53 54 55 56 57
export const chartHeight = 300;

export const graphTypes = {
  deploymentData: 'scatter',
};

58
export const symbolSizes = {
59
  anomaly: 8,
60 61 62
  default: 14,
};

63 64 65 66 67 68 69 70 71 72
export const areaOpacityValues = {
  default: 0.2,
};

export const colorValues = {
  primaryColor: '#1f78d1', // $blue-500 (see variables.scss)
  anomalySymbol: '#db3b21',
  anomalyAreaColor: '#1f78d1',
};

73 74 75 76 77 78 79
export const chartColorValues = [
  '#1f78d1', // $blue-500 (see variables.scss)
  '#1aaa55', // $green-500
  '#fc9403', // $orange-500
  '#6d49cb', // $purple
];

80 81 82
export const lineTypes = {
  default: 'solid',
};
83

84 85 86 87
export const lineWidths = {
  default: 2,
};

88 89 90 91 92
export const dateFormats = {
  timeOfDay: 'h:MM TT',
  default: 'dd mmm yyyy, h:MMTT',
};

93 94
export const timeRanges = [
  {
95
    label: __('30 minutes'),
96
    duration: { seconds: 60 * 30 },
97
  },
98
  {
99
    label: __('3 hours'),
100
    duration: { seconds: 60 * 60 * 3 },
101
  },
102
  {
103
    label: __('8 hours'),
104
    duration: { seconds: 60 * 60 * 8 },
105 106
    default: true,
  },
107
  {
108
    label: __('1 day'),
109
    duration: { seconds: 60 * 60 * 24 * 1 },
110
  },
111
  {
112
    label: __('3 days'),
113
    duration: { seconds: 60 * 60 * 24 * 3 },
114
  },
115
  {
116
    label: __('1 week'),
117
    duration: { seconds: 60 * 60 * 24 * 7 * 1 },
118
  },
119
  {
120 121
    label: __('1 month'),
    duration: { seconds: 60 * 60 * 24 * 30 },
122
  },
123 124 125
];

export const defaultTimeRange = timeRanges.find(tr => tr.default);