-
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
EMT-146: use ingest agent for status info #63921
EMT-146: use ingest agent for status info #63921
Conversation
@elasticmachine merge upstream |
…mdifrankie/kibana into EMT-146_use_agent_service_for_status
@elasticmachine merge upstream |
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.
I'd like to avoid the new AgentService
and getAgentStatus
this PR currently has. Ingest Manager already has an Agent Service. I'd like to use that and its current function signatures, or update them to make them more useful/consistent/whatever, rather than add export a different one.
I made a comment where I think it might work. Ingest Manager's handlers do the same await agent ... getAgentStatus
pattern so I don't think it's unusual for Endpoint to do it.
If getStatusById
is useful Ingest Manager could add/export that. I'd prefer either to adding this new function & signature.
const status = await metadataRequestContext.endpointAppContext.agentService.getAgentStatus( | ||
metadataRequestContext.requestHandlerContext, | ||
hostMetadata.elastic.agent.id | ||
); |
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.
const status = await metadataRequestContext.endpointAppContext.agentService.getAgentStatus( | |
metadataRequestContext.requestHandlerContext, | |
hostMetadata.elastic.agent.id | |
); | |
const { endpointAppContext, requestHandlerContext } = metadataRequestContext; | |
const { getAgent, getAgentStatus } = endpointAppContext.agentService; | |
const agent = await getAgent(requestHandlerContext.core.savedObjects.client, hostMetadata.elastic.agent.id); | |
const status = await getAgentStatus(agent); |
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.
I won't be able to try this locally until Monday afternoon, but I think this will work. If so, we can avoid the new getAgentStatus
this PR adds in Ingest Manager.
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.
@jfsiii Can we talk about this. I would think a wholesale service will be better that performs the functionality will be better. And this does not isolate from changes to how agent status is derived. With this approach we have too much knowledge of the internal working of Ingest. This will mean will do a wholesale export of the entire services directory?
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.
@nnamdifrankie sure, we can talk anytime. I'm available most days from 1pm-5pm ET.
Before then, I'll try to summary my understanding & suggestions.
As I understand it, this PR adds an Agent Service but Ingest Manager already has one
It also adds a function getAgentStatus
which a) is a duplicate of an existing function and b) uses the existing services functions from Ingest.
I'd like to avoid both those issues and think we can do that by moving that function into services/agents/status
, changing its name to something like getAgentStatusById
, and have it accept a saved object client and string id. That's in line with lots of our other service functions.
That way, all you're really changing at this call site is the function name and the first argument. It's still only calling one function and Ingest is the one in control of that logic.
- const status = await metadataRequestContext.endpointAppContext.agentService.getAgentStatus(
- metadataRequestContext.requestHandlerContext,
+ const status = await metadataRequestContext.endpointAppContext.agentService.getAgentStatusById(
+ metadataRequestContext.requestHandlerContext.core.savedObjects.client,
Hope that helps. Reach out any time to talk more.
@elasticmachine merge upstream |
…mdifrankie/kibana into EMT-146_use_agent_service_for_status
@@ -148,6 +150,9 @@ export class IngestManagerPlugin implements Plugin<IngestManagerSetupContract> { | |||
} | |||
return deepFreeze({ | |||
esIndexPatternService: new ESIndexPatternSavedObjectService(), | |||
agentService: { |
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.
I think we should expose agentService
during start, it's probably not going to work if you use it during setup
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.
Thanks for catching that @nchaulet. Yeah, I believe we're encouraged to put as much as possible in start. Especially anything that could Error.
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.
I think this is a setup dependency, because we do the route registration in the setup method which I believe is the place for this action. These are just service definitions are they are not consumed in the setup step but in the handlers. Also if ingest does not setup correctly, then the endpoint is also not supposed to work either at least with how we depend on the ingest plugin today.
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.
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.
Yes esIndexPatternService
should probably be moved to start too.
If it's too much refacto for this PR I am ok to have a follow up PR for that.
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.
Gotcha, yeah I was talking with @nnamdifrankie about that. Right now endpoint is accessing the ingest contract in the setup
function because that's where the routes are being registered. If we move the contract to the start
function I think we'd have to use a singleton or something to point to the ingest contract because I don't think we can register the endpoint routes in the start
function. It seems like other plugins do this. An example is the encrypted saved objects: https://github.com/elastic/kibana/blob/master/x-pack/plugins/actions/server/plugin.ts#L243
Might be easier to do that in a follow up PR.
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.
); | ||
hostStatus = HOST_STATUS_MAPPING.get(status) || HostStatus.ERROR; | ||
} catch (e) { | ||
if (e.isBoom && e.output.statusCode === 404) { |
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.
Does the ingest api throw a boom?
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.
Yes, if a saved object is not found is going throw a Boom error
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.
Yes,
server log [10:02:10.301] [warning][endpoint][metadata][plugins] agent with id 023fa40c-411d-4188-a941-4147bfadd095 not found
@elasticmachine merge upstream |
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.
Changes look good from an endpoint side.
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.
Good to me for the ingest manager part
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.
🚀 from me. Especially with the linked follow up PR.
💚 Build SucceededHistory
To update your PR or re-run it, just comment with: |
* master: (29 commits) [Dashboard] Deangularize navbar, attempt nr. 2 (elastic#61611) refactor action filter creation utils (elastic#62969) Refresh index pattern list before redirecting (elastic#63329) [APM]fixing custom link unit tests (elastic#64045) [Ingest] EPM & Fleet are enabled when Ingest is enabled (elastic#64103) [Alerting] Fixed bug with no possibility to edit the index name after adding (elastic#64033) [Maps] Map settings: min and max zoom (elastic#63714) [kbn-storybook] Use raw loader for text files (elastic#64108) [EPM] /packages/{package} endpoint to support upgrades (elastic#63629) [SIEM] New Platform Saved Objects Registration (elastic#64029) [Endpoint] Hook to handle events needing navigation via Router (elastic#63863) Fixed small issue in clone functionality (elastic#64085) [Endpoint]EMT-146: use ingest agent for status info (elastic#63921) [SIEM] Server NP Followup (elastic#64010) Register uiSettings on New Platform (elastic#64015) [Reporting] Integration polling config with client code (elastic#63754) [Docs]7.7 SIEM doc updates (elastic#63951) [SIEM] [Cases] Tags suggestions (elastic#63878) Include datasource UUID in agent config yaml, adjust overflow height of yaml view (elastic#64027) [DOCS] Add file size setting for Data Visualizer (elastic#64006) ...
…ana into task-manager/cancel-logging * 'task-manager/cancel-logging' of github.com:gmmorris/kibana: (28 commits) [Dashboard] Deangularize navbar, attempt nr. 2 (elastic#61611) refactor action filter creation utils (elastic#62969) Refresh index pattern list before redirecting (elastic#63329) [APM]fixing custom link unit tests (elastic#64045) [Ingest] EPM & Fleet are enabled when Ingest is enabled (elastic#64103) [Alerting] Fixed bug with no possibility to edit the index name after adding (elastic#64033) [Maps] Map settings: min and max zoom (elastic#63714) [kbn-storybook] Use raw loader for text files (elastic#64108) [EPM] /packages/{package} endpoint to support upgrades (elastic#63629) [SIEM] New Platform Saved Objects Registration (elastic#64029) [Endpoint] Hook to handle events needing navigation via Router (elastic#63863) Fixed small issue in clone functionality (elastic#64085) [Endpoint]EMT-146: use ingest agent for status info (elastic#63921) [SIEM] Server NP Followup (elastic#64010) Register uiSettings on New Platform (elastic#64015) [Reporting] Integration polling config with client code (elastic#63754) [Docs]7.7 SIEM doc updates (elastic#63951) [SIEM] [Cases] Tags suggestions (elastic#63878) Include datasource UUID in agent config yaml, adjust overflow height of yaml view (elastic#64027) [DOCS] Add file size setting for Data Visualizer (elastic#64006) ...
Summary
https://github.com/elastic/endpoint-app-team/issues/146
Checklist
Delete any items that are not applicable to this PR.