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
Limit dynamic counters #1743
Limit dynamic counters #1743
Conversation
Iterate through the hashtable items requires to grab the mutex (stats_lock). Signed-off-by: Laszlo Budai <laszlo.budai@balabit.com>
Signed-off-by: Laszlo Budai <laszlo.budai@balabit.com>
Signed-off-by: Laszlo Budai <laszlo.budai@balabit.com>
Build SUCCESS, the tests were executed on test branch: master and test suite: functions |
5fe0a15
to
e453bc4
Compare
Build SUCCESS, the tests were executed on test branch: master and test suite: functions |
e453bc4
to
724cb87
Compare
Build SUCCESS, the tests were executed on test branch: master and test suite: functions |
return NULL; | ||
sc = stats_cluster_dynamic_new(sc_key); | ||
_insert_cluster(sc); | ||
if ( !stats_check_dynamic_clusters_limit(_number_of_dynamic_clusters())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unnecessary space here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm... we have a tool that checks style and blocks merge until we fix format issues.
So I wouldn't fix it here (fixing astyle would be better as currently we don't check this kind of format issue and it is possible that there are other parts of the code which is affected by the same problem).
Looks good to me. |
lib/stats/stats-registry.c
Outdated
static StatsClusterContainer stats_cluster_container; | ||
|
||
static guint | ||
_number_of_dynamic_clusters() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing void in the parameter list
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
lib/stats/stats-registry.c
Outdated
{ | ||
msg_warning("Number of dynamic cluster limit has been reached.", | ||
evt_tag_int("allowed clusters", stats_number_of_dynamic_clusters_limit())); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use underscore in the tag name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
Users can set this via the `stats_max_dynamics` global option. This is not the number of counters but clusters which means that users can limit the number of different dynamic value occurrences (as each cluster has a pre-allocated array of counters). Note that after reload, when users set a lower limit, they have to wait for stat-freq-timer being expired to remove the previously allocated dynamic clusters. Dynamic values are * source host (from stats level 2) * sender host (host from) (from stats level 3) * program (from stats level 3) The following example contains 6 different dynamic values (a sender, a host and four different programs): src.sender;;localhost;d;processed;4 src.sender;;localhost;d;stamp;1509121934 src.program;;P-18069;d;processed;1 src.program;;P-18069;d;stamp;1509121933 src.program;;P-21491;d;processed;1 src.program;;P-21491;d;stamp;1509121934 src.program;;P-9774;d;processed;1 src.program;;P-9774;d;stamp;1509121919 src.program;;P-14737;d;processed;1 src.program;;P-14737;d;stamp;1509121931 src.host;;localhost;d;processed;4 src.host;;localhost;d;stamp;1509121934 Signed-off-by: Laszlo Budai <laszlo.budai@balabit.com>
724cb87
to
e9d47ab
Compare
Build SUCCESS, the tests were executed on test branch: master and test suite: functions |
@@ -264,6 +264,15 @@ stats_cluster_new(const StatsClusterKey *key) | |||
return self; | |||
} | |||
|
|||
StatsCluster * | |||
stats_cluster_dynamic_new(const StatsClusterKey *key) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I rather use a parameter for the constructor.
Based on the signature of this function it seems that we have two different object for dynamic and static clusters, while they differs only in one attribute.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We talked about this IRL, here is my short answer: I think dynamic cluster represents a different (sub)type (it behaves differently than the non-dynamic clusters) and we already provide a different API for dynamic counters (note: there is no dynamic counter, but dynamic cluster, what makes a counter dynamic is that the counter is registered with one of the _dynamic
function which track the counter inside a dynamic cluster).
So I think this is not only a simple attribute: this is a kind of type selector and we actually make behavioral decisions based on the value of this attribute.
|
||
g_assert(sc->dynamic == dynamic); | ||
} | ||
if (!sc) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In what circumstances can sc
be falsy here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, I see, in the next commit it can be NULL
.
@@ -931,6 +932,7 @@ stat_option | |||
: KW_STATS_FREQ '(' nonnegative_integer ')' { last_stats_options->log_freq = $3; } | |||
| KW_STATS_LEVEL '(' nonnegative_integer ')' { last_stats_options->level = $3; } | |||
| KW_STATS_LIFETIME '(' positive_integer ')' { last_stats_options->lifetime = $3; } | |||
| KW_STATS_MAX_DYNAMIC '(' nonnegative_integer ')' { last_stats_options->max_dynamic = $3; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the default value of this option? What will be on the documentation? As I see:
>0
means the limit of the dynamic stat clusters0
means disable storing dynamic stat clusters-1
means there is no limit - but it is not a valid value here...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-1 is cannot be set by users in the config, it is the default value, so when the option is not set then number of dynamic counters are unlimited as before.
@fekete-robert : some documentation related notes
|
Thanks, I'll add it to our todo list.
…On Wed, Nov 8, 2017 at 1:50 PM, Budai Laszlo ***@***.***> wrote:
@fekete-robert <https://github.com/fekete-robert> : some documentation
related notes
- @presidento <https://github.com/presidento> pointed out that the
default value (-1) cannot be set by users, so if someone don't need this
feature(->don't want to limit the number of dynamic counters), he or she
has to remove the option from the config (and this is intentional from my
part)
- reload won't clear dynamic counters (hin: lifetime, stats-freq)
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1743 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ADwKbcRH4HsNAm9kQKEMmZU7Dt5Cqj0Gks5s0aN_gaJpZM4QJiG4>
.
|
Add config option for limiting dynamic counters
Users can limit the number of registered dynamic counters via the
stats_max_dynamics
global option.This is not a limit for the number of counters but for the number of clusters which means that users
can limit the number of different dynamic value occurrences (as each
cluster has a pre-allocated array of counters).
Note that after reload, when users set a lower limit,
they have to wait for stat-freq-timer being expired to remove the
previously allocated dynamic clusters.
Dynamic values are
By default this change is backward compatible: if someone not uses this feature, number of dynamic counters won't be limited.
It is possible to disable dynamic counters by setting the limit to 0.
The following example contains 6 different dynamic values (a sender, a host and four different programs):
Questions to reviewers: