-
Notifications
You must be signed in to change notification settings - Fork 8.5k
Fix agent config indicator when applied through fleet integration #131820
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
Changes from 1 commit
c92ba74
bab0ced
7329fe0
d50d06c
abae232
29efe60
44abd38
e62bbc2
74bd08c
8b76c61
57a3627
560c644
0aa86ff
1cea1ea
4f5b9de
e547c6f
4757af5
29205d6
b1f8d4e
5737fc0
e19ec2a
06171e3
d9b00bf
758d67a
e918b75
fc5fa66
9445e65
98f4ee4
f2cebe3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| /* | ||
| * 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 { termQuery, rangeQuery } from '@kbn/observability-plugin/server'; | ||
| import { keyBy } from 'lodash'; | ||
| import datemath from '@kbn/datemath'; | ||
| import { METRICSET_NAME } from '../../../../common/elasticsearch_fieldnames'; | ||
| import { Setup } from '../../../lib/helpers/setup_request'; | ||
|
|
||
| export async function getConfigAppliedToAgentsThroughFleet({ | ||
| setup, | ||
| }: { | ||
| setup: Setup; | ||
| }) { | ||
| const { internalClient, indices } = setup; | ||
|
|
||
| const params = { | ||
| index: indices.metric, | ||
| size: 200, | ||
| body: { | ||
| query: { | ||
| bool: { | ||
| filter: [ | ||
| ...termQuery(METRICSET_NAME, 'agent_config'), | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm curious if this is the best way. Given it's a single
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah we also use it for a list of agent configurations. That means we cannot set
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Makes sense, will do them in parallel
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done in 1cea1ea |
||
| ...rangeQuery( | ||
| datemath.parse('now-15m')!.valueOf(), | ||
| datemath.parse('now')!.valueOf() | ||
| ), | ||
| ], | ||
| }, | ||
| }, | ||
| aggs: { | ||
| config_by_etag: { | ||
| terms: { | ||
| field: 'labels.etag', | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. and should
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated in e547c6f |
||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| }; | ||
|
|
||
| const response = await internalClient.search( | ||
| 'get_config_applied_to_agent_through_fleet', | ||
| params | ||
| ); | ||
|
|
||
| return keyBy(response.aggregations?.config_by_etag.buckets, 'key'); | ||
| } | ||
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.
why 200? should it be configurable?
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.
actually looks like size should be 0?
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.
That was meant for the aggregation. What do you think the size should be? Config list returns 200.
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.
Updated in e547c6f