Skip to content

Commit

Permalink
Remove dependency on the observability plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
weltenwort committed Dec 13, 2024
1 parent ed832fa commit f7be89d
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,16 @@
import { badRequest } from '@hapi/boom';
import type { ElasticsearchClient, IScopedClusterClient } from '@kbn/core/server';
import {
findInventoryFields,
InventoryItemType,
findInventoryFields,
inventoryModels,
} from '@kbn/metrics-data-access-plugin/common';
import { rangeQuery } from '@kbn/observability-plugin/server';

import { DataStreamDetails } from '../../../../common/api_types';
import { MAX_HOSTS_METRIC_VALUE } from '../../../../common/constants';
import { _IGNORED } from '../../../../common/es_fields';
import { DataStreamDetails } from '../../../../common/api_types';
import { createDatasetQualityESClient } from '../../../utils';
import { datasetQualityPrivileges } from '../../../services';
import { createDatasetQualityESClient } from '../../../utils';
import { rangeQuery } from '../../../utils/queries';
import { getDataStreams } from '../get_data_streams';
import { getDataStreamsMeteringStats } from '../get_data_streams_metering_stats';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
* 2.0.
*/

import type { ElasticsearchClient } from '@kbn/core/server';
import { rangeQuery } from '@kbn/observability-plugin/server';
import { QueryDslBoolQuery } from '@elastic/elasticsearch/lib/api/types';
import type { ElasticsearchClient } from '@kbn/core/server';
import { DataStreamDocsStat } from '../../../common/api_types';
import { createDatasetQualityESClient } from '../../utils';
import { rangeQuery } from '../../utils/queries';

interface Dataset {
type: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
*/

import { ElasticsearchClient } from '@kbn/core-elasticsearch-server';
import { rangeQuery, existsQuery } from '@kbn/observability-plugin/server';
import { DegradedFieldResponse } from '../../../../common/api_types';
import { MAX_DEGRADED_FIELDS } from '../../../../common/constants';
import { INDEX, TIMESTAMP, _IGNORED } from '../../../../common/es_fields';
import { createDatasetQualityESClient } from '../../../utils';
import { _IGNORED, INDEX, TIMESTAMP } from '../../../../common/es_fields';
import { existsQuery, rangeQuery } from '../../../utils/queries';
import { getFieldIntervalInSeconds } from './get_interval';

export async function getDegradedFields({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
*/

import { ElasticsearchClient } from '@kbn/core-elasticsearch-server';
import { rangeQuery } from '@kbn/observability-plugin/server/utils/queries';
import { extractIndexNameFromBackingIndex } from '../../../common/utils';
import { _IGNORED } from '../../../common/es_fields';
import { DataStreamType } from '../../../common/types';
import { extractIndexNameFromBackingIndex } from '../../../common/utils';
import { createDatasetQualityESClient } from '../../utils';
import { rangeQuery } from '../../utils/queries';

export async function getNonAggregatableDataStreams({
esClient,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
* 2.0.
*/
import { QueryDslQueryContainer } from '@elastic/elasticsearch/lib/api/types';
import { isUndefinedOrNull } from '@kbn/observability-plugin/server/utils/queries';

export function isUndefinedOrNull(value: any): value is undefined | null {
return value === undefined || value === null;
}

export function wildcardQuery<T extends string>(
field: T,
Expand All @@ -17,3 +20,25 @@ export function wildcardQuery<T extends string>(

return [{ wildcard: { [field]: `*${value}*` } }];
}

export function rangeQuery(
start?: number,
end?: number,
field = '@timestamp'
): QueryDslQueryContainer[] {
return [
{
range: {
[field]: {
gte: start,
lte: end,
format: 'epoch_millis',
},
},
},
];
}

export function existsQuery(field: string): QueryDslQueryContainer[] {
return [{ exists: { field } }];
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
"@kbn/field-formats-plugin",
"@kbn/field-types",
"@kbn/io-ts-utils",
"@kbn/observability-plugin",
"@kbn/es-types",
"@kbn/deeplinks-observability",
"@kbn/router-utils",
Expand Down

0 comments on commit f7be89d

Please sign in to comment.