Skip to content

Commit 55e8677

Browse files
authored
Complete OTel configuration pipelines with an exporter (elastic#233090)
- Merge configuration of multiple inputs in a single configuration. - Add a forward connector as exporter for each input pipeline. - Generate an exporter configuration based on the assigned data output. - Add a pipeline with all the forward connectors as receivers and the generated exporter as exporter. - Add a transform processor to each pipeline with the attributes for dynamic routing.
1 parent d2b6936 commit 55e8677

File tree

8 files changed

+811
-222
lines changed

8 files changed

+811
-222
lines changed

x-pack/platform/plugins/shared/fleet/server/services/agent_policies/full_agent_policy.ts

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,13 @@ import type {
2626
FleetProxy,
2727
FleetServerHost,
2828
AgentPolicy,
29-
TemplateAgentPolicyInput,
3029
} from '../../types';
3130
import type {
3231
DownloadSource,
3332
FullAgentPolicyDownload,
3433
FullAgentPolicyInput,
3534
FullAgentPolicyMonitoring,
3635
FullAgentPolicyOutputPermissions,
37-
OTelCollectorConfig,
3836
PackageInfo,
3937
} from '../../../common/types';
4038
import { agentPolicyService } from '../agent_policy';
@@ -64,6 +62,7 @@ import {
6462
DEFAULT_CLUSTER_PERMISSIONS,
6563
} from './package_policies_to_agent_permissions';
6664
import { fetchRelatedSavedObjects } from './related_saved_objects';
65+
import { generateOtelcolConfig } from './otel_collector';
6766

6867
async function fetchAgentPolicy(soClient: SavedObjectsClientContract, id: string) {
6968
try {
@@ -162,7 +161,7 @@ export async function getFullAgentPolicy(
162161

163162
let otelcolConfig;
164163
if (experimentalFeature.enableOtelIntegrations) {
165-
otelcolConfig = generateOtelcolConfig(agentInputs);
164+
otelcolConfig = generateOtelcolConfig(agentInputs, dataOutput);
166165
}
167166

168167
const inputs = agentInputs
@@ -891,25 +890,3 @@ export function getBinarySourceSettings(
891890
}
892891
return config;
893892
}
894-
895-
// Generate OTel Collector policy
896-
export function generateOtelcolConfig(inputs: FullAgentPolicyInput[] | TemplateAgentPolicyInput[]) {
897-
const otelConfig = inputs.flatMap((input) => {
898-
if (input.type === OTEL_COLLECTOR_INPUT_TYPE) {
899-
const otelInputs: OTelCollectorConfig[] = (input?.streams ?? []).flatMap((inputStream) => {
900-
return {
901-
...(inputStream?.receivers ? { receivers: inputStream.receivers } : {}),
902-
...(inputStream?.service ? { service: inputStream.service } : {}),
903-
...(inputStream?.extensions ? { service: inputStream.extensions } : {}),
904-
...(inputStream?.processors ? { service: inputStream.processors } : {}),
905-
...(inputStream?.connectors ? { service: inputStream.connectors } : {}),
906-
...(inputStream?.exporters ? { service: inputStream.exporters } : {}),
907-
};
908-
});
909-
910-
return otelInputs;
911-
}
912-
});
913-
914-
return otelConfig.length > 0 ? otelConfig[0] : {};
915-
}

0 commit comments

Comments
 (0)