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

DLQ-ing events that trigger an conditional evaluation error. #16423

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

andsel
Copy link
Contributor

@andsel andsel commented Sep 5, 2024

Release notes

When a conditional evaluation encounter an error in the expression the event that triggered the issue is sent to pipeline's DLQ, if enabled for the executing pipeline.

What does this PR do?

This PR engage with the work done in #16322, the ConditionalEvaluationListener that is receives notifications about if-statements evaluation failure, is improved to also send the event to DLQ (if enabled in the pipeline) and not just logging it.

Why is it important/What is the impact to the user?

Let the user that encounter errors in the evaluation of conditional statements to enqueue in DLQ for a subsequent processing.

Checklist

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • [ ] I have made corresponding change to the default configuration files (and/or docker env variables)
  • I have added tests that prove my fix is effective or that my feature works

Author's Checklist

  • [ ]

How to test this PR locally

Use a pipeline that would trigger an error in conditional evaluation, like:

input {
    generator {
      message => '{"path":{"to":{"value": 101}}}'
      codec => json
      count => 1
    }
}

filter {
  if [path][to][value] > "100" { mutate { add_tag => "hit" } }
}

output {
    stdout { codec => rubydebug }
}

And enable DLQ, so in config/logstash.yml set

dead_letter_queue.enable: true

Related issues

Use cases

Screenshots

Logs

@andsel andsel self-assigned this Sep 5, 2024
@andsel andsel changed the title Feature/insert event into dlq on failing if statements 2 DLQ-ing events that trigger an conditional evaluation error. Sep 5, 2024
…ct the full stack trafe and debug log it, the other is send to DLQ
@andsel andsel marked this pull request as ready for review September 5, 2024 15:14
@andsel andsel requested a review from jsvd September 13, 2024 07:38
@@ -190,6 +191,15 @@ public void notify(ConditionalEvaluationError err) {
} catch (IOException ioex) {
LOGGER.warn("Invalid operation on closing internal resources", ioex);
}

// if pipeline has DLQ enabled, send also there the event
if (javaDlqWriter != null) {
Copy link
Member

Choose a reason for hiding this comment

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

We should change the log entry to mention that the event was sent to the DLQ instead of "Event was dropped, enable debug logging to see the event's payload."

@@ -180,10 +181,32 @@ public final class LogErrorEvaluationListener implements ConditionalEvaluationLi
@Override
public void notify(ConditionalEvaluationError err) {
lastErrorEvaluationReceived = err.getCause().getMessage();
LOGGER.warn("{}. Event was dropped, enable debug logging to see the event's payload.", lastErrorEvaluationReceived);
if (isDLQEnabled()) {
LOGGER.warn("{}. Failing event was sent to dead letter queue", lastErrorEvaluationReceived);
Copy link
Member

Choose a reason for hiding this comment

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

Any reason for one to end on a period (.) and the other not?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, was a typo

Copy link

Quality Gate passed Quality Gate passed

Issues
0 New issues
0 Fixed issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarQube

@elasticmachine
Copy link
Collaborator

💚 Build Succeeded

History

cc @andsel

@andsel andsel requested a review from jsvd September 18, 2024 11:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Send to DLQ events that trigger a fail on a condition evaluation
3 participants