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] Add a new keep_monitoring_alive flag to kibana.yml #168629

Closed
3 tasks done
kpollich opened this issue Oct 11, 2023 · 9 comments
Closed
3 tasks done

[Fleet] Add a new keep_monitoring_alive flag to kibana.yml #168629

kpollich opened this issue Oct 11, 2023 · 9 comments
Assignees
Labels
Team:Fleet Team label for Observability Data Collection Fleet team

Comments

@kpollich
Copy link
Member

kpollich commented Oct 11, 2023

Ref elastic/elastic-agent#2734

The agent team is shipping some work soon to automatically shut down the monitoring server if metrics are disabled. However, in cloud we want to enable to keep the monitoring server alive even if nothing's being collected. To support this use case, we need to add a new flag to kibana.yml so that Cloud policies can opt into this behavior.

  • Add a keep_monitoring_alive flag to Fleet's config schema for preconfigured agent policies here
  • Update Fleet's agent policy rendering logic here to generate a monitoring configuration with { enabled : true, logs: false, metrics: false } when keep_monitoring_alive is true on the policy object
  • Update the preconfigured cloud agent policy to pass this flag as true
@kpollich kpollich added the Team:Fleet Team label for Observability Data Collection Fleet team label Oct 11, 2023
@elasticmachine
Copy link
Contributor

Pinging @elastic/fleet (Team:Fleet)

@cmacknz
Copy link
Member

cmacknz commented Oct 11, 2023

I think we should just change the agent configuration used in cloud instead of doing this in Kibana. See elastic/elastic-agent#2734 (comment)

What we really want on the Fleet side of this is to expose all of the agent.monitoring configurations in the Fleet UI, but I don't think that is blocking for us because the override API can be used to change those settings today.

@michalpristas
Copy link

michalpristas commented Oct 12, 2023

changing agent cloud config is not that simple as it seems as logic there which translate what is defined in a template and what gets to agent does not have a notion of flags we use.

the thing @kpollich mentioned will result in what you are requesting. using additional flag they will generate config we expect. we will not see additional flag in our config and our logic stays the same as defined in elastic/elastic-agent#3584

@cmacknz
Copy link
Member

cmacknz commented Oct 12, 2023

Thanks, we can't change the default behaviour of elastic/elastic-agent#3584 or elastic/elastic-agent#2509 without the change here to ensure cloud keeps working as expected.

I'll mark this as blocking those two issues and we can figure out when to prioritize this.

@kpollich
Copy link
Member Author

This + the necessary change in the preconfigured cloud policy would be pretty low effort for the Fleet & Integrations team to implement. We could turn around pretty quickly on this to unblock if needed.

@jlind23
Copy link
Contributor

jlind23 commented Oct 12, 2023

@kpollich just pulled it in the current sprint to make it happened. Happy to have you working on it or ask someone else, just let me know.

@kpollich
Copy link
Member Author

I can get this done late this week or early next.

@kpollich kpollich self-assigned this Oct 12, 2023
kpollich added a commit that referenced this issue Oct 16, 2023
## Summary

Ref #168629

Adds a new `keep_monitoring_alive` flag to agent policies that allows
agent environments to keep the monitoring server if they choose.

> [!note]
> `monitoring_enabled: []` needs to be explicitly set for this flag to
be honored. If `monitoring_enabled` is omitted entirely, Fleet defaults
to enabling monitoring for logs and metrics.

## To test

Create a preconfigured policy where logs/metrics monitoring is
explicitly disabled and include this new flag e.g.

```yml
xpack.fleet.agentPolicies:
  - name: Test preconfigured policy
    id: test-preconfigured-policy
    package_policies: []
    monitoring_enabled: []
    keep_monitoring_alive: true
```

Then, run Kibana and verify the `monitoring` block in the full agent
policy has monitoring enabled, but logs/metrics as disabled, e.g.


![image](https://github.com/elastic/kibana/assets/6766512/f5b205ad-96f0-4e88-967a-43546bf2bf84)

You can also verify the need for `monitoring_enabled: []` by creating
another preconfigured policy e.g.

```yml
- name: Test preconfigured policy 2
    id: test-preconfigured-policy-2
    package_policies: []
    keep_monitoring_alive: true
```

This will generate a policy e.g. 


![image](https://github.com/elastic/kibana/assets/6766512/013b0381-b605-49a4-8819-3dec713f1e1f)

All other combinations of enabling monitoring for logs/metrics should
also generate the policies as expected. If you want to verify every
combination manually:

```yml
xpack.fleet.agentPolicies: 
  - name: Test preconfigured policy
    id: test-preconfigured-policy
    package_policies: []
    monitoring_enabled: []
    keep_monitoring_alive: true
  - name: Test preconfigured policy 2
    id: test-preconfigured-policy-2
    package_policies: []
    keep_monitoring_alive: true
  - name: Test preconfigured policy 3
    id: test-preconfigured-policy-3
    package_policies: []
    monitoring_enabled: ['logs']
  - name: Test preconfigured policy 4
    id: test-preconfigured-policy-4
    package_policies: []
    monitoring_enabled: ['metrics']
  - name: Test preconfigured policy 5
    id: test-preconfigured-policy-5
    package_policies: []
    monitoring_enabled: ['logs', 'metrics']
```

---------

Co-authored-by: kibanamachine <[email protected]>
dej611 pushed a commit to dej611/kibana that referenced this issue Oct 17, 2023
…#168865)

## Summary

Ref elastic#168629

Adds a new `keep_monitoring_alive` flag to agent policies that allows
agent environments to keep the monitoring server if they choose.

> [!note]
> `monitoring_enabled: []` needs to be explicitly set for this flag to
be honored. If `monitoring_enabled` is omitted entirely, Fleet defaults
to enabling monitoring for logs and metrics.

## To test

Create a preconfigured policy where logs/metrics monitoring is
explicitly disabled and include this new flag e.g.

```yml
xpack.fleet.agentPolicies:
  - name: Test preconfigured policy
    id: test-preconfigured-policy
    package_policies: []
    monitoring_enabled: []
    keep_monitoring_alive: true
```

Then, run Kibana and verify the `monitoring` block in the full agent
policy has monitoring enabled, but logs/metrics as disabled, e.g.


![image](https://github.com/elastic/kibana/assets/6766512/f5b205ad-96f0-4e88-967a-43546bf2bf84)

You can also verify the need for `monitoring_enabled: []` by creating
another preconfigured policy e.g.

```yml
- name: Test preconfigured policy 2
    id: test-preconfigured-policy-2
    package_policies: []
    keep_monitoring_alive: true
```

This will generate a policy e.g. 


![image](https://github.com/elastic/kibana/assets/6766512/013b0381-b605-49a4-8819-3dec713f1e1f)

All other combinations of enabling monitoring for logs/metrics should
also generate the policies as expected. If you want to verify every
combination manually:

```yml
xpack.fleet.agentPolicies: 
  - name: Test preconfigured policy
    id: test-preconfigured-policy
    package_policies: []
    monitoring_enabled: []
    keep_monitoring_alive: true
  - name: Test preconfigured policy 2
    id: test-preconfigured-policy-2
    package_policies: []
    keep_monitoring_alive: true
  - name: Test preconfigured policy 3
    id: test-preconfigured-policy-3
    package_policies: []
    monitoring_enabled: ['logs']
  - name: Test preconfigured policy 4
    id: test-preconfigured-policy-4
    package_policies: []
    monitoring_enabled: ['metrics']
  - name: Test preconfigured policy 5
    id: test-preconfigured-policy-5
    package_policies: []
    monitoring_enabled: ['logs', 'metrics']
```

---------

Co-authored-by: kibanamachine <[email protected]>
@michalpristas
Copy link

@kpollich can we close?

@kpollich
Copy link
Member Author

Yep thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Team:Fleet Team label for Observability Data Collection Fleet team
Projects
None yet
Development

No branches or pull requests

5 participants