Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fleet] Add support for allow_routing data streams option #131609

Closed
wants to merge 1 commit into from
Closed
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 @@ -25,7 +25,7 @@ import {
} from './policy_template';

type PackagePolicyStream = RegistryStream & { release?: 'beta' | 'experimental' | 'ga' } & {
data_stream: { type: string; dataset: string };
data_stream: { type: string; dataset: string; allow_routing?: boolean };
};

export const getStreamsForInputType = (
Expand All @@ -47,6 +47,7 @@ export const getStreamsForInputType = (
data_stream: {
type: dataStream.type,
dataset: dataStream.dataset,
allow_routing: dataStream.allow_routing,
},
release: dataStream.release,
});
Expand Down
1 change: 1 addition & 0 deletions x-pack/plugins/fleet/common/types/models/data_stream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export interface DataStream {
dataset: string;
namespace: string;
type: string;
allow_routing: boolean;
package: string;
package_version: string;
last_activity_ms: number;
Expand Down
4 changes: 3 additions & 1 deletion x-pack/plugins/fleet/common/types/models/epm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -328,10 +328,11 @@ export enum RegistryDataStreamKeys {
ingest_pipeline = 'ingest_pipeline',
elasticsearch = 'elasticsearch',
dataset_is_prefix = 'dataset_is_prefix',
allow_routing = 'allow_routing',
}

export interface RegistryDataStream {
[key: string]: any;
[key: string]: unknown;
[RegistryDataStreamKeys.type]: string;
[RegistryDataStreamKeys.ilm_policy]?: string;
[RegistryDataStreamKeys.hidden]?: boolean;
Expand All @@ -344,6 +345,7 @@ export interface RegistryDataStream {
[RegistryDataStreamKeys.ingest_pipeline]?: string;
[RegistryDataStreamKeys.elasticsearch]?: RegistryElasticsearch;
[RegistryDataStreamKeys.dataset_is_prefix]?: boolean;
[RegistryDataStreamKeys.allow_routing]?: boolean;
}

export interface RegistryElasticsearch {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export interface NewPackagePolicyInputStream {
data_stream: {
dataset: string;
type: string;
allow_routing?: boolean;
elasticsearch?: {
privileges?: {
indices?: string[];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ export async function storedPackagePoliciesToAgentPermissions(
type: stream.data_stream.type,
dataset:
stream.compiled_stream?.data_stream?.dataset ?? stream.data_stream.dataset,
allow_routing: stream.data_stream.allow_routing,
};

if (stream.data_stream.elasticsearch) {
Expand Down Expand Up @@ -140,6 +141,7 @@ interface DataStreamMeta {
dataset: string;
dataset_is_prefix?: boolean;
hidden?: boolean;
allow_routing?: boolean;
elasticsearch?: {
privileges?: RegistryDataStreamPrivileges;
};
Expand All @@ -158,6 +160,10 @@ export function getDataStreamPrivileges(dataStream: DataStreamMeta, namespace: s

index += `-${namespace}`;

if (dataStream.allow_routing) {
index = `${dataStream.type}-*-*`;
}

const privileges = dataStream?.elasticsearch?.privileges?.indices?.length
? dataStream.elasticsearch.privileges.indices
: PACKAGE_POLICY_DEFAULT_INDEX_PRIVILEGES;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ title: Test Dataset

type: logs

allow_routing: true

elasticsearch:
index_template.mappings:
dynamic: true
Expand Down