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-6860: Support Splunk Metadata keys in ClusterLogForwarder #2999

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

vparfonov
Copy link
Contributor

Description

This PR addressed to extend the ClusterLogForwarder to support Splunk metadata fields when forwarding logs
so that we enable better integration with Splunk.

/cc @Clee2691 @cahartma
/assign @jcantrill

/cherry-pick

Links

@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Mar 26, 2025
@openshift-ci-robot
Copy link

openshift-ci-robot commented Mar 26, 2025

@vparfonov: This pull request references LOG-6860 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 addressed to extend the ClusterLogForwarder to support Splunk metadata fields when forwarding logs
so that we enable better integration with Splunk.

/cc @Clee2691 @cahartma
/assign @jcantrill

/cherry-pick

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.

@cahartma
Copy link
Contributor

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Mar 27, 2025
@openshift-ci openshift-ci bot removed the lgtm Indicates that a PR is ready to be merged. label Mar 27, 2025
Copy link
Contributor

openshift-ci bot commented Mar 27, 2025

New changes are detected. LGTM label has been removed.

Copy link
Contributor

openshift-ci bot commented Mar 27, 2025

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: vparfonov
Once this PR has been reviewed and has the lgtm label, please ask for approval from cahartma. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found 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

@@ -338,6 +338,15 @@ type ClusterLogForwarderList struct {
Items []ClusterLogForwarder `json:"items"`
}

// FieldPath represents a path to find a value for a given field. The format must a value that can be converted to a
Copy link
Contributor

Choose a reason for hiding this comment

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

...The format must be a value...

@@ -1045,6 +1045,49 @@ type Splunk struct {
// +kubebuilder:validation:Pattern:=`^(([a-zA-Z0-9-_.\/])*(\{(\.[a-zA-Z0-9_]+|\."[^"]+")+((\|\|)(\.[a-zA-Z0-9_]+|\.?"[^"]+")+)*\|\|"[^"]*"\})*)*$`
// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Index",xDescriptors={"urn:alm:descriptor:com.tectonic.ui:text"}
Index string `json:"index,omitempty"`

//Fields to be added to Splunk index
Copy link
Contributor

Choose a reason for hiding this comment

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

IndexedFields This should match the field name per golang guidelines.

IndexedFields are the list of fields to be indexed by Splunk. //Please add a short comment matching "splunks" warning about using this feature. Maybe we should also add a note about all fields are converted to a string

@@ -80,3 +85,71 @@ func SecretFrom(secretKey *v1.SecretReference) string {
}
return ""
}

// generateQuotedPathSegmentArrayStr generates the final string of the array of array of path segments
Copy link
Contributor

Choose a reason for hiding this comment

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

Should be capitalized

payload := string(spec.Splunk.PayloadKey)
for _, v := range spec.Splunk.IndexedFields {
if !strings.HasPrefix(string(v), payload) {
results = append(results, fmt.Sprintf("Indexed field: %s not part of payload: %s", v, payload))
Copy link
Contributor

Choose a reason for hiding this comment

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

are we trying to restrict they payload field from being part of indexed fields? If so then the error should read that it can not or is not allowed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Indexed fields can't be outside of a given payload

var _ = Describe("validating Splunk", func() {
Context("#ValidateSplunkMetadata", func() {

It("should fail validation if meet indexed field not in payload", func() {
Copy link
Contributor

Choose a reason for hiding this comment

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

If i read this validation correctly, the "event" is always the entire vector log event (e.g. .)? And you can only index fields that are part of what gets added to .? The splunk docs would suggest otherwise but I guess vector's encoding does not allow defining the "event" content separate from "indexed field values"? Maybe the "indexed" fields at the root level would need to be added to the "exclude" fields?

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 checks not related to the Splunk requirements directly, more about our procedure how we remap/calculate fields. If indexed fields will be outside the given payload, we can't remap it correctly. So this warning to check given settings. I think adding "indexed" fields to exclude filter not make sens, we have .log_source and .log_type these should be enough.

if err != nil {
return "", err
}
println("\n\n\n\n\n\n\n")
Copy link
Contributor

Choose a reason for hiding this comment

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

should these be log statements?


//checking Splunk index fields with 'index=${index} | stats count by ${field_name}'
//not direct checking to be sure fields sent as indexed
//if filed is indexed will return counts 2*logs_count or logs_count otherwise
Copy link
Contributor

Choose a reason for hiding this comment

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

if field

Entry("should send audit logs with default source ", "", "", obs.InputTypeAudit),
Entry("should send journal logs with default source ", "", "", obs.InputTypeInfrastructure))

DescribeTable("with user defined payloadKey", func(payloadKey, expSourceType string, expression *regexp.Regexp) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add a test for the audit log defined in the feature request and see how closely we can get to matching the request. I don't believe we wish to test indexing every annotation but I'm interested to see how we populate "event" with the audit event message and maybe index a few other fields

@jcantrill
Copy link
Contributor

/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 Mar 27, 2025
@vparfonov vparfonov requested a review from jcantrill March 28, 2025 12:18
Signed-off-by: Vitalii Parfonov <[email protected]>
@vparfonov
Copy link
Contributor Author

/test functional-target

1 similar comment
@vparfonov
Copy link
Contributor Author

/test functional-target

Signed-off-by: Vitalii Parfonov <[email protected]>
@vparfonov vparfonov marked this pull request as draft March 28, 2025 20:31
@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Mar 28, 2025
Signed-off-by: Vitalii Parfonov <[email protected]>
@vparfonov
Copy link
Contributor Author

/test functional-target

Signed-off-by: Vitalii Parfonov <[email protected]>
@vparfonov
Copy link
Contributor Author

/test functional-target

1 similar comment
@vparfonov
Copy link
Contributor Author

/test functional-target

Signed-off-by: Vitalii Parfonov <[email protected]>
@vparfonov
Copy link
Contributor Author

/test functional-target

4 similar comments
@vparfonov
Copy link
Contributor Author

/test functional-target

@vparfonov
Copy link
Contributor Author

/test functional-target

@vparfonov
Copy link
Contributor Author

/test functional-target

@vparfonov
Copy link
Contributor Author

/test functional-target

Copy link
Contributor

openshift-ci bot commented Mar 29, 2025

@vparfonov: 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-sigs/prow repository. I understand the commands that are listed here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. release/6.3
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants