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

es_out: support Upstream Servers with configuration overriding #7608

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

Conversation

mabrarov
Copy link

@mabrarov mabrarov commented Jun 25, 2023

Implementation of Upstream feature for the Elasticsearch output plugin.

This pull request is based on pull request #1560 and Forward output plugin.

It was tested in a local setup with:

  1. Single Elasticsearch instance.

    Refer to elastic-cluster directory of mabrarov/elastic-stack repository for Docker Compose project used to create target Elasticsearch cluster and Kibana.

    fluent-bit.conf Fluent Bit configuration file used for the test:

    [SERVICE]
        Flush           10
    
    [INPUT]
        Name            dummy
        Dummy           { "message" : "this is dummy data" }
        Rate            10
    
    [OUTPUT]
        Workers         4
        Name            es
        Host            localhost
        Port            9201
        TLS             Off
        Retry_Limit     6
        Replace_Dots    On
        HTTP_User       elastic
        HTTP_Passwd     elastic
        Index           fluent-bit
    

    Debug log is available at flb_es.log.

  2. Elasticsearch cluster of 3 master-eligible/data and 1 coordinating nodes.

    Refer to elastic-cluster directory of mabrarov/elastic-stack repository for Docker Compose project used to create target Elasticsearch cluster and Kibana.

    fluent-bit.conf Fluent Bit configuration file used for the test:

    [SERVICE]
        Flush           10
    
    [INPUT]
        Name            dummy
        Dummy           { "message" : "this is dummy data" }
        Rate            10
    
    [OUTPUT]
        Workers         4
        Name            es
        Upstream        ./upstream.conf
        TLS             Off
        Retry_Limit     6
        Replace_Dots    On
        HTTP_User       elastic
        HTTP_Passwd     elastic
        Index           fluent-bit
    

    upstream.conf Fluent Bit configuration file used for the test:

    [UPSTREAM]
        name        elasticsearch-balancing
    
    [NODE]
        name        elasticsearch1
        host        localhost
        port        9201
        Index       fluent-bit-000002
        buffer_size 4M
    
    [NODE]
        name        elasticsearch2
        host        localhost
        port        9202
        Index       fluent-bit-000003
        compress    gzip
    
    [NODE]
        name        elasticsearch3
        host        localhost
        port        9203
        Index       fluent-bit-000004
    

    Debug log is available at flb_es_upstream.log.

Testing

  • Example configuration files for the change can be found in mabrarov/elastic-stack repository under fluent-bit-es-cluster directory.
  • Debug log output from testing the change - see above.
  • Attached Valgrind output that shows no leaks or memory corruption was found - refer to flb_run_code_analysis.log for the output of command
    TEST_PRESET=valgrind ./run_code_analysis.sh
  • [N/A] Run local packaging test showing all targets (including any new ones) build.
  • [N/A] Set ok-package-test label to test for all targets (requires maintainer to do).

Documentation

Backporting

  • [N/A] Backport to latest stable release.

Fluent Bit is licensed under Apache 2.0, by submitting this pull request I understand that this code will be released under the terms of that license.


struct flb_elasticsearch {
struct flb_elasticsearch_config {
Copy link
Author

Choose a reason for hiding this comment

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

The whole idea / implementation and naming of new types follows Upstream support in Forward output plugin.

return 0;
}

toks = flb_utils_split((const char *)cloud_auth, ':', -1);
Copy link
Author

@mabrarov mabrarov Jun 26, 2023

Choose a reason for hiding this comment

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

Not:

Suggested change
toks = flb_utils_split((const char *)cloud_auth, ':', -1);
toks = flb_utils_split((const char *) cloud_auth, ':', -1);

because https://github.com/fluent/fluent-bit/blob/master/CONTRIBUTING.md requires to follow https://httpd.apache.org/dev/styleguide.html which requires to not put a space in case of type cast:

The Guidelines
...
There is no whitespace between a cast and the item modified (e.g., "(int)j" and not "(int) j").

@mabrarov
Copy link
Author

Hi reviewers,

Is it possible to approve only workflow for this pull request, so that automated checks and build can start?

Thank you.

@mabrarov mabrarov temporarily deployed to pr June 28, 2023 17:55 — with GitHub Actions Inactive
@mabrarov mabrarov temporarily deployed to pr June 28, 2023 17:55 — with GitHub Actions Inactive
@mabrarov mabrarov temporarily deployed to pr June 28, 2023 17:55 — with GitHub Actions Inactive
@PettitWesley
Copy link
Contributor

@mabrarov sure

@mabrarov mabrarov temporarily deployed to pr June 28, 2023 18:22 — with GitHub Actions Inactive
@mabrarov
Copy link
Author

mabrarov commented Jun 29, 2023

Hi @PettitWesley,

It looks like all failed checks are around run-macos-unit-tests jobs and caused by the following failed unit tests:

  1. flb-rt-in_event_test
  2. flb-rt-out_tcp

I feel like other pull requests have the same issues, i.e. it doesn't seem that the failed checks are caused by this pull request changes.

Help of maintainers is appreciated.

Thank you.

}
tmp = flb_upstream_node_get_property(FLB_ES_CONFIG_PROPERTY_LOGSTASH_PREFIX, node);
if (tmp) {
ec->logstash_prefix = (char *)tmp;
Copy link
Author

@mabrarov mabrarov Jul 7, 2023

Choose a reason for hiding this comment

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

Type cast is illegal. Should use flb_sds_create instead. Working on fix in feature/out_es_upstream_support_extended_test branch.

Copy link
Author

Choose a reason for hiding this comment

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

Fixed.

@mabrarov mabrarov force-pushed the feature/out_es_upstream_support_extended branch from ba3382a to b7cd81b Compare July 8, 2023 10:22
@mabrarov
Copy link
Author

Hi @PettitWesley,

Is it possible to trigger automated workflow (build) for this pull request one more time? I found & fixed one issue and added tests for the new code since last build happened.

Thank you.

@mabrarov mabrarov temporarily deployed to pr July 10, 2023 12:05 — with GitHub Actions Inactive
@mabrarov mabrarov temporarily deployed to pr July 10, 2023 12:05 — with GitHub Actions Inactive
@mabrarov mabrarov temporarily deployed to pr July 10, 2023 12:05 — with GitHub Actions Inactive
@mabrarov mabrarov temporarily deployed to pr July 10, 2023 12:28 — with GitHub Actions Inactive
@mabrarov
Copy link
Author

Hi dear reviewers,

Is it possible to get this pull request reviewed / accepted sooner? Is there something pending / waiting from my side to start review?

Thank you.

@mabrarov mabrarov force-pushed the feature/out_es_upstream_support_extended branch from b7cd81b to b81d3f7 Compare July 20, 2023 19:38
@mabrarov
Copy link
Author

Hi @PettitWesley and @edsiper,

It feels like you are code owners for Elasticsearch output plugin. Is there something pending / waiting from my side to start review of this pull request? This new feature was requested 4 years ago and I feel it is something which multiple users of Fluent Bit (not just my team) would like to have.

Thank you.

@mabrarov mabrarov force-pushed the feature/out_es_upstream_support_extended branch from b81d3f7 to f6431c2 Compare September 30, 2023 13:32
@mabrarov
Copy link
Author

Hi @PettitWesley and @edsiper,

Is there a chance to get this pull request reviewed (and eventually accepted)? Please let me know if something is missing and blocking that.

Thank you.

@116davinder
Copy link

Please someone review this, I also want this feature to merged and released.
thank you!

@mabrarov mabrarov force-pushed the feature/out_es_upstream_support_extended branch from f6431c2 to d03cde0 Compare December 24, 2023 17:12
@dioniseo
Copy link

+1

Hello reviewers, could you please review this PR?

This feature also will be very useful in our project and very useful feature to support HA.

Thank you!

@mabrarov
Copy link
Author

Just FYI, my team successfully tested replacement of following log shipping solution:

Fluent Bit DaemonSet in K8s (Forward output plugin with Upstream Servers, Upstream node per Fluentd instance) → Fluentd (2 instances with fluent-plugin-elasticsearch configured to connect to all nodes of Elasticsearch cluster) → Elasticsearch cluster (3+ nodes)

with:

Fluent Bit DaemonSet in K8s (Docker image built from source branch of this pull request, Elasticsearch output plugin with Upstream Servers, Upstream node per Elasticsearch node) → Elasticsearch cluster (3+ nodes)

For my team it means (this pull request means) a possibility to get rid of 7-9 Fluentd instances (where each Fluentd instance occupies a single VM).

Copy link
Contributor

This PR is stale because it has been open 45 days with no activity. Remove stale label or comment or this will be closed in 10 days.

@github-actions github-actions bot added the Stale label Jun 27, 2024
@mabrarov
Copy link
Author

This pull request is still actual and up-to-date (ready for merging, tested with changes coming from target branch).

@github-actions github-actions bot removed the Stale label Jun 29, 2024
@AzureLeMoon
Copy link

Hello, @PettitWesley and @edsiper.

i hope you guys can take a look at this pr and merge it sooner, it's a highly requested feature with its mentioned in the official docs as well.

@mabrarov
Copy link
Author

mabrarov commented Jul 28, 2024

Hi @PettitWesley and @edsiper,

It looks like there is one more enhancement which this pull request brings comparing to approach "Fluent Bit (Forward output plugin with Upstream Servers) → multiple Fluentd instances → multiple Elasticsearch instances of a single Elasticsearch cluster":

  1. Fluentd can generate unique ID of Elasticsearch document before inserting data into Elasticsearch. This approach can help to avoid duplicating records (at Elasticsearch side) when re-sending data to Elasticsearch at Fluentd side. Refer to https://github.com/uken/fluent-plugin-elasticsearch?tab=readme-ov-file#generate-hash-id.
  2. Unfortunately, elasticsearch_genid Fluentd filter plugin won't help to avoid duplicated records when Fluent Bit re-sends data to Fluentd.
  3. With this pull request we can generate unique ID of Elasticsearch document at Fluent Bit side - refer to Generate_ID key of Elasticsearch Fluent Bit output plugin configuration. This approach (Fluent Bit built from this pull request, Fluent Bit configured with Elasticsearch output plugin with Upstream Servers and Generate_ID configuration key set to On → multiple Elasticsearch instances of a single Elasticsearch cluster) fully eliminates possibility to get duplicated records at Elasticsearch side due to re-sending of data.

@mabrarov mabrarov force-pushed the feature/out_es_upstream_support_extended branch from d03cde0 to 30a2822 Compare August 19, 2024 18:52
@mabrarov
Copy link
Author

Hi @PettitWesley,

Could you (or someone from maintainers / reviewers) please approve workflow for this pull request, so that the automated checks and build of this pull request can start?

Thank you.

@mabrarov mabrarov force-pushed the feature/out_es_upstream_support_extended branch 3 times, most recently from 7aaea9f to b13a6f8 Compare September 5, 2024 15:25
@mabrarov mabrarov force-pushed the feature/out_es_upstream_support_extended branch from b13a6f8 to f7d0a15 Compare September 6, 2024 09:39
…wn to parser of Upstream node configuration section are implemented, e.g. "host" and "port"

Signed-off-by: Marat Abrarov <[email protected]>
…o the test callback based on configuration of Fluent Bit and based on configuration of plugin

Signed-off-by: Marat Abrarov <[email protected]>
…with Upstream node configuration

For Elastic cloud authentication these parameters are always taken from plugin configuration and never from Upstream node configuration: cloud_id.

For AWS authentication these parameters are always taken from plugin configuration and never from Upstream node configuration: http_proxy, no_proxy, tls*.

Signed-off-by: Marat Abrarov <[email protected]>
@mabrarov mabrarov force-pushed the feature/out_es_upstream_support_extended branch from f7d0a15 to f023976 Compare October 25, 2024 04:04
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.

5 participants