Skip to content

Commit 041dfdd

Browse files
authored
send protocol separately to agent as part of full agent policy (#79781)
1 parent 7031ea4 commit 041dfdd

File tree

4 files changed

+16
-6
lines changed

4 files changed

+16
-6
lines changed

x-pack/plugins/ingest_manager/common/types/models/agent_policy.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ export interface FullAgentPolicy {
6464
fleet?: {
6565
kibana: {
6666
hosts: string[];
67+
protocol: string;
6768
};
6869
};
6970
inputs: FullAgentPolicyInput[];

x-pack/plugins/ingest_manager/server/services/agent_policy.test.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ describe('agent policy', () => {
8181
revision: 1,
8282
fleet: {
8383
kibana: {
84-
hosts: ['http://localhost:5603'],
84+
hosts: ['localhost:5603'],
85+
protocol: 'http',
8586
},
8687
},
8788
agent: {
@@ -115,7 +116,8 @@ describe('agent policy', () => {
115116
revision: 1,
116117
fleet: {
117118
kibana: {
118-
hosts: ['http://localhost:5603'],
119+
hosts: ['localhost:5603'],
120+
protocol: 'http',
119121
},
120122
},
121123
agent: {
@@ -150,7 +152,8 @@ describe('agent policy', () => {
150152
revision: 1,
151153
fleet: {
152154
kibana: {
153-
hosts: ['http://localhost:5603'],
155+
hosts: ['localhost:5603'],
156+
protocol: 'http',
154157
},
155158
},
156159
agent: {

x-pack/plugins/ingest_manager/server/services/agent_policy.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -538,10 +538,16 @@ class AgentPolicyService {
538538
} catch (error) {
539539
throw new Error('Default settings is not setup');
540540
}
541-
if (!settings.kibana_urls) throw new Error('kibana_urls is missing');
541+
if (!settings.kibana_urls || !settings.kibana_urls.length)
542+
throw new Error('kibana_urls is missing');
543+
const hostsWithoutProtocol = settings.kibana_urls.map((url) => {
544+
const parsedURL = new URL(url);
545+
return `${parsedURL.host}${parsedURL.pathname !== '/' ? parsedURL.pathname : ''}`;
546+
});
542547
fullAgentPolicy.fleet = {
543548
kibana: {
544-
hosts: settings.kibana_urls,
549+
protocol: new URL(settings.kibana_urls[0]).protocol.replace(':', ''),
550+
hosts: hostsWithoutProtocol,
545551
},
546552
};
547553
}

x-pack/test/security_solution_endpoint/apps/endpoint/policy_details.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
2525
const { protocol, hostname, port } = kbnTestServer;
2626

2727
const kibanaUrl = Url.format({
28-
protocol,
2928
hostname,
3029
port,
3130
});
@@ -237,6 +236,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
237236
fleet: {
238237
kibana: {
239238
hosts: [kibanaUrl],
239+
protocol,
240240
},
241241
},
242242
revision: 3,

0 commit comments

Comments
 (0)