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 @@ -64,6 +64,7 @@ export interface FullAgentPolicy {
fleet?: {
kibana: {
hosts: string[];
protocol: string;
};
};
inputs: FullAgentPolicyInput[];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ describe('agent policy', () => {
revision: 1,
fleet: {
kibana: {
hosts: ['http://localhost:5603'],
hosts: ['localhost:5603'],
protocol: 'http',
},
},
agent: {
Expand Down Expand Up @@ -115,7 +116,8 @@ describe('agent policy', () => {
revision: 1,
fleet: {
kibana: {
hosts: ['http://localhost:5603'],
hosts: ['localhost:5603'],
protocol: 'http',
},
},
agent: {
Expand Down Expand Up @@ -150,7 +152,8 @@ describe('agent policy', () => {
revision: 1,
fleet: {
kibana: {
hosts: ['http://localhost:5603'],
hosts: ['localhost:5603'],
protocol: 'http',
},
},
agent: {
Expand Down
10 changes: 8 additions & 2 deletions x-pack/plugins/ingest_manager/server/services/agent_policy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -532,10 +532,16 @@ class AgentPolicyService {
} catch (error) {
throw new Error('Default settings is not setup');
}
if (!settings.kibana_urls) throw new Error('kibana_urls is missing');
if (!settings.kibana_urls || !settings.kibana_urls.length)
throw new Error('kibana_urls is missing');
const hostsWithoutProtocol = settings.kibana_urls.map((url) => {
const parsedURL = new URL(url);
return `${parsedURL.host}${parsedURL.pathname !== '/' ? parsedURL.pathname : ''}`;
});
fullAgentPolicy.fleet = {
kibana: {
hosts: settings.kibana_urls,
protocol: new URL(settings.kibana_urls[0]).protocol.replace(':', ''),
hosts: hostsWithoutProtocol,
},
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
const { protocol, hostname, port } = kbnTestServer;

const kibanaUrl = Url.format({
protocol,
hostname,
port,
});
Expand Down Expand Up @@ -237,6 +236,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
fleet: {
kibana: {
hosts: [kibanaUrl],
protocol,
},
},
revision: 3,
Expand Down