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

LOG-3883: Implement pruning fields from log messages #2348

Merged
merged 1 commit into from
Feb 14, 2024

Conversation

Clee2691
Copy link
Contributor

@Clee2691 Clee2691 commented Feb 9, 2024

Description

This PR adds the prune filter feature. This feature allows admins to prune fields from log records to reduce the overall size of a record.

This feature extends the filter API by adding the fields prune along with in and notIn.

The fields, in and notIn, expect an array of dot-delimited path expressions which should contain alphanumeric and underscores. Anything outside of that will have to be quoted.

  • Ex1 : .kubernetes."foo-bar/baz"
  • Ex2: .log_type

An example prune filter spec is as follows:

spec:
  filters:
    - name: my-prune
      type: prune
      prune:
        in: [.kubernetes.namespace_name,.foo."test-dashes/slashes"]
        notIn: [.log_type,.message,.kubernetes,."@timestamp",.openshift]

/cc @cahartma @vparfonov
/assign @jcantrill

Links

@openshift-ci-robot
Copy link

openshift-ci-robot commented Feb 9, 2024

@Clee2691: This pull request references LOG-3883 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the task to target the "4.8.0" version, but no target version was set.

In response to this:

Description

This PR adds the prune filter feature. This feature allows admins to prune fields from log records to reduce the overall size of a record.

This feature extends the filter API by adding the fields prune along with in and notIn.

The fields, in and notIn, expect an array of dot-delimited path expressions which should contain alphanumeric and underscores. Anything outside of that will have to be quoted.

  • Ex1 : .kubernetes."foo-bar/baz"
  • Ex2: .log_type

An example prune filter spec is as follows:

spec:
 filters:
   - name: my-prune
     type: prune
     prune:
       in: [.kubernetes.namespace_name,.foo."test-dashes/slashes"]
       notIn: [.log_type,.message,.kubernetes,."@timestamp",.openshift]

/cc @cahartma @vparfonov
/assign @jcantrill

Links

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Feb 9, 2024
@Clee2691
Copy link
Contributor Author

Clee2691 commented Feb 9, 2024

/hold

@openshift-ci openshift-ci bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Feb 9, 2024
@Clee2691
Copy link
Contributor Author

Clee2691 commented Feb 9, 2024

/retest

@jcantrill
Copy link
Contributor

/approve

Copy link
Contributor

openshift-ci bot commented Feb 9, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Clee2691, jcantrill

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Feb 9, 2024
@Clee2691
Copy link
Contributor Author

Clee2691 commented Feb 9, 2024

/hold cancel

@openshift-ci openshift-ci bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Feb 9, 2024
# Prune keys not in `notIn` list
new_object = {}
for_each(notIn) -> |_index, pathSeg| {
val = get(., pathSeg) ?? null
Copy link
Contributor

Choose a reason for hiding this comment

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

can we use exist function instead of get https://vector.dev/docs/reference/vrl/functions/#exists ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am using get here because I broke up the field path into an array of path segments. The get function expects an array instead of a path. I could not use something like:

paths = [.log, .message]

and iterate through that because for_each would only extract the values and not preserve the path for the exists function.

@openshift-merge-robot openshift-merge-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 11, 2024
@openshift-merge-robot openshift-merge-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 12, 2024
@openshift-ci openshift-ci bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Feb 12, 2024
@Clee2691
Copy link
Contributor Author

/hold cancel

@openshift-ci openshift-ci bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Feb 12, 2024
@Clee2691
Copy link
Contributor Author

/retest

@vparfonov
Copy link
Contributor

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Feb 14, 2024
Copy link
Contributor

openshift-ci bot commented Feb 14, 2024

@Clee2691: all tests passed!

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@openshift-merge-bot openshift-merge-bot bot merged commit d47eec1 into openshift:master Feb 14, 2024
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. lgtm Indicates that a PR is ready to be merged. release/5.9
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants