-
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
Fleet Usage telemetry extension #145353
Merged
juliaElastic
merged 16 commits into
elastic:main
from
juliaElastic:feat/extend-fleet-telemetry
Nov 23, 2022
Merged
Fleet Usage telemetry extension #145353
Changes from 8 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
b34f4d4
changes to fleet usage task, agent version telemetry
juliaElastic aa0196d
added fleet server config
juliaElastic b92d5f1
Merge branch 'main' into feat/extend-fleet-telemetry
kibanamachine 25e1e09
added agent policies telemetry
juliaElastic 8d54d36
added last checkin status
juliaElastic cefd848
added last checkin status - fix
juliaElastic e110da3
Merge branch 'main' into feat/extend-fleet-telemetry
kibanamachine d95598a
added last checkin status for last 1h
juliaElastic 4c5f29e
added abortController, apm span
juliaElastic f12a872
Merge branch 'main' into feat/extend-fleet-telemetry
kibanamachine b29541b
removed fleet server hosts info
juliaElastic 6c6de57
removed host port from policy config, added try catch
juliaElastic 43788cb
fix checks
juliaElastic 99f5a61
integration test, removed last1h checkin errors, added agents per policy
juliaElastic 1fa218b
setting registry to localhost to prevent synthetics from installing
juliaElastic 241a5e9
whitelist fleet server config to only server limits, timeouts and run…
juliaElastic 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import type { SavedObjectsClient, ElasticsearchClient } from '@kbn/core/server'; | ||
|
||
import { AGENT_POLICY_INDEX } from '../../common'; | ||
import { ES_SEARCH_LIMIT } from '../../common/constants'; | ||
|
||
export const getAgentPoliciesUsage = async ( | ||
soClient?: SavedObjectsClient, | ||
esClient?: ElasticsearchClient | ||
): Promise<any> => { | ||
if (!soClient || !esClient) { | ||
return {}; | ||
} | ||
|
||
const res = await esClient.search({ | ||
index: AGENT_POLICY_INDEX, | ||
size: ES_SEARCH_LIMIT, | ||
track_total_hits: true, | ||
rest_total_hits_as_int: true, | ||
}); | ||
|
||
const agentPolicies = res.hits.hits; | ||
|
||
const outputTypes = new Set<string>(); | ||
agentPolicies.forEach((item) => { | ||
const source = (item._source as any) ?? {}; | ||
Object.keys(source.data.outputs).forEach((output) => { | ||
outputTypes.add(source.data.outputs[output].type); | ||
}); | ||
}); | ||
|
||
return { | ||
count: res.hits.total, | ||
output_types: Array.from(outputTypes), | ||
}; | ||
}; |
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
Oops, something went wrong.
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.
it will be a great improvements to write an integration tests for these collectors(I think it's doable with a jest integration test).
Maybe this can be done in a follow up issue if it's too much work.
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'll look into adding integration tests.
I think I might create a separate pr for the agent logs collector too, since that depends on ES change.
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.
Added integration test.
I wonder how could we improve the integration test framework, it seems rather slow to start up an ES instance for every test. And it is slow to test changes locally too.
Raised a separate issue for improvements: #145988