Skip to content
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] Fix KQL/kuery for getting Fleet Server agent count #180650

Merged
merged 1 commit into from
Apr 12, 2024

Conversation

jen-huang
Copy link
Contributor

@jen-huang jen-huang commented Apr 11, 2024

Summary

Resolves #180427 - see issue for repro steps.

Code introduced in #179603 made the KQL to look up count of Fleet Server agents malformed. This is used to determine if the Add agent flyout should show "Add Fleet Server" instructions or show the normal instructions. When user has multiple Fleet Server policies on 8.13.2, the Add agent flyout will never show the normal instructions regardless of actual Fleet Server enrollment due to error response from the query.

Although the code was introduced in 8.13.2, the issue was "hidden" in 8.14.0 when strict KQL validation was turned off (#176806). Thus, this issue is only present in 8.13.2, 8.14 with the feature flag for strict validation turned on, or a future release if/when we turn strict validation back on.

This PR will be backported to 8.13 in case another patch release is cut. This fix adds parenthesis around the concatenation of multiple policy IDs:

image

@jen-huang jen-huang added release_note:fix Team:Fleet Team label for Observability Data Collection Fleet team v8.14.0 v8.13.3 labels Apr 11, 2024
@jen-huang jen-huang self-assigned this Apr 11, 2024
@jen-huang jen-huang requested a review from a team as a code owner April 11, 2024 22:24
@elasticmachine
Copy link
Contributor

Pinging @elastic/fleet (Team:Fleet)

@apmmachine
Copy link
Contributor

🤖 GitHub comments

Expand to view the GitHub comments

Just comment with:

  • /oblt-deploy : Deploy a Kibana instance using the Observability test environments.
  • /oblt-deploy-serverless : Deploy a serverless Kibana instance using the Observability test environments.
  • run elasticsearch-ci/docs : Re-trigger the docs validation. (use unformatted text in the comment!)

@kibana-ci
Copy link
Collaborator

💛 Build succeeded, but was flaky

Failed CI Steps

Test Failures

  • [job] [logs] FTR Configs #45 / dashboard app - group 2 dashboard filtering adding a filter that excludes all data "before all" hook for "filters on pie charts"

Metrics [docs]

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
fleet 158.9KB 158.9KB +2.0B

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

cc @jen-huang

@jen-huang jen-huang enabled auto-merge (squash) April 12, 2024 05:41
Copy link
Contributor

@juliaElastic juliaElastic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jen-huang jen-huang merged commit 382ad45 into elastic:main Apr 12, 2024
28 checks passed
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Apr 12, 2024
…80650)

## Summary

Resolves [elastic#180427](elastic#180427) -
see issue for repro steps.

Code introduced in elastic#179603 made
the KQL to look up count of Fleet Server agents malformed. This is used
to determine if the Add agent flyout should show "Add Fleet Server"
instructions or show the normal instructions. When user has multiple
Fleet Server policies on 8.13.2, the Add agent flyout will never show
the normal instructions regardless of actual Fleet Server enrollment due
to error response from the query.

Although the code was introduced in 8.13.2, the issue was "hidden" in
8.14.0 when strict KQL validation was turned off
(elastic#176806). Thus, this issue is
only present in 8.13.2, 8.14 with the feature flag for strict validation
turned on, or a future release if/when we turn strict validation back
on.

This PR will be backported to 8.13 in case another patch release is cut.
This fix adds parenthesis around the concatenation of multiple policy
IDs:

<img width="763" alt="image"
src="https://github.com/elastic/kibana/assets/1965714/99019ca2-e613-431f-8ff1-590116ba7511">

(cherry picked from commit 382ad45)
@kibanamachine
Copy link
Contributor

💚 All backports created successfully

Status Branch Result
8.13

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

@jen-huang jen-huang deleted the fix/fleet-server-policies branch April 12, 2024 17:14
kibanamachine added a commit that referenced this pull request Apr 12, 2024
…80650) (#180668)

# Backport

This will backport the following commits from `main` to `8.13`:
- [[Fleet] Fix KQL/kuery for getting Fleet Server agent count
(#180650)](#180650)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Jen
Huang","email":"its.jenetic@gmail.com"},"sourceCommit":{"committedDate":"2024-04-12T08:14:40Z","message":"[Fleet]
Fix KQL/kuery for getting Fleet Server agent count (#180650)\n\n##
Summary\r\n\r\nResolves
[#180427](#180427) -\r\nsee
issue for repro steps.\r\n\r\nCode introduced in
#179603 made\r\nthe KQL to look up
count of Fleet Server agents malformed. This is used\r\nto determine if
the Add agent flyout should show \"Add Fleet Server\"\r\ninstructions or
show the normal instructions. When user has multiple\r\nFleet Server
policies on 8.13.2, the Add agent flyout will never show\r\nthe normal
instructions regardless of actual Fleet Server enrollment due\r\nto
error response from the query.\r\n\r\nAlthough the code was introduced
in 8.13.2, the issue was \"hidden\" in\r\n8.14.0 when strict KQL
validation was turned
off\r\n(#176806). Thus, this issue
is\r\nonly present in 8.13.2, 8.14 with the feature flag for strict
validation\r\nturned on, or a future release if/when we turn strict
validation back\r\non.\r\n\r\nThis PR will be backported to 8.13 in case
another patch release is cut.\r\nThis fix adds parenthesis around the
concatenation of multiple policy\r\nIDs:\r\n\r\n<img width=\"763\"
alt=\"image\"\r\nsrc=\"https://github.com/elastic/kibana/assets/1965714/99019ca2-e613-431f-8ff1-590116ba7511\">","sha":"382ad457d38a4b2a6b10baa76484b8b5109e3c5d","branchLabelMapping":{"^v8.14.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","Team:Fleet","v8.14.0","v8.13.3"],"title":"[Fleet]
Fix KQL/kuery for getting Fleet Server agent
count","number":180650,"url":"#180650
Fix KQL/kuery for getting Fleet Server agent count (#180650)\n\n##
Summary\r\n\r\nResolves
[#180427](#180427) -\r\nsee
issue for repro steps.\r\n\r\nCode introduced in
#179603 made\r\nthe KQL to look up
count of Fleet Server agents malformed. This is used\r\nto determine if
the Add agent flyout should show \"Add Fleet Server\"\r\ninstructions or
show the normal instructions. When user has multiple\r\nFleet Server
policies on 8.13.2, the Add agent flyout will never show\r\nthe normal
instructions regardless of actual Fleet Server enrollment due\r\nto
error response from the query.\r\n\r\nAlthough the code was introduced
in 8.13.2, the issue was \"hidden\" in\r\n8.14.0 when strict KQL
validation was turned
off\r\n(#176806). Thus, this issue
is\r\nonly present in 8.13.2, 8.14 with the feature flag for strict
validation\r\nturned on, or a future release if/when we turn strict
validation back\r\non.\r\n\r\nThis PR will be backported to 8.13 in case
another patch release is cut.\r\nThis fix adds parenthesis around the
concatenation of multiple policy\r\nIDs:\r\n\r\n<img width=\"763\"
alt=\"image\"\r\nsrc=\"https://github.com/elastic/kibana/assets/1965714/99019ca2-e613-431f-8ff1-590116ba7511\">","sha":"382ad457d38a4b2a6b10baa76484b8b5109e3c5d"}},"sourceBranch":"main","suggestedTargetBranches":["8.13"],"targetPullRequestStates":[{"branch":"main","label":"v8.14.0","branchLabelMappingKey":"^v8.14.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/180650","number":180650,"mergeCommit":{"message":"[Fleet]
Fix KQL/kuery for getting Fleet Server agent count (#180650)\n\n##
Summary\r\n\r\nResolves
[#180427](#180427) -\r\nsee
issue for repro steps.\r\n\r\nCode introduced in
#179603 made\r\nthe KQL to look up
count of Fleet Server agents malformed. This is used\r\nto determine if
the Add agent flyout should show \"Add Fleet Server\"\r\ninstructions or
show the normal instructions. When user has multiple\r\nFleet Server
policies on 8.13.2, the Add agent flyout will never show\r\nthe normal
instructions regardless of actual Fleet Server enrollment due\r\nto
error response from the query.\r\n\r\nAlthough the code was introduced
in 8.13.2, the issue was \"hidden\" in\r\n8.14.0 when strict KQL
validation was turned
off\r\n(#176806). Thus, this issue
is\r\nonly present in 8.13.2, 8.14 with the feature flag for strict
validation\r\nturned on, or a future release if/when we turn strict
validation back\r\non.\r\n\r\nThis PR will be backported to 8.13 in case
another patch release is cut.\r\nThis fix adds parenthesis around the
concatenation of multiple policy\r\nIDs:\r\n\r\n<img width=\"763\"
alt=\"image\"\r\nsrc=\"https://github.com/elastic/kibana/assets/1965714/99019ca2-e613-431f-8ff1-590116ba7511\">","sha":"382ad457d38a4b2a6b10baa76484b8b5109e3c5d"}},{"branch":"8.13","label":"v8.13.3","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Jen Huang <its.jenetic@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release_note:fix Team:Fleet Team label for Observability Data Collection Fleet team v8.13.3 v8.14.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Fleet] Unable to open Add agent flyout with 2 Fleet Server policies on Cloud
6 participants