diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..da2f7e379da78761f996e4ef2ceecaa296e01232 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,27 @@ +ARG BASE_REGISTRY=nexus-docker-secure.levelup-nexus.svc.cluster.local:18082 +ARG BASE_IMAGE=opensource/fluentd/fluentd +ARG BASE_TAG=1.10.0 + +FROM ${BASE_REGISTRY}/${BASE_IMAGE}:${BASE_TAG} + +USER 0 + +COPY fluent-plugin-elasticsearch-4.0.9.gem multi_json-1.14.1.gem multipart-post-2.1.1.gem \ + faraday-1.0.1.gem elasticsearch-transport-7.7.0.gem elasticsearch-api-7.7.0.gem \ + elasticsearch-7.7.0.gem excon-0.73.0.gem /tmp/ + +COPY scripts/entrypoint.sh /fluentd/entrypoint.sh + +RUN gem install --force --local -N /tmp/*.gem && \ + rm -rf /tmp/*.gem /usr/lib/ruby/gems/*/cache/*.gem && \ + chmod a+rx /fluentd/entrypoint.sh + +EXPOSE 24224 5140 + +USER 1000 + +HEALTHCHECK CMD curl -I http://localhost:24220/api/plugins.json + +ENTRYPOINT ["tini", "--", "/fluentd/entrypoint.sh"] + +CMD ["fluentd"] \ No newline at end of file diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000000000000000000000000000000000000..450dfd5236d8f2ec9a9357e19b2874ed1872d051 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,2 @@ +@Library('DCCSCR@master') _ +dccscrPipeline(version: "4.0.9") \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..84388e16dca540597bb42717f0aeeb2ff4debdaa --- /dev/null +++ b/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 2011-2018 Fluentd Authors + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/README.md b/README.md index 7b5e9025b4cb4ea35db54a763e2585257243e2e7..1e6bf064efb11fb430ed3350b0f4d9845c3c80c1 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,70 @@ # fluentd-elasticsearch +This is a fluentd container with the fluent-plugin-elasticsearch plugin installed. + +For more information, visit https://github.com/uken/fluent-plugin-elasticsearch + +## Usage +In your Fluentd configuration, use @type elasticsearch. Additional configuration is optional, default values would look like this: + +``` + + @type elasticsearch + host localhost + port 9200 + index_name fluentd + type_name fluentd + +``` +NOTE: type_name parameter will be used fixed _doc value for Elasticsearch 7. + +NOTE: type_name parameter will make no effect for Elasticsearch 8. + +Index templates +This plugin creates Elasticsearch indices by merely writing to them. Consider using Index Templates to gain control of what get indexed and how. See this example for a good starting point. + +## Configuration +### host +``` +host user-custom-host.domain # default localhost +``` +You can specify Elasticsearch host by this parameter. + +Note: Since v3.3.2, host parameter supports builtin placeholders. If you want to send events dynamically into different hosts at runtime with elasticsearch_dynamic output plugin, please consider to switch to use plain elasticsearch output plugin. In more detail for builtin placeholders, please refer to Placeholders section. + +### port +``` +port 9201 # defaults to 9200 +``` +You can specify Elasticsearch port by this parameter. + +### emit_error_for_missing_id +``` +emit_error_for_missing_id true +``` +When write_operation is configured to anything other then index, setting this value to true will cause the plugin to emit_error_event of any records which do not include an _id field. The default (false) behavior is to silently drop the records. + +### hosts +``` +hosts host1:port1,host2:port2,host3:port3 +``` +You can specify multiple Elasticsearch hosts with separator ",". + +If you specify multiple hosts, this plugin will load balance updates to Elasticsearch. This is an elasticsearch-ruby feature, the default strategy is round-robin. + +If you specify hosts option, host and port options are ignored. + +``` +host user-custom-host.domain # ignored +port 9200 # ignored +hosts host1:port1,host2:port2,host3:port3 +``` +If you specify hosts option without port, port option is used. + +``` +port 9200 +hosts host1:port1,host2:port2,host3 # port3 is 9200 +``` +Note: If you will use scheme https, do not include "https://" in your hosts ie. host "https://domain", this will cause ES cluster to be unreachable and you will receive an error "Can not reach Elasticsearch cluster" + +Note: Up until v2.8.5, it was allowed to embed the username/password in the URL. However, this syntax is deprecated as of v2.8.6 because it was found to cause serious connection problems (See #394). Please migrate your settings to use the user and password field (described below) instead. \ No newline at end of file diff --git a/download.yaml b/download.yaml new file mode 100644 index 0000000000000000000000000000000000000000..c257080e04fd2b743136ef6665d472a4486f176d --- /dev/null +++ b/download.yaml @@ -0,0 +1,41 @@ +resources: + - url: "https://rubygems.org/downloads/fluent-plugin-elasticsearch-4.0.9.gem" + filename: "fluent-plugin-elasticsearch-4.0.9.gem" + validation: + type: "sha256" + value: "488b0e12619c862c4d28053e858f4be9e5c5173b6d113e64e65492304a527e0e" + - url: "https://rubygems.org/downloads/multi_json-1.14.1.gem" + filename: "multi_json-1.14.1.gem" + validation: + type: "sha256" + value: "d971296c0eacea289d31e4a7ab7ac5eda97262c62bbc8c110de4f5e36425c577" + - url: "https://rubygems.org/downloads/multipart-post-2.1.1.gem" + filename: "multipart-post-2.1.1.gem" + validation: + type: "sha256" + value: "d2dd7aa957650e0d99e0513cd388401b069f09528441b87d884609c8e94ffcfd" + - url: "https://rubygems.org/downloads/faraday-1.0.1.gem" + filename: "faraday-1.0.1.gem" + validation: + type: "sha256" + value: "381aee04fcc9effbe5fa7cc703d8f5f20293722f987ded4f958f77514cd29373" + - url: "https://rubygems.org/downloads/elasticsearch-transport-7.7.0.gem" + filename: "elasticsearch-transport-7.7.0.gem" + validation: + type: "sha256" + value: "48daf4df3a564236d520313aa269f753e055043730fa2bf94ac37e62cc2a0443" + - url: "https://rubygems.org/downloads/elasticsearch-api-7.7.0.gem" + filename: "elasticsearch-api-7.7.0.gem" + validation: + type: "sha256" + value: "5bc46fba4901c61a48f2ae76b90b5e70f3259466952c25360e44b3531b03210e" + - url: "https://rubygems.org/downloads/elasticsearch-7.7.0.gem" + filename: "elasticsearch-7.7.0.gem" + validation: + type: "sha256" + value: "e9cc8e7f279496c0b08eb356966babc1adf3a38209aea4faa6a5932269e2ffaa" + - url: "https://rubygems.org/downloads/excon-0.73.0.gem" + filename: "excon-0.73.0.gem" + validation: + type: "sha256" + value: "bcee89692736d075ee41c904e98e80d9f94793d7b71d28bea1cc73078c8777ff" diff --git a/scripts/.gitkeep b/scripts/.gitkeep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/scripts/entrypoint.sh b/scripts/entrypoint.sh new file mode 100644 index 0000000000000000000000000000000000000000..aad4e34f863f5e9f0b82c7c148a354c9451a6cde --- /dev/null +++ b/scripts/entrypoint.sh @@ -0,0 +1,10 @@ +set -e + +SIMPLE_SNIFFER=$( gem contents fluent-plugin-elasticsearch | grep elasticsearch_simple_sniffer.rb ) + +if [ -n "$SIMPLE_SNIFFER" -a -f "$SIMPLE_SNIFFER" ] ; then + FLUENTD_OPT="$FLUENTD_OPT -r $SIMPLE_SNIFFER" +fi + + +exec fluentd -c /fluentd/etc/${FLUENTD_CONF} -p /fluentd/plugins --gemfile /fluentd/Gemfile ${FLUENTD_OPT} \ No newline at end of file