Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ const scenario: Scenario<any> = async ({ logger, scenarioOpts = { numHosts: 2 }
'host.ip': '122.122.122.122',
'resource.attributes.host.name': hostName,
'resource.attributes.os.type': 'linux',
'os.type': 'linux',
// This is the key: dataset that matches inventory model expectation
'data_stream.dataset': 'hostmetricsreceiver.otel',
'data_stream.type': 'metrics',
Expand Down Expand Up @@ -125,9 +126,11 @@ const scenario: Scenario<any> = async ({ logger, scenarioOpts = { numHosts: 2 }
direction: 'receive',
'system.network.io': Math.floor(Math.random() * 1000000000), // bytes received
},
].map((net) => ({
].map(({ 'system.network.io': netIo, ...net }) => ({
...base,
...net,
'system.network.io': netIo,
'metrics.system.network.io': netIo,
'metricset.name': 'network',
'device.keyword': 'eth0',
}));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const scenario: Scenario<InfraDocument | ApmFields> = async ({
const instances = times(numInstances).map((index) => {
return apm
.service({
name: `synth-node-${index % 3}`,
name: `synth-node-${index}`,
environment: ENVIRONMENT,
agentName: 'node-js',
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import {
CLOUD_PROVIDER,
HOST_OS_NAME,
OS_NAME,
OS_TYPE,
SERVICE_NAME,
type DataSchemaFormat,
} from '@kbn/metrics-data-access-plugin/common';
Expand Down Expand Up @@ -49,28 +49,28 @@ const controlPanelConfig: Record<DataSchemaFormat, ControlPanels> = {
},
},
semconv: {
[OS_NAME]: {
[OS_TYPE]: {
order: 0,
width: 'medium',
grow: false,
type: 'optionsListControl',
fieldName: OS_NAME,
fieldName: OS_TYPE,
title: 'Operating System',
},
},
};

const replaceableControlPanels: Record<DataSchemaFormat, ReplaceableControl> = {
ecs: {
[OS_NAME]: {
[OS_TYPE]: {
key: HOST_OS_NAME,
control: controlPanelConfig.ecs[HOST_OS_NAME],
},
},
semconv: {
[HOST_OS_NAME]: {
key: OS_NAME,
control: controlPanelConfig.semconv[OS_NAME],
key: OS_TYPE,
control: controlPanelConfig.semconv[OS_TYPE],
},
},
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,17 @@ import type {
} from '@kbn/controls-plugin/public';
import { ControlGroupRenderer } from '@kbn/controls-plugin/public';
import type { DataView } from '@kbn/data-views-plugin/public';
import type { Filter, Query, TimeRange } from '@kbn/es-query';
import { buildCustomFilter, type Filter, type Query, type TimeRange } from '@kbn/es-query';
import { FilterStateStore } from '@kbn/es-query-constants';
import styled from '@emotion/styled';
import { useControlPanels } from '@kbn/observability-shared-plugin/public';
import React, { useCallback, useEffect, useMemo, useRef } from 'react';
import { Subscription } from 'rxjs';
import type { DataSchemaFormat } from '@kbn/metrics-data-access-plugin/common';
import {
DATASTREAM_DATASET,
findInventoryModel,
type DataSchemaFormat,
} from '@kbn/metrics-data-access-plugin/common';
import { useTimeRangeMetadataContext } from '../../../../../hooks/use_time_range_metadata';
import { SchemaSelector } from '../../../../../components/schema_selector';
import { getControlPanelConfigs } from './control_panels_config';
Expand Down Expand Up @@ -46,6 +51,34 @@ export const ControlsContent = ({
schemas,
}: Props) => {
const controlConfigs = useMemo(() => getControlPanelConfigs(schema), [schema]);
const schemaFilters = useMemo(() => {
if (!schema || !dataView?.id) return [];
const inventoryModel = findInventoryModel('host');
const nodeFilterQueries = inventoryModel.nodeFilter?.({ schema }) ?? [];

const apmDatasetFilter: Record<string, object> =
schema === 'ecs'
? { prefix: { [DATASTREAM_DATASET]: { value: 'apm.transaction.' } } }
: { wildcard: { [DATASTREAM_DATASET]: { value: 'transaction.*.otel' } } };

const shouldClauses = [...nodeFilterQueries, apmDatasetFilter];

return [
buildCustomFilter(
dataView.id!,
{
bool: {
should: shouldClauses,
minimum_should_match: 1,
},
},
false,
false,
null,
FilterStateStore.APP_STATE
),
];
}, [schema, dataView?.id]);
const [controlPanels, setControlPanels] = useControlPanels(controlConfigs.controls, dataView);
const controlGroupAPI = useRef<ControlGroupRendererApi | undefined>();
const subscriptions = useRef<Subscription>(new Subscription());
Expand Down Expand Up @@ -138,7 +171,7 @@ export const ControlsContent = ({
onApiAvailable={loadCompleteHandler}
timeRange={timeRange}
query={query}
filters={filters}
filters={[...filters, ...schemaFilters]}
/>
<SchemaSelector
isHostsView
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@
"@kbn/observability-agent-builder-plugin",
"@kbn/presentation-publishing",
"@kbn/inspector-plugin",
"@kbn/es-query-constants"
],
"exclude": ["target/**/*"]
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const DATASTREAM_DATASET = 'data_stream.dataset';
export const EVENT_DATASET = 'event.dataset';

// otel
export const OS_NAME = 'os.name';
export const OS_TYPE = 'os.type';

// integrations
export const SYSTEM_INTEGRATION = 'system';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export {
METRICSET_MODULE,
METRICSET_NAME,
DATASTREAM_DATASET,
OS_NAME,
OS_TYPE,
SYSTEM_INTEGRATION,
HOST_METRICS_RECEIVER_OTEL,
} from './constants';
Expand Down
Loading