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

new(metrics): add host_ifinfo metric #3253

Merged
merged 3 commits into from
Aug 27, 2024

Conversation

incertum
Copy link
Contributor

What type of PR is this?

Uncomment one (or more) /kind <> lines:

/kind bug

/kind cleanup

/kind design

/kind documentation

/kind failing-test

/kind feature

/kind release

Any specific area of the project related to this PR?

Uncomment one (or more) /area <> lines:

/area build

/area engine

/area tests

/area proposals

/area CI

What this PR does / why we need it:

For fleet management and inventory purposes, having the host ifinfo available is highly valuable, in addition to evt.hostname, kernel_release, and many other wrapper/base metric fields.

In addition to incorporating the new metric field into the metrics framework, I would also like to propose adding new filter checks similar to evt.hostname to libs (details to be discussed later).

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

new(metrics): add host_ifinfo metric

@incertum
Copy link
Contributor Author

@FedeDP @sgaist @mrgian thanks.

Copy link

This PR may bring feature or behavior changes in the Falco engine and may require the engine version to be bumped.

Please double check userspace/engine/falco_engine_version.h file. See versioning for FALCO_ENGINE_VERSION.

/hold

@FedeDP
Copy link
Contributor

FedeDP commented Jun 19, 2024

/milestone 0.39.0

@poiana poiana added this to the 0.39.0 milestone Jun 19, 2024
Copy link
Contributor

@sgaist sgaist 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 however I am wondering whether the network addresses might change if the inspectors get reloaded ?

#if defined(__linux__) and !defined(MINIMAL_BUILD) and !defined(__EMSCRIPTEN__)
// todo: consider extending libs and expose API for ipv4 and ipv6 to string conversion
std::string ipv4addr_to_string(uint32_t addr);
std::string ipv6addr_to_string(const ipv6addr& addr);
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not make it a function of the ipv6addr structure ?
Since that structure has a constructor that takes a string as input, a to_string method would make sense as well. What do you think ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thought the same. That's why I left a todo item.
@FedeDP would it be ok to make the to_string functions public? For ipv4 we have it in libs, but it's private. For ipv6 we do not yet have it. I can port this code over to libs if you all agree.

Copy link
Contributor

Choose a reason for hiding this comment

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

+1 from my side! Neat idea!

Copy link
Contributor

Choose a reason for hiding this comment

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

(i don't think it's a problem to make them public!)

@incertum incertum force-pushed the metrics-host-network-interfaces branch from 18e335c to a7bde11 Compare June 28, 2024 01:02
@poiana poiana added size/M and removed size/L labels Jun 28, 2024
@incertum incertum force-pushed the metrics-host-network-interfaces branch 2 times, most recently from 91b90cb to 74c5c49 Compare June 28, 2024 01:05
@@ -357,6 +357,43 @@ void stats_writer::collector::get_metrics_output_fields_wrapper(
metric_name_file_sha256 = "falco.sha256_config_file." + falco::utils::sanitize_metric_name(metric_name_file_sha256);
output_fields[metric_name_file_sha256] = item.second;
}

if (stats_snapshot_time_delta_sec == 0)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This new trick helps to create the json only once every inspector reload. For Prometheus however it does it every time right now @sgaist.

@incertum
Copy link
Contributor Author

/hold needs a libs bump after merging falcosecurity/libs#1937.

@FedeDP
Copy link
Contributor

FedeDP commented Aug 26, 2024

I think you can now rebase on top of Falco master ;)

Because libs constantly refreshes them, it's fine to re-create the JSON
each time

Signed-off-by: Melissa Kilby <[email protected]>
@incertum incertum force-pushed the metrics-host-network-interfaces branch from 74c5c49 to f43b4df Compare August 26, 2024 17:30
@incertum
Copy link
Contributor Author

I think you can now rebase on top of Falco master ;)

Rebased, thanks.

Copy link
Contributor

@FedeDP FedeDP left a comment

Choose a reason for hiding this comment

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

/approve

@poiana
Copy link
Contributor

poiana commented Aug 27, 2024

LGTM label has been added.

Git tree hash: dd0c218c324ac0e01bf1d25b092ad4cc3822fcec

Copy link
Member

@Andreagit97 Andreagit97 left a comment

Choose a reason for hiding this comment

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

/approve

@poiana
Copy link
Contributor

poiana commented Aug 27, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Andreagit97, FedeDP, incertum

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:
  • OWNERS [Andreagit97,FedeDP,incertum]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@FedeDP
Copy link
Contributor

FedeDP commented Aug 27, 2024

/unhold

@poiana poiana merged commit f839821 into falcosecurity:master Aug 27, 2024
32 of 33 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

5 participants