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

Sidecar support for tags and collectors with multiple configurations #13433

Merged
merged 100 commits into from
Oct 19, 2022

Conversation

gally47
Copy link
Contributor

@gally47 gally47 commented Sep 13, 2022

Description

This PR adds two features to the Sidecar:

  • Automated configuration assignment through tags
  • Lifting the limit of running only one configuration per collector

Both features need Sidecar 1.3.x or later.
Older sidecars are still supported, but will only pick up the first assigned configuration.

For implementation details see https://github.com/Graylog2/graylog-plugin-enterprise/issues/3956

To improve the UX of Sidecars Configurations Assignment and Tags in this PR we:

  • used buttons instead of links to distinguish between the actions and filters
  • used modal instead popover to display a clear list of configuration assignments
  • made the configuration assignments list support multi select
  • displayed tags in configuration assignments list
  • displayed assigned configurations in collectors administration page
  • added a one click solution to open configuration assignment modal
  • added a configuration tags field in collector configuration create/edit form page

Fixes https://github.com/Graylog2/graylog-plugin-enterprise/issues/3956
Fixes #10454

@gally47 gally47 changed the title Sidecars Configurations Assignment UX improvements #13362 Sidecars Configurations Assignment (UX improvements) #13362 Sep 13, 2022
mpfz0r and others added 12 commits September 13, 2022 18:19
…#13349)

* Add support for multiple configurations per collector

This will need a new sidcar release.
Old sidecars are still supported with just a single configuration.

* Use Java 9 Lists

* Add support for ${sidecar.spoolDir} variable

* Fix tests

* Revert "Add support for multiple configurations per collector"

This reverts commit 0a17743.

* Use ${sidecar.spoolDir} for fresh collector templates

And add explanation to the UI

* make eslint happy

* convert tags to Set and fix Autovalue

* Support configuration_id in CollectorStatus

Co-authored-by: Othello Maurer <[email protected]>
* add assignedFromTags property to assignment

* Don't fail for unknown properties on NodeDetails

This makes it easier to extend the sidecar
in the future

* Create sidecar config assignments based on tags

This is a first naive approach.
Every registration request will rebuild the assignments
and this is probably too expensive.

* fix test

* Fix more Tests

* Fine grained EtagService

Use three different caches for configs, collectors and assignments.

* Add Etag caching for UpdateRegistration results

The response to the registration PUT request contains
configuration assignments, which can be cached as well.

This requires us to invalidate the sidecar etag cache in more
situations:
 - Configration assignments
 - User triggered collector actions (stop, start, restart)

* Cleanup old assignment caching commit

* optimize

* fix after merge

* replace deprecated notempty annotation

* cache assignments per sidecar id

using just the md5 of an assignment result might
leed to sidecars missing out on updates.
An assignment is always meant for a single sidecar, caching the entire
assignment over all sidecars is wrong.

A per sidecar cache entry allows more fine grained cache invalidations.

Bump the cacheMaxSize to 5000 entries, which is a more meaningful
number, considered that this might have to hold all sidecars.

* Refactor sidecar register() call.

Only update the tagged assignments when we miss the cache.

* change cache naming

* more refactoring

* improve cache invalidation

* use fancy java

Co-authored-by: Othello Maurer <[email protected]>

* Add more cases for tag invalidation and fix tests

* add tags to Config summary

* Generate EntityTags with a better hash algorithm

As @thll noticed, Object.hashCode() is prone to having collisions

* Handle manual assignments via API

* rename

* Make tags available as config variables.

This allows configs to be written with conditionals.
E.g.:

```
<#if sidecar.tags.apache??>
 - /var/log/apache/*.log
</#if>
```

* dont lose tags on UI configuration updates

Co-authored-by: Othello Maurer <[email protected]>
* Only assign tagged configs that match the OS

* rename test

* add tests for SidecarService.updateTaggedConfigurationAssignments()

* add tests for SidecarService.applyManualAssignments()
* Fix cache invalidation for collector actions

The registration cache was using the sidecar "_id",
while the ActionService was invalidating the sidecar "node_id".

Change the entire cache to using the "node_id"

* Rename parameter from sidecarId to sidecarNodeId

Co-authored-by: Othello Maurer <[email protected]>
* Invalidate registration cache only for affected sidecars

* Use node-id for cache invalidation

The cache key has been changed since this PR has been started.

* Consider OS for cache invalidation

Also use symmetric difference of tags to further reduce
unnecessary invalidations

* Invalidate less when creating new configs
thll and others added 14 commits September 29, 2022 18:57
…#13349)

* Add support for multiple configurations per collector

This will need a new sidcar release.
Old sidecars are still supported with just a single configuration.

* Use Java 9 Lists

* Add support for ${sidecar.spoolDir} variable

* Fix tests

* Revert "Add support for multiple configurations per collector"

This reverts commit 0a17743.

* Use ${sidecar.spoolDir} for fresh collector templates

And add explanation to the UI

* make eslint happy

* convert tags to Set and fix Autovalue

* Support configuration_id in CollectorStatus

Co-authored-by: Othello Maurer <[email protected]>
* add assignedFromTags property to assignment

* Don't fail for unknown properties on NodeDetails

This makes it easier to extend the sidecar
in the future

* Create sidecar config assignments based on tags

This is a first naive approach.
Every registration request will rebuild the assignments
and this is probably too expensive.

* fix test

* Fix more Tests

* Fine grained EtagService

Use three different caches for configs, collectors and assignments.

* Add Etag caching for UpdateRegistration results

The response to the registration PUT request contains
configuration assignments, which can be cached as well.

This requires us to invalidate the sidecar etag cache in more
situations:
 - Configration assignments
 - User triggered collector actions (stop, start, restart)

* Cleanup old assignment caching commit

* optimize

* fix after merge

* replace deprecated notempty annotation

* cache assignments per sidecar id

using just the md5 of an assignment result might
leed to sidecars missing out on updates.
An assignment is always meant for a single sidecar, caching the entire
assignment over all sidecars is wrong.

A per sidecar cache entry allows more fine grained cache invalidations.

Bump the cacheMaxSize to 5000 entries, which is a more meaningful
number, considered that this might have to hold all sidecars.

* Refactor sidecar register() call.

Only update the tagged assignments when we miss the cache.

* change cache naming

* more refactoring

* improve cache invalidation

* use fancy java

Co-authored-by: Othello Maurer <[email protected]>

* Add more cases for tag invalidation and fix tests

* add tags to Config summary

* Generate EntityTags with a better hash algorithm

As @thll noticed, Object.hashCode() is prone to having collisions

* Handle manual assignments via API

* rename

* Make tags available as config variables.

This allows configs to be written with conditionals.
E.g.:

```
<#if sidecar.tags.apache??>
 - /var/log/apache/*.log
</#if>
```

* dont lose tags on UI configuration updates

Co-authored-by: Othello Maurer <[email protected]>
@gally47 gally47 requested a review from ousmaneo October 17, 2022 13:26
Copy link
Contributor

@ousmaneo ousmaneo left a comment

Choose a reason for hiding this comment

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

I have some small changes. Other than that we are good to go 👍

@gally47 gally47 requested a review from ousmaneo October 18, 2022 13:58
Copy link
Contributor

@ousmaneo ousmaneo left a comment

Choose a reason for hiding this comment

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

Looks good to me !
We still have some java code in this PR if that part is already merged we should consider rebasing so that the only the frontend code is in this PR.

Thank you !

@mpfz0r mpfz0r changed the title Sidecars Configurations Assignment and Tags (UX improvements) #13362 Sidecar support for tags and collectors with multiple configurations Oct 19, 2022
Copy link
Contributor

@mnin mnin left a comment

Choose a reason for hiding this comment

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

LGTM

@gael-donat
Copy link

Hey guys, great to see this issue is merged; when can we expect an update for the graylog-sidecar binaries ? days ? weeks?

thanks !

@mpfz0r
Copy link
Contributor

mpfz0r commented Oct 19, 2022

@gael-donat we are planning to release a 5.0 beta / Sidecar 1.3 beta next week.

@gael-donat
Copy link

gael-donat commented Oct 19, 2022

Ok thanks. Since the LDAP group mapping is not a free feature anymore, we still are on graylog3. I assume the configuration will not be available if we stay on graylog3 ?

@mpfz0r
Copy link
Contributor

mpfz0r commented Oct 19, 2022

Yeah, sorry. that's not gonna happen. We are not even actively maintaining 3.x anymore. (Patching Log4Shell was an exception)

@gael-donat
Copy link

gael-donat commented Oct 19, 2022

that's understandable.

Shame we lost the tag feature switch from collector to sidecar tho.. but great to see it added again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

"Default" configuration for Sidecar Log Collector
6 participants