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

fix(elasticsearch sink): Encode bulk action parameters as JSON #21293

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

jszwedko
Copy link
Member

They are currently using string templating which, if there are special characters in the value, will
end up creating an invalid JSON payload; an issue that can be difficult to track down. This happened
in #21288.

Signed-off-by: Jesse Szwedko [email protected]

They are currently using string templating which, if there are special characters in the value, will
end up creating an invalid JSON payload; an issue that can be difficult to track down. This happened
in #21288.

Signed-off-by: Jesse Szwedko <[email protected]>
@jszwedko jszwedko requested a review from a team as a code owner September 13, 2024 14:47
@github-actions github-actions bot added the domain: sinks Anything related to the Vector's sinks label Sep 13, 2024
@datadog-vectordotdev
Copy link

datadog-vectordotdev bot commented Sep 13, 2024

Datadog Report

Branch report: jszwedko/fix-elasticsearch-message-encoding
Commit report: 509120c
Test service: vector

❌ 9 Failed (0 Known Flaky), 2223 Passed, 0 Skipped, 1m 31.64s Total Time

❌ Failed Tests (9)

This report shows up to 5 failed tests.

  • sinks::elasticsearch::tests::allows_using_except_fields - vector - Details

    Expand for error
     thread 'sinks::elasticsearch::tests::allows_using_except_fields' panicked at src/sinks/elasticsearch/tests.rs:494:5:
     assertion \`left == right\` failed
       left: "{\"index\":{\"_type\":\"_doc\",\"_index\":\"purple\"}}\n{\"foo\":\"bar\",\"message\":\"hello there\"}\n"
      right: "{\"index\":{\"_index\":\"purple\",\"_type\":\"_doc\"}}\n{\"foo\":\"bar\",\"message\":\"hello there\"}\n"
     stack backtrace:
        0:     0x5575c3570165 - std::backtrace_rs::backtrace::libunwind::trace::h649ab3318d3445c5
                                    at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/std/src/../../backtrace/src/backtrace/libunwind.rs:116:5
        1:     0x5575c3570165 - std::backtrace_rs::backtrace::trace_unsynchronized::hf4bb60c3387150c3
                                    at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
        2:     0x5575c3570165 - std::sys::backtrace::_print_fmt::hd9186c800e44bd00
     ...
    
  • sinks::elasticsearch::tests::allows_using_only_fields - vector - Details

    Expand for error
     thread 'sinks::elasticsearch::tests::allows_using_only_fields' panicked at src/sinks/elasticsearch/tests.rs:529:5:
     assertion \`left == right\` failed
       left: "{\"index\":{\"_type\":\"_doc\",\"_index\":\"purple\"}}\n{\"foo\":\"bar\"}\n"
      right: "{\"index\":{\"_index\":\"purple\",\"_type\":\"_doc\"}}\n{\"foo\":\"bar\"}\n"
     stack backtrace:
        0:     0x557e6a475165 - std::backtrace_rs::backtrace::libunwind::trace::h649ab3318d3445c5
                                    at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/std/src/../../backtrace/src/backtrace/libunwind.rs:116:5
        1:     0x557e6a475165 - std::backtrace_rs::backtrace::trace_unsynchronized::hf4bb60c3387150c3
                                    at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
        2:     0x557e6a475165 - std::sys::backtrace::_print_fmt::hd9186c800e44bd00
     ...
    
  • sinks::elasticsearch::tests::encode_datastream_mode - vector - Details

    Expand for error
     thread 'sinks::elasticsearch::tests::encode_datastream_mode' panicked at src/sinks/elasticsearch/tests.rs:251:5:
     assertion \`left == right\` failed
       left: "{\"create\":{\"_type\":\"_doc\",\"_index\":\"synthetics-testing-default\"}}\n{\"@timestamp\":\"2020-12-01T01:02:03Z\",\"data_stream\":{\"dataset\":\"testing\",\"namespace\":\"default\",\"type\":\"synthetics\"},\"message\":\"hello there\"}\n"
      right: "{\"create\":{\"_index\":\"synthetics-testing-default\",\"_type\":\"_doc\"}}\n{\"@timestamp\":\"2020-12-01T01:02:03Z\",\"data_stream\":{\"dataset\":\"testing\",\"namespace\":\"default\",\"type\":\"synthetics\"},\"message\":\"hello there\"}\n"
     stack backtrace:
        0:     0x557f7366b165 - std::backtrace_rs::backtrace::libunwind::trace::h649ab3318d3445c5
                                    at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/std/src/../../backtrace/src/backtrace/libunwind.rs:116:5
        1:     0x557f7366b165 - std::backtrace_rs::backtrace::trace_unsynchronized::hf4bb60c3387150c3
                                    at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
        2:     0x557f7366b165 - std::sys::backtrace::_print_fmt::hd9186c800e44bd00
     ...
    
  • sinks::elasticsearch::tests::encode_datastream_mode_no_routing - vector - Details

    Expand for error
     thread 'sinks::elasticsearch::tests::encode_datastream_mode_no_routing' panicked at src/sinks/elasticsearch/tests.rs:306:5:
     assertion \`left == right\` failed
       left: "{\"create\":{\"_type\":\"_doc\",\"_index\":\"logs-generic-something\"}}\n{\"@timestamp\":\"2020-12-01T01:02:03Z\",\"data_stream\":{\"dataset\":\"testing\",\"namespace\":\"something\",\"type\":\"synthetics\"},\"message\":\"hello there\"}\n"
      right: "{\"create\":{\"_index\":\"logs-generic-something\",\"_type\":\"_doc\"}}\n{\"@timestamp\":\"2020-12-01T01:02:03Z\",\"data_stream\":{\"dataset\":\"testing\",\"namespace\":\"something\",\"type\":\"synthetics\"},\"message\":\"hello there\"}\n"
     stack backtrace:
        0:     0x55dabe5bb165 - std::backtrace_rs::backtrace::libunwind::trace::h649ab3318d3445c5
                                    at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/std/src/../../backtrace/src/backtrace/libunwind.rs:116:5
        1:     0x55dabe5bb165 - std::backtrace_rs::backtrace::trace_unsynchronized::hf4bb60c3387150c3
                                    at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
        2:     0x55dabe5bb165 - std::sys::backtrace::_print_fmt::hd9186c800e44bd00
     ...
    
  • sinks::elasticsearch::tests::encode_datastream_mode_no_sync - vector - Details

    Expand for error
     thread 'sinks::elasticsearch::tests::encode_datastream_mode_no_sync' panicked at src/sinks/elasticsearch/tests.rs:458:5:
     assertion \`left == right\` failed
       left: "{\"create\":{\"_type\":\"_doc\",\"_index\":\"synthetics-testing-something\"}}\n{\"@timestamp\":\"2020-12-01T01:02:03Z\",\"data_stream\":{\"dataset\":\"testing\",\"type\":\"synthetics\"},\"message\":\"hello there\"}\n"
      right: "{\"create\":{\"_index\":\"synthetics-testing-something\",\"_type\":\"_doc\"}}\n{\"@timestamp\":\"2020-12-01T01:02:03Z\",\"data_stream\":{\"dataset\":\"testing\",\"type\":\"synthetics\"},\"message\":\"hello there\"}\n"
     stack backtrace:
        0:     0x55ae51faf165 - std::backtrace_rs::backtrace::libunwind::trace::h649ab3318d3445c5
                                    at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/std/src/../../backtrace/src/backtrace/libunwind.rs:116:5
        1:     0x55ae51faf165 - std::backtrace_rs::backtrace::trace_unsynchronized::hf4bb60c3387150c3
                                    at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
        2:     0x55ae51faf165 - std::sys::backtrace::_print_fmt::hd9186c800e44bd00
     ...
    

"TYPE\n",
false,
&DocumentMetadata::Id("ID\n".to_string()),
);
Copy link
Member

Choose a reason for hiding this comment

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

Should we add an .unwrap() here?

Copy link
Member Author

Choose a reason for hiding this comment

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

Mmm, yeah, I just used the pattern the other tests here are using, but yes, it would make sense to use unwrap on all of these

@pront
Copy link
Member

pront commented Oct 17, 2024

Note: Tests fail due the order of keys in the objects. The data look identical otherwise.

@jszwedko jszwedko added the no-changelog Changes in this PR do not need user-facing explanations in the release changelog label Nov 1, 2024
@jszwedko jszwedko changed the title fix(elasticsearch): Encode bulk action parameters as JSON fix(elasticsearch source): Encode bulk action parameters as JSON Nov 1, 2024
@jszwedko jszwedko changed the title fix(elasticsearch source): Encode bulk action parameters as JSON fix(elasticsearch sink): Encode bulk action parameters as JSON Nov 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
domain: sinks Anything related to the Vector's sinks no-changelog Changes in this PR do not need user-facing explanations in the release changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants