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

Change filtering rules behavior #48

Merged

Conversation

adejanovski
Copy link
Collaborator

This PR changes the way metrics filtering rules are applied. It mimics how firewall rules are applied by iptables, where the last rule wins.
It allows to deny a whole group of metrics and then allow only specific ones, without affecting other metric groups.
As this is a breaking change, the version number was bumped accordingly.

Filtering rules now mimic the behavior of iptables firewall rules. The last applicable rule wins.
Copy link
Contributor

@emerkle826 emerkle826 left a comment

Choose a reason for hiding this comment

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

Just a couple of nit-pick suggestions that don't have to be addressed. Approved as-is or with the minor changes made.

Comment on lines 106 to 107
logger.info("Metric {}", name);
logger.info(">>>>>> Applying rule {}", lastRule.get());
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe make these DEBUG level logs. I don't have a very strong opinion here, so if you still want them to be INFO, I could be easily convinced.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

You're right, I moved them to debug level. I also enclosed the block under a if (logging.isDebugLevel()) { to avoid the additional calls when we're at INFO level.

Comment on lines +43 to +45
Assert.assertFalse(FilteringRule.applyFilters("org.apache.cassandra.metrics.metric1", Arrays.asList(unaffectedByDenyRule, firstRule, secondRule, thirdRule)).isAllowRule);
Assert.assertTrue(FilteringRule.applyFilters("org.apache.cassandra.metrics.metric2", Arrays.asList(unaffectedByDenyRule, firstRule, secondRule, thirdRule)).isAllowRule);
Assert.assertTrue(FilteringRule.applyFilters("org.apache.cassandra.whatever.metric3", Arrays.asList(unaffectedByDenyRule, firstRule, secondRule, thirdRule)).isAllowRule);
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: You could extract the List of rules once, and use it in each of the assert statements, as opposed to using Arrays.asList each time. But this is a test, so the efficiency is not really a big deal.

@adejanovski adejanovski force-pushed the alex/last-filtering-rule-wins branch from 0219252 to aa52a78 Compare October 21, 2021 12:12
@adejanovski adejanovski merged commit 66e151c into datastax:master Oct 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants