Skip to content

Commit

Permalink
[SLO] move constants to common (#172186)
Browse files Browse the repository at this point in the history
## Summary

Resolves #170474

- Moves constants from `server/assets/constants` to
`common/slo/constants`
- Updates all the constants with the new path
- Updates the Lens definition to use the new path

---------

Co-authored-by: Kibana Machine <[email protected]>
  • Loading branch information
dominiqueclarke and kibanamachine authored Dec 4, 2023
1 parent d21fd3a commit 7133509
Show file tree
Hide file tree
Showing 44 changed files with 44 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import { useEuiTheme } from '@elastic/eui';
import { TypedLensByValueInput } from '@kbn/lens-plugin/public';
import { ALL_VALUE, SLOResponse, timeslicesBudgetingMethodSchema } from '@kbn/slo-schema';
import { SLO_DESTINATION_INDEX_PATTERN } from '../../../../common/slo/constants';

export function useLensDefinition(slo: SLOResponse): TypedLensByValueInput['attributes'] {
const { euiTheme } = useEuiTheme();
Expand Down Expand Up @@ -555,7 +556,7 @@ export function useLensDefinition(slo: SLOResponse): TypedLensByValueInput['attr
adHocDataViews: {
'32ca1ad4-81c0-4daf-b9d1-07118044bdc5': {
id: '32ca1ad4-81c0-4daf-b9d1-07118044bdc5',
title: '.slo-observability.sli-v2.*',
title: SLO_DESTINATION_INDEX_PATTERN,
timeFieldName: '@timestamp',
sourceFilters: [],
fieldFormats: {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import { SLO_RESOURCES_VERSION } from '../constants';
import { SLO_RESOURCES_VERSION } from '../../../common/slo/constants';

export const getSLOMappingsTemplate = (name: string) => ({
name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import { SLO_RESOURCES_VERSION } from '../constants';
import { SLO_RESOURCES_VERSION } from '../../../common/slo/constants';

export const getSLOSettingsTemplate = (name: string) => ({
name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import { SLO_RESOURCES_VERSION } from '../constants';
import { SLO_RESOURCES_VERSION } from '../../../common/slo/constants';

export const getSLOSummaryMappingsTemplate = (name: string) => ({
name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import { SLO_RESOURCES_VERSION } from '../constants';
import { SLO_RESOURCES_VERSION } from '../../../common/slo/constants';

export const getSLOSummarySettingsTemplate = (name: string) => ({
name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import { SLO_RESOURCES_VERSION } from '../constants';
import { SLO_RESOURCES_VERSION } from '../../../common/slo/constants';

export const getSLOIndexTemplate = (name: string, indexPattern: string, composedOf: string[]) => ({
name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import { SLO_RESOURCES_VERSION } from '../constants';
import { SLO_RESOURCES_VERSION } from '../../../common/slo/constants';

export const getSLOSummaryIndexTemplate = (
name: string,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import { SLO_RESOURCES_VERSION } from '../constants';
import { SLO_RESOURCES_VERSION } from '../../../common/slo/constants';

export const getSLOPipelineTemplate = (id: string, indexNamePrefix: string) => ({
id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import { SLO_RESOURCES_VERSION } from '../constants';
import { SLO_RESOURCES_VERSION } from '../../../common/slo/constants';

export const getSLOSummaryPipelineTemplate = (id: string) => ({
id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
TransformSource,
TransformTimeSync,
} from '@elastic/elasticsearch/lib/api/types';
import { SLO_RESOURCES_VERSION } from '../constants';
import { SLO_RESOURCES_VERSION } from '../../../common/slo/constants';

export interface TransformSettings {
frequency: TransformPutTransformRequest['frequency'];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { ElasticsearchClient } from '@kbn/core/server';
import { get } from 'lodash';
import { Duration, SLO, toDurationUnit } from '../../../../domain/models';
import { BurnRateRuleParams } from '../types';
import { SLO_DESTINATION_INDEX_PATTERN } from '../../../../assets/constants';
import { SLO_DESTINATION_INDEX_PATTERN } from '../../../../../common/slo/constants';
import {
buildQuery,
EvaluationAfterKey,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import { ElasticsearchClient } from '@kbn/core/server';
import { ALL_VALUE, CreateSLOParams, CreateSLOResponse } from '@kbn/slo-schema';
import { v4 as uuidv4 } from 'uuid';
import { SLO_SUMMARY_TEMP_INDEX_NAME } from '../../assets/constants';
import { SLO_SUMMARY_TEMP_INDEX_NAME } from '../../../common/slo/constants';
import { Duration, DurationUnit, SLO } from '../../domain/models';
import { validateSLO } from '../../domain/services';
import { SLORepository } from './slo_repository';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
getSLOTransformId,
SLO_DESTINATION_INDEX_PATTERN,
SLO_SUMMARY_DESTINATION_INDEX_PATTERN,
} from '../../assets/constants';
} from '../../../common/slo/constants';
import { DeleteSLO } from './delete_slo';
import { createAPMTransactionErrorRateIndicator, createSLO } from './fixtures/slo';
import { createSLORepositoryMock, createTransformManagerMock } from './mocks';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
getSLOTransformId,
SLO_DESTINATION_INDEX_PATTERN,
SLO_SUMMARY_DESTINATION_INDEX_PATTERN,
} from '../../assets/constants';
} from '../../../common/slo/constants';
import { SLORepository } from './slo_repository';
import { TransformManager } from './transform_manager';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { ALL_VALUE, DeleteSLOInstancesParams } from '@kbn/slo-schema';
import {
SLO_DESTINATION_INDEX_PATTERN,
SLO_SUMMARY_DESTINATION_INDEX_PATTERN,
} from '../../assets/constants';
} from '../../../common/slo/constants';
import { IllegalArgumentError } from '../../errors';

interface SloInstanceTuple {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import { ElasticsearchClient } from '@kbn/core-elasticsearch-server';
import { ALL_VALUE, GetSLOInstancesResponse } from '@kbn/slo-schema';
import { SLO_DESTINATION_INDEX_PATTERN } from '../../assets/constants';
import { SLO_DESTINATION_INDEX_PATTERN } from '../../../common/slo/constants';
import { SLORepository } from './slo_repository';

export class GetSLOInstances {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {
import { assertNever } from '@kbn/std';
import * as t from 'io-ts';
import moment from 'moment';
import { SLO_DESTINATION_INDEX_PATTERN } from '../../assets/constants';
import { SLO_DESTINATION_INDEX_PATTERN } from '../../../common/slo/constants';
import { DateRange, HistoricalSummary, SLO, SLOId } from '../../domain/models';
import {
computeSLI,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import { getSLOTransformId } from '../../assets/constants';
import { getSLOTransformId } from '../../../common/slo/constants';
import { SLORepository } from './slo_repository';
import { TransformManager } from './transform_manager';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
SLO_SUMMARY_COMPONENT_TEMPLATE_SETTINGS_NAME,
SLO_SUMMARY_INDEX_TEMPLATE_NAME,
SLO_SUMMARY_INGEST_PIPELINE_NAME,
} from '../../assets/constants';
} from '../../../common/slo/constants';
import { DefaultResourceInstaller } from './resource_installer';

describe('resourceInstaller', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import {
SLO_SUMMARY_INDEX_TEMPLATE_PATTERN,
SLO_SUMMARY_INGEST_PIPELINE_NAME,
SLO_SUMMARY_TEMP_INDEX_NAME,
} from '../../assets/constants';
} from '../../../common/slo/constants';
import { getSLOIndexTemplate } from '../../assets/index_templates/slo_index_templates';
import { getSLOSummaryIndexTemplate } from '../../assets/index_templates/slo_summary_index_templates';
import { getSLOPipelineTemplate } from '../../assets/ingest_templates/slo_pipeline_template';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {
timeslicesBudgetingMethodSchema,
} from '@kbn/slo-schema';
import { assertNever } from '@kbn/std';
import { SLO_DESTINATION_INDEX_PATTERN } from '../../assets/constants';
import { SLO_DESTINATION_INDEX_PATTERN } from '../../../common/slo/constants';
import { DateRange, Duration, IndicatorData, SLO } from '../../domain/models';
import { InternalQueryError } from '../../errors';
import { getDelayInSecondsFromSLO } from '../../domain/services/get_delay_in_seconds_from_slo';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import { ElasticsearchClientMock, elasticsearchServiceMock } from '@kbn/core/server/mocks';
import moment from 'moment';
import { SLO_DESTINATION_INDEX_PATTERN } from '../../assets/constants';
import { SLO_DESTINATION_INDEX_PATTERN } from '../../../common/slo/constants';
import { Duration, DurationUnit } from '../../domain/models';
import { createSLO } from './fixtures/slo';
import { sevenDaysRolling, weeklyCalendarAligned } from './fixtures/time_window';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
toMomentUnitOfTime,
} from '@kbn/slo-schema';
import moment from 'moment';
import { SLO_DESTINATION_INDEX_PATTERN } from '../../assets/constants';
import { SLO_DESTINATION_INDEX_PATTERN } from '../../../common/slo/constants';
import { DateRange, SLO, Summary } from '../../domain/models';
import { computeSLI, computeSummaryStatus, toErrorBudget } from '../../domain/services';
import { toDateRange } from '../../domain/services/date_range';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { ElasticsearchClient, Logger } from '@kbn/core/server';
import { ALL_VALUE } from '@kbn/slo-schema';
import { assertNever } from '@kbn/std';
import _ from 'lodash';
import { SLO_SUMMARY_DESTINATION_INDEX_PATTERN } from '../../assets/constants';
import { SLO_SUMMARY_DESTINATION_INDEX_PATTERN } from '../../../common/slo/constants';
import { SLOId, Status, Summary } from '../../domain/models';
import { toHighPrecision } from '../../utils/number';
import { getElastichsearchQueryOrThrow } from './transform_generators';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import type { ElasticsearchClient, Logger } from '@kbn/core/server';
import {
SLO_SUMMARY_TRANSFORMS_VERSION,
SLO_SUMMARY_TRANSFORM_NAME_PREFIX,
} from '../../../assets/constants';
} from '../../../../common/slo/constants';
import { retryTransientEsErrors } from '../../../utils/retry';
import { ALL_TRANSFORM_TEMPLATES } from './templates';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
SLO_SUMMARY_INGEST_PIPELINE_NAME,
SLO_SUMMARY_TRANSFORMS_VERSION,
SLO_SUMMARY_TRANSFORM_NAME_PREFIX,
} from '../../../../assets/constants';
} from '../../../../../common/slo/constants';
import { groupBy } from './common';

export const SUMMARY_OCCURRENCES_30D_ROLLING: TransformPutTransformRequest = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
SLO_SUMMARY_INGEST_PIPELINE_NAME,
SLO_SUMMARY_TRANSFORMS_VERSION,
SLO_SUMMARY_TRANSFORM_NAME_PREFIX,
} from '../../../../assets/constants';
} from '../../../../../common/slo/constants';
import { groupBy } from './common';

export const SUMMARY_OCCURRENCES_7D_ROLLING: TransformPutTransformRequest = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
SLO_SUMMARY_INGEST_PIPELINE_NAME,
SLO_SUMMARY_TRANSFORMS_VERSION,
SLO_SUMMARY_TRANSFORM_NAME_PREFIX,
} from '../../../../assets/constants';
} from '../../../../../common/slo/constants';
import { groupBy } from './common';

export const SUMMARY_OCCURRENCES_90D_ROLLING: TransformPutTransformRequest = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
SLO_SUMMARY_INGEST_PIPELINE_NAME,
SLO_SUMMARY_TRANSFORMS_VERSION,
SLO_SUMMARY_TRANSFORM_NAME_PREFIX,
} from '../../../../assets/constants';
} from '../../../../../common/slo/constants';
import { groupBy } from './common';

export const SUMMARY_OCCURRENCES_MONTHLY_ALIGNED: TransformPutTransformRequest = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
SLO_SUMMARY_INGEST_PIPELINE_NAME,
SLO_SUMMARY_TRANSFORMS_VERSION,
SLO_SUMMARY_TRANSFORM_NAME_PREFIX,
} from '../../../../assets/constants';
} from '../../../../../common/slo/constants';
import { groupBy } from './common';

export const SUMMARY_OCCURRENCES_WEEKLY_ALIGNED: TransformPutTransformRequest = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
SLO_SUMMARY_INGEST_PIPELINE_NAME,
SLO_SUMMARY_TRANSFORMS_VERSION,
SLO_SUMMARY_TRANSFORM_NAME_PREFIX,
} from '../../../../assets/constants';
} from '../../../../../common/slo/constants';
import { groupBy } from './common';

export const SUMMARY_TIMESLICES_30D_ROLLING: TransformPutTransformRequest = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
SLO_SUMMARY_INGEST_PIPELINE_NAME,
SLO_SUMMARY_TRANSFORMS_VERSION,
SLO_SUMMARY_TRANSFORM_NAME_PREFIX,
} from '../../../../assets/constants';
} from '../../../../../common/slo/constants';
import { groupBy } from './common';

export const SUMMARY_TIMESLICES_7D_ROLLING: TransformPutTransformRequest = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
SLO_SUMMARY_INGEST_PIPELINE_NAME,
SLO_SUMMARY_TRANSFORMS_VERSION,
SLO_SUMMARY_TRANSFORM_NAME_PREFIX,
} from '../../../../assets/constants';
} from '../../../../../common/slo/constants';
import { groupBy } from './common';

export const SUMMARY_TIMESLICES_90D_ROLLING: TransformPutTransformRequest = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
SLO_SUMMARY_INGEST_PIPELINE_NAME,
SLO_SUMMARY_TRANSFORMS_VERSION,
SLO_SUMMARY_TRANSFORM_NAME_PREFIX,
} from '../../../../assets/constants';
} from '../../../../../common/slo/constants';
import { groupBy } from './common';

export const SUMMARY_TIMESLICES_MONTHLY_ALIGNED: TransformPutTransformRequest = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
SLO_SUMMARY_INGEST_PIPELINE_NAME,
SLO_SUMMARY_TRANSFORMS_VERSION,
SLO_SUMMARY_TRANSFORM_NAME_PREFIX,
} from '../../../../assets/constants';
} from '../../../../../common/slo/constants';
import { groupBy } from './common';

export const SUMMARY_TIMESLICES_WEEKLY_ALIGNED: TransformPutTransformRequest = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
getSLOTransformId,
SLO_DESTINATION_INDEX_NAME,
SLO_INGEST_PIPELINE_NAME,
} from '../../../assets/constants';
} from '../../../../common/slo/constants';
import { getSLOTransformTemplate } from '../../../assets/transform_templates/slo_transform_template';
import { APMTransactionDurationIndicator, SLO } from '../../../domain/models';
import { InvalidTransformError } from '../../../errors';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
getSLOTransformId,
SLO_DESTINATION_INDEX_NAME,
SLO_INGEST_PIPELINE_NAME,
} from '../../../assets/constants';
} from '../../../../common/slo/constants';
import { getSLOTransformTemplate } from '../../../assets/transform_templates/slo_transform_template';
import { APMTransactionErrorRateIndicator, SLO } from '../../../domain/models';
import { InvalidTransformError } from '../../../errors';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
SLO_DESTINATION_INDEX_NAME,
SLO_INGEST_PIPELINE_NAME,
getSLOTransformId,
} from '../../../assets/constants';
} from '../../../../common/slo/constants';
import { SLO } from '../../../domain/models';
import { GetHistogramIndicatorAggregation } from '../aggregations';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
SLO_DESTINATION_INDEX_NAME,
SLO_INGEST_PIPELINE_NAME,
getSLOTransformId,
} from '../../../assets/constants';
} from '../../../../common/slo/constants';
import { KQLCustomIndicator, SLO } from '../../../domain/models';

export class KQLCustomTransformGenerator extends TransformGenerator {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
SLO_DESTINATION_INDEX_NAME,
SLO_INGEST_PIPELINE_NAME,
getSLOTransformId,
} from '../../../assets/constants';
} from '../../../../common/slo/constants';
import { MetricCustomIndicator, SLO } from '../../../domain/models';
import { GetCustomMetricIndicatorAggregation } from '../aggregations';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {
SLO_DESTINATION_INDEX_NAME,
SLO_INGEST_PIPELINE_NAME,
getSLOTransformId,
} from '../../../assets/constants';
} from '../../../../common/slo/constants';
import { SLO } from '../../../domain/models';
import { GetTimesliceMetricIndicatorAggregation } from '../aggregations';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
getSLOTransformId,
SLO_DESTINATION_INDEX_PATTERN,
SLO_SUMMARY_DESTINATION_INDEX_PATTERN,
} from '../../assets/constants';
} from '../../../common/slo/constants';
import { SLO } from '../../domain/models';
import { fiveMinute, oneMinute } from './fixtures/duration';
import {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
SLO_DESTINATION_INDEX_PATTERN,
SLO_SUMMARY_DESTINATION_INDEX_PATTERN,
SLO_SUMMARY_TEMP_INDEX_NAME,
} from '../../assets/constants';
} from '../../../common/slo/constants';
import { SLO } from '../../domain/models';
import { validateSLO } from '../../domain/services';
import { SLORepository } from './slo_repository';
Expand Down

0 comments on commit 7133509

Please sign in to comment.