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] Expose agent logging level in agent policy settings #180607

Merged
merged 12 commits into from
Apr 15, 2024

Conversation

criamico
Copy link
Contributor

@criamico criamico commented Apr 11, 2024

Closes #158861

Summary

Expose agent logging level in agent policy settings.
The new setting is added via the new settings framework and will show up under "advanced settings". It's currently hidden until the agent supports it.

Testing

Enable the settings config: #180597 (comment)

  • Go to the agent policy settings form
  • Under advanced settings there is a new dropdown "Agent logging level". Choose a value and save the policy
  • The new value should be retained after saving
  • Go to the agent policies tab and select action "View policy"
  • The new field should be visible under agent.logging.level
Screenshots

Screenshot 2024-04-12 at 16 21 46
Screenshot 2024-04-12 at 16 21 52
Screenshot 2024-04-12 at 16 22 28
Screenshot 2024-04-12 at 16 27 48

Checklist

@criamico criamico changed the title 158861 logging level per policy [Fleet] Expose agent logging level in agent policy settings Apr 11, 2024
@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!)

@criamico criamico self-assigned this Apr 11, 2024
@criamico criamico added Team:Fleet Team label for Observability Data Collection Fleet team release_note:skip Skip the PR/issue when compiling release notes v8.14.0 labels Apr 11, 2024
@criamico
Copy link
Contributor Author

@elasticmachine merge upstream

@@ -63,15 +63,13 @@ interface Props {
agentPolicy: Partial<NewAgentPolicy | AgentPolicy>;
updateAgentPolicy: (u: Partial<NewAgentPolicy | AgentPolicy>) => void;
validation: ValidationResults;
isEditing?: boolean;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This field was not used anymore so I removed it

@@ -35,8 +35,6 @@ interface Props {
withSysMonitoring: boolean;
updateSysMonitoring: (newValue: boolean) => void;
validation: ValidationResults;
isEditing?: boolean;
onDelete?: () => void;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same as above, the linter catched unused props

@criamico criamico marked this pull request as ready for review April 12, 2024 14:35
@criamico criamico requested a review from a team as a code owner April 12, 2024 14:35
@elasticmachine
Copy link
Contributor

Pinging @elastic/fleet (Team:Fleet)

@criamico
Copy link
Contributor Author

@elasticmachine merge upstream

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

@criamico criamico enabled auto-merge (squash) April 15, 2024 09:31
@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
fleet 1.3MB 1.3MB +598.0B

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.7KB 159.0KB +248.0B

History

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

cc @criamico

@criamico criamico merged commit f1abe4f into elastic:main Apr 15, 2024
18 checks passed
@kibanamachine kibanamachine added the backport:skip This commit does not require backporting label Apr 15, 2024
criamico added a commit that referenced this pull request Apr 17, 2024
## Summary
Part of #158861
#180607 added a new log level
selector in Agent Policy settings. However there were some small bugs
with it. This PR addresses all of them:

- Extra dot in copy text
- A broken link was displayed - Made this link optional
- When clicking "Cancel", all the other fields on the page reset back to
their original values but the log level doesn't. The reason is the no
default was set for the select

### Before
![image
(19)](https://github.com/elastic/kibana/assets/16084106/bc310642-5425-4413-8cfa-aff03557f2eb)

### After
![Screenshot 2024-04-17 at 10 50
04](https://github.com/elastic/kibana/assets/16084106/30fc6797-7297-496e-9ec7-209e04a44bba)


### Testing 
- Enable `hidden: false`
[here](https://github.com/elastic/kibana/blob/bc9cd862f04430f4e50e7da2a11f16bc80756e9c/x-pack/plugins/fleet/common/settings/agent_policy_settings.ts#L133)
- Change the log level and then click "cancel" on the bottom of the
page, it should reset back to the default value ("info" if the policy is
new, the previous saved value if the policy already had this value set)
- No extra dot and link should be visible
jen-huang added a commit that referenced this pull request May 16, 2024
‼️ Should be reverted if
elastic/elastic-agent#4747 does not make
8.15.0.

## Summary

Resolves #180778 

This PR allows agent log level to be reset back to the level set on its
policy (or if not set, simply the default agent level, see
elastic/elastic-agent#3090).

To achieve this, this PR:
- Allows `null` to be passed for the log level settings action, i.e.:

```
POST kbn:/api/fleet/agents/<AGENT_ID>/actions
{"action":{"type":"SETTINGS","data":{"log_level": null}}}
```
- Enables the agent policy log level setting implemented in
#180607
- Always show `Apply changes` on the agent details > Logs tab
- For agents >= 8.15.0, always show `Reset to policy` on the agent
details > Logs tab
- Ensures both buttons are disabled if user does not have access to
write to agents

<img width="1254" alt="image"
src="https://github.com/elastic/kibana/assets/1965714/bcdf763e-2053-4071-9aa8-8bcb57b8fee1">

<img width="1267" alt="image"
src="https://github.com/elastic/kibana/assets/1965714/182ac54d-d5ad-435f-9376-70bb24f288f9">

### Caveats
1. The reported agent log level is not accurate if agent is using the
level from its policy and does not have a log level set on its own level
(elastic/elastic-agent#4747), so the initial
selection on the agent log level could be wrong
2. We have no way to tell where the log level came from
(elastic/elastic-agent#4748), so that's why
`Apply changes` and `Reset to policy` are always shown

### Testing
Use the latest `8.15.0-SNAPSHOT` for agents or fleet server to test this
change

### Checklist

Delete any items that are not applicable to this PR.

- [x] Any text added follows [EUI's writing
guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses
sentence case text and includes [i18n
support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)
- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting release_note:skip Skip the PR/issue when compiling release notes Team:Fleet Team label for Observability Data Collection Fleet team v8.14.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Fleet] Support changing the default log level per policy (or globally)
6 participants