-
Notifications
You must be signed in to change notification settings - Fork 166
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
new(plugin_api): add plugin metrics support #1828
new(plugin_api): add plugin metrics support #1828
Conversation
/milestone 0.17.0 |
New proposal @mrgian: A bummer that the plugin system is so restrictive, but let's focus on this PR. Why don't we just define a vanilla struct for the plugin metrics and then return that struct via the That way we don't need any of the redefinitions and it would be very similar approach to how we retrieve the libsinsp state metrics, for instance checkout the |
@incertum Keep in mind that the main point of this feature is to let plugins define their own custom metrics. |
Oh I somehow thought we wanted just some fixed wrapper metrics like event counts, drops etc since that is what we exposed in Falco before. Anyways given the plugin system is how it is, seems that we need to keep re-defining things. Just like I called out that it is not a nice approach to needing to redefine the event types when writing a plugin for the syscalls source ... |
08274bc
to
caa5c41
Compare
caa5c41
to
555092b
Compare
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.
/approve
LGTM label has been added. Git tree hash: f1cb57941205278b29711a490fde0ac29f8dfa59
|
Windows CI is failing plus there is now a conflict :) Care to take a look? Thanks! |
555092b
to
09a4324
Compare
@FedeDP Can you re-run the CI? The Windows build should be ok now (I hope). Thanks :) |
/cc @jasondellaluce |
09a4324
to
846da48
Compare
Signed-off-by: Gianmatteo Palmieri <[email protected]>
Signed-off-by: Gianmatteo Palmieri <[email protected]>
Signed-off-by: Gianmatteo Palmieri <[email protected]>
846da48
to
2ccdd8e
Compare
@@ -890,3 +891,39 @@ TEST(sinsp_plugin, plugin_set_config) | |||
|
|||
libsinsp_logger()->remove_callback_log(); | |||
} | |||
|
|||
#ifdef __linux__ |
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.
Why is this linux only?
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.
libs_metrics_collector
is currently compiled on linux only (see https://github.com/falcosecurity/libs/blob/master/userspace/libsinsp/metrics_collector.h#L82)
I think the reason behind is that we had linux-only metrics.
However, with this PR that's not the case anymore, so we should definitely enable metrics in other platforms too.
I'm working on that, but maybe it's better to open another PR when I'm done :)
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.
Out of simplicity as macOS and Windows were / are not a primary metrics use case. In more detail it's because of how we compute CPU usage etc, which is Linux specific.
I believe there is no harm to refine what actually only needs to be linux. @mrgian does this help?
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.
Hey @incertum Thank you!
I believe we just need to rearrange #ifdef __linux__
directives.
The only hiccup I had is in https://github.com/falcosecurity/libs/blob/master/userspace/libsinsp/metrics_collector.cpp#L35-L56
That uses designated initialization (explicit array indexes) which is not supported by MSVC.
However I don't think removing these explicit indexes is a big problem, the comment on top should be enough for contributors to understand that metrics_unit_name_mappings_prometheus
and metrics_metric_type_name_mappings_prometheus
need to stay in sync with the enums in metrics_v2.h
.
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.
Out of scope, but have we ever thought about using a client library for prometheus, like: https://github.com/jupp0r/prometheus-cpp ? @incertum
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.
@FedeDP see the previous discussions; that was the whole point of not adding another lib as we have a more unique use case with all of our different metrics spanning multiple areas of the code base, plus that lib seems not very suitable and supported enough IMO.
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.
Thanks Melissa! I probably lost that part :)
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.
@mrgian mind elaborating However I don't think removing these explicit indexes is a big problem,
?
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.
mrgian@cddf7b7
👆 @incertum This is what I've done to make libs_metrics_collector
compile on Windows.
Notice how I had to remove designation initializers from metrics_unit_name_mappings_prometheus
, it allows to compile with MSVC and the code behavior stays the same.
However we now have to make sure metrics_unit_name_mappings_prometheus
has the same ordering as the values in metrics_v2_value_unit
in metrics_v2.h
. This comment should be enough to make contributors aware of this.
The same applies for metrics_metric_type_name_mappings_prometheus
.
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 believe ok for now since we don't have much time left for the next release.
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.
/approve
LGTM label has been added. Git tree hash: 677159adc1a667b27f25cfc8d61164a9366f085e
|
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.
/approve
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: FedeDP, incertum, mrgian The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
What type of PR is this?
/kind feature
Any specific area of the project related to this PR?
/area libsinsp
/area tests
Does this PR require a change in the driver versions?
What this PR does / why we need it:
Adds metrics support to the plugin API.
Which issue(s) this PR fixes:
Fixes #
Special notes for your reviewer:
Does this PR introduce a user-facing change?: