-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[Ingest] Allow to enable monitoring of elastic agent #63598
Merged
nchaulet
merged 10 commits into
elastic:master
from
nchaulet:feature-fleet-agent-monitoring
Apr 29, 2020
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
5d030c3
[Ingest] Allow to enable monitoring of elastic agent
nchaulet d63354e
Merge branch 'master' of github.com:elastic/kibana into feature-fleet…
nchaulet a41950b
Fix typo
nchaulet 415f92e
Merge branch 'master' of github.com:elastic/kibana into feature-fleet…
nchaulet 3c3464d
update UI
nchaulet b8cc23f
Merge branch 'master' of github.com:elastic/kibana into feature-fleet…
nchaulet ae0b854
Enable by default
nchaulet c7300d1
Merge branch 'master' of github.com:elastic/kibana into feature-fleet…
nchaulet b477035
Fix type issue
nchaulet 41cd40e
Update x-pack/plugins/ingest_manager/public/applications/ingest_manag…
nchaulet File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
134 changes: 134 additions & 0 deletions
134
x-pack/plugins/ingest_manager/server/services/agent_config.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { savedObjectsClientMock } from 'src/core/server/mocks'; | ||
import { agentConfigService } from './agent_config'; | ||
import { Output } from '../types'; | ||
|
||
function getSavedObjectMock(configAttributes: any) { | ||
const mock = savedObjectsClientMock.create(); | ||
|
||
mock.get.mockImplementation(async (type: string, id: string) => { | ||
return { | ||
type, | ||
id, | ||
references: [], | ||
attributes: configAttributes, | ||
}; | ||
}); | ||
|
||
return mock; | ||
} | ||
|
||
jest.mock('./output', () => { | ||
return { | ||
outputService: { | ||
getDefaultOutputId: () => 'test-id', | ||
get: (): Output => { | ||
return { | ||
id: 'test-id', | ||
is_default: true, | ||
name: 'default', | ||
// @ts-ignore | ||
type: 'elasticsearch', | ||
hosts: ['http://127.0.0.1:9201'], | ||
}; | ||
}, | ||
}, | ||
}; | ||
}); | ||
|
||
describe('agent config', () => { | ||
describe('getFullConfig', () => { | ||
it('should return a config without monitoring if not monitoring is not enabled', async () => { | ||
const soClient = getSavedObjectMock({ | ||
revision: 1, | ||
}); | ||
const config = await agentConfigService.getFullConfig(soClient, 'config'); | ||
|
||
expect(config).toMatchObject({ | ||
id: 'config', | ||
outputs: { | ||
default: { | ||
type: 'elasticsearch', | ||
hosts: ['http://127.0.0.1:9201'], | ||
ca_sha256: undefined, | ||
api_key: undefined, | ||
}, | ||
}, | ||
datasources: [], | ||
revision: 1, | ||
settings: { | ||
monitoring: { | ||
enabled: false, | ||
logs: false, | ||
metrics: false, | ||
}, | ||
}, | ||
}); | ||
}); | ||
|
||
it('should return a config with monitoring if monitoring is enabled for logs', async () => { | ||
const soClient = getSavedObjectMock({ | ||
revision: 1, | ||
monitoring_enabled: ['logs'], | ||
}); | ||
const config = await agentConfigService.getFullConfig(soClient, 'config'); | ||
|
||
expect(config).toMatchObject({ | ||
id: 'config', | ||
outputs: { | ||
default: { | ||
type: 'elasticsearch', | ||
hosts: ['http://127.0.0.1:9201'], | ||
ca_sha256: undefined, | ||
api_key: undefined, | ||
}, | ||
}, | ||
datasources: [], | ||
revision: 1, | ||
settings: { | ||
monitoring: { | ||
use_output: 'default', | ||
enabled: true, | ||
logs: true, | ||
metrics: false, | ||
}, | ||
}, | ||
}); | ||
}); | ||
|
||
it('should return a config with monitoring if monitoring is enabled for metrics', async () => { | ||
const soClient = getSavedObjectMock({ | ||
revision: 1, | ||
monitoring_enabled: ['metrics'], | ||
}); | ||
const config = await agentConfigService.getFullConfig(soClient, 'config'); | ||
|
||
expect(config).toMatchObject({ | ||
id: 'config', | ||
outputs: { | ||
default: { | ||
type: 'elasticsearch', | ||
hosts: ['http://127.0.0.1:9201'], | ||
ca_sha256: undefined, | ||
api_key: undefined, | ||
}, | ||
}, | ||
datasources: [], | ||
revision: 1, | ||
settings: { | ||
monitoring: { | ||
use_output: 'default', | ||
enabled: true, | ||
logs: false, | ||
metrics: true, | ||
}, | ||
}, | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can use
.includes
instead of.indexOf