fluent-plugin-mattermost 0.1.2 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/release.yml +80 -0
- data/.gitignore +1 -1
- data/CHANGELOG.md +36 -0
- data/Gemfile +3 -3
- data/LICENSE +201 -201
- data/README.md +49 -49
- data/Rakefile +13 -13
- data/documentation/docker-installation.md +12 -12
- data/documentation/installation.md +14 -14
- data/fluent-plugin-mattermost.gemspec +29 -27
- data/lib/fluent/plugin/out_mattermost.rb +109 -109
- data/lib/release/version.rb +3 -0
- data/test/helper.rb +8 -8
- data/test/plugin/test_out_mattermost.rb +18 -18
- metadata +9 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eb5bc91515a590fa4df017f10fa3c0d44013f9ab43fc2f6ce650f26a0b4987d9
|
4
|
+
data.tar.gz: 66e1426bf96790847bf41036ca12b5d3100d52a491ec74f9399e64b068a212ba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2f7c099d2fcb5d4682e3dd334a98c91c32707bb5df0fb60df71d0dbcd8374f7069fbce2f1f8370c8f90e8f3f645bd3f974512e19dad256edace2b6fdaac66b97
|
7
|
+
data.tar.gz: d34df3431bc1ba45dbf181f3989c84240af9f759525392b1daaa03fd6c65db25b9a2c787a4aee8f05fecd7561843cc8d3f74119515217fca2a3172d43ac5a06f
|
@@ -0,0 +1,80 @@
|
|
1
|
+
name: fluent-plugin-mattermost
|
2
|
+
on:
|
3
|
+
push:
|
4
|
+
branches:
|
5
|
+
- master
|
6
|
+
pull_request:
|
7
|
+
branches:
|
8
|
+
- master
|
9
|
+
jobs:
|
10
|
+
release-please:
|
11
|
+
runs-on: ubuntu-latest
|
12
|
+
steps:
|
13
|
+
# Set a mask
|
14
|
+
- name: create a mask
|
15
|
+
run: |
|
16
|
+
echo "::add-mask::${{ secrets.GITHUB_TOKEN }}"
|
17
|
+
- uses: GoogleCloudPlatform/release-please-action@v3.1.0
|
18
|
+
id: release
|
19
|
+
with:
|
20
|
+
# Personal Access Token
|
21
|
+
token: ${{ secrets.GITHUB_TOKEN }}
|
22
|
+
# The release type
|
23
|
+
release-type: ruby
|
24
|
+
# A name for the artifact releases are being created for
|
25
|
+
# which is the name of our gem
|
26
|
+
package-name: fluent-plugin-mattermost
|
27
|
+
bump-minor-pre-major: true
|
28
|
+
bump-patch-for-minor-pre-major: true
|
29
|
+
# Path to our version file to increment
|
30
|
+
version-file: "lib/release/version.rb"
|
31
|
+
# INFOS: In case you get the error message: Error: release-please failed: Validation Failed: {"resource":"Release","code":"already_exists","field":"tag_name"}
|
32
|
+
# You can comment out the pull-request-title-pattern to see in the action log which version it is locked in.
|
33
|
+
# Found the version of the tag where release-please-acton wants to create the PR, remove it from the repository and try again
|
34
|
+
pull-request-title-pattern: "fluent-plugin-mattermost ${scope}: release${component} ${version}"
|
35
|
+
- uses: actions/checkout@v2
|
36
|
+
if: ${{ steps.release.outputs.release_created }}
|
37
|
+
# Setup ruby if a release was created
|
38
|
+
- uses: ruby/setup-ruby@v1
|
39
|
+
with:
|
40
|
+
ruby-version: 3.0.2
|
41
|
+
if: ${{ steps.release.outputs.release_created }}
|
42
|
+
- name: Install the bundle with the version 2.2.32
|
43
|
+
if: ${{ steps.release.outputs.release_created }}
|
44
|
+
run: gem install bundler:2.2.32
|
45
|
+
# Update the version.rb file with the new version
|
46
|
+
- name: update version.rb file
|
47
|
+
if: ${{ steps.release.outputs.release_created }}
|
48
|
+
run: printf "module Release\n VERSION = '${{ steps.release.outputs.major }}.${{ steps.release.outputs.minor }}.${{ steps.release.outputs.patch }}'\nend" > lib/release/version.rb
|
49
|
+
# Bundle install
|
50
|
+
- run: bundle _2.2.32_ install
|
51
|
+
if: ${{ steps.release.outputs.release_created }}
|
52
|
+
# Set a mask
|
53
|
+
- name: create a mask
|
54
|
+
if: ${{ steps.release.outputs.release_created }}
|
55
|
+
run: |
|
56
|
+
echo "::add-mask::${{ secrets.GEM_HOST_API_KEY }}"
|
57
|
+
echo "::add-mask::${{ secrets.GITHUB_TOKEN }}"
|
58
|
+
# Publish on the rubygem.org
|
59
|
+
- name: publish gem
|
60
|
+
if: ${{ steps.release.outputs.release_created }}
|
61
|
+
env:
|
62
|
+
GEM_HOST_API_KEY: ${{ secrets.GEM_HOST_API_KEY }}
|
63
|
+
run: |
|
64
|
+
mkdir -p $HOME/.gem
|
65
|
+
touch $HOME/.gem/credentials
|
66
|
+
chmod 0600 $HOME/.gem/credentials
|
67
|
+
printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
|
68
|
+
gem build fluent-plugin-mattermost
|
69
|
+
gem push fluent-plugin-mattermost-${{ steps.release.outputs.major }}.${{ steps.release.outputs.minor }}.${{ steps.release.outputs.patch }}.gem
|
70
|
+
echo "A new gem was pushed!!!"
|
71
|
+
- uses: meeDamian/github-release@2.0
|
72
|
+
if: ${{ steps.release.outputs.release_created }}
|
73
|
+
with:
|
74
|
+
tag: v${{ steps.release.outputs.major }}.${{ steps.release.outputs.minor }}.${{ steps.release.outputs.patch }}
|
75
|
+
token: ${{ secrets.GITHUB_TOKEN }}
|
76
|
+
name: fluent-plugin-mattermost-v${{ steps.release.outputs.major }}.${{ steps.release.outputs.minor }}.${{ steps.release.outputs.patch }}
|
77
|
+
allow_override: true
|
78
|
+
gzip: true
|
79
|
+
files: >
|
80
|
+
fluent-plugin-mattermost-${{ steps.release.outputs.major }}.${{ steps.release.outputs.minor }}.${{ steps.release.outputs.patch }}.gem
|
data/.gitignore
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
.idea
|
1
|
+
.idea
|
2
2
|
*.gem
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
### [0.2.1](https://github.com/levigo-systems/fluent-plugin-mattermost/compare/v0.2.0...v0.2.1) (2022-02-11)
|
4
|
+
|
5
|
+
|
6
|
+
### Bug Fixes
|
7
|
+
|
8
|
+
* replaced the name in fluent-plugin-mattermost ([18a9cea](https://github.com/levigo-systems/fluent-plugin-mattermost/commit/18a9cea4b9038ee374c61c0ff062dc91b9547c3d))
|
9
|
+
|
10
|
+
## 0.2.0 (2022-02-11)
|
11
|
+
|
12
|
+
|
13
|
+
### Features
|
14
|
+
|
15
|
+
* Integration with CICD, creation of a new release and publication on rubygems.org, creation of the package with a new gem to be attached to the release ([7093f42](https://github.com/levigo-systems/fluent-plugin-mattermost/commit/7093f428a21c2d3946115bef26eeeec174316979))
|
16
|
+
* release-please-action version update to 3.1.0 ([b9444de](https://github.com/levigo-systems/fluent-plugin-mattermost/commit/b9444de71edc00c3faa9fb861ec01f1a22c8c0d8))
|
17
|
+
* update plugin version on version.rb ([b9444de](https://github.com/levigo-systems/fluent-plugin-mattermost/commit/b9444de71edc00c3faa9fb861ec01f1a22c8c0d8))
|
18
|
+
|
19
|
+
|
20
|
+
### Bug Fixes
|
21
|
+
|
22
|
+
* changelog.md was added ([7731a36](https://github.com/levigo-systems/fluent-plugin-mattermost/commit/7731a36ae27e4bb91b9b769b912af68210586249))
|
23
|
+
|
24
|
+
|
25
|
+
### Miscellaneous Chores
|
26
|
+
|
27
|
+
* release 0.2.0 ([34deb0b](https://github.com/levigo-systems/fluent-plugin-mattermost/commit/34deb0bde4eaa3fa882ce677e12612e85383f7b2))
|
28
|
+
* release 0.2.0 ([f1f05c5](https://github.com/levigo-systems/fluent-plugin-mattermost/commit/f1f05c5e352b14b8517f51de071d6d6641d0b10b))
|
29
|
+
* release 0.2.0 ([ba03a50](https://github.com/levigo-systems/fluent-plugin-mattermost/commit/ba03a5051c208ec575e6d350abddd562e7a72f25))
|
30
|
+
|
31
|
+
## 0.1.2 (2022-02-09)
|
32
|
+
|
33
|
+
|
34
|
+
### Features
|
35
|
+
|
36
|
+
* test -> old version
|
data/Gemfile
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
source "https://rubygems.org"
|
2
|
-
|
3
|
-
gemspec
|
1
|
+
source "https://rubygems.org"
|
2
|
+
|
3
|
+
gemspec
|
data/LICENSE
CHANGED
@@ -1,201 +1,201 @@
|
|
1
|
-
Apache License
|
2
|
-
Version 2.0, January 2004
|
3
|
-
http://www.apache.org/licenses/
|
4
|
-
|
5
|
-
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
6
|
-
|
7
|
-
1. Definitions.
|
8
|
-
|
9
|
-
"License" shall mean the terms and conditions for use, reproduction,
|
10
|
-
and distribution as defined by Sections 1 through 9 of this document.
|
11
|
-
|
12
|
-
"Licensor" shall mean the copyright owner or entity authorized by
|
13
|
-
the copyright owner that is granting the License.
|
14
|
-
|
15
|
-
"Legal Entity" shall mean the union of the acting entity and all
|
16
|
-
other entities that control, are controlled by, or are under common
|
17
|
-
control with that entity. For the purposes of this definition,
|
18
|
-
"control" means (i) the power, direct or indirect, to cause the
|
19
|
-
direction or management of such entity, whether by contract or
|
20
|
-
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
21
|
-
outstanding shares, or (iii) beneficial ownership of such entity.
|
22
|
-
|
23
|
-
"You" (or "Your") shall mean an individual or Legal Entity
|
24
|
-
exercising permissions granted by this License.
|
25
|
-
|
26
|
-
"Source" form shall mean the preferred form for making modifications,
|
27
|
-
including but not limited to software source code, documentation
|
28
|
-
source, and configuration files.
|
29
|
-
|
30
|
-
"Object" form shall mean any form resulting from mechanical
|
31
|
-
transformation or translation of a Source form, including but
|
32
|
-
not limited to compiled object code, generated documentation,
|
33
|
-
and conversions to other media types.
|
34
|
-
|
35
|
-
"Work" shall mean the work of authorship, whether in Source or
|
36
|
-
Object form, made available under the License, as indicated by a
|
37
|
-
copyright notice that is included in or attached to the work
|
38
|
-
(an example is provided in the Appendix below).
|
39
|
-
|
40
|
-
"Derivative Works" shall mean any work, whether in Source or Object
|
41
|
-
form, that is based on (or derived from) the Work and for which the
|
42
|
-
editorial revisions, annotations, elaborations, or other modifications
|
43
|
-
represent, as a whole, an original work of authorship. For the purposes
|
44
|
-
of this License, Derivative Works shall not include works that remain
|
45
|
-
separable from, or merely link (or bind by name) to the interfaces of,
|
46
|
-
the Work and Derivative Works thereof.
|
47
|
-
|
48
|
-
"Contribution" shall mean any work of authorship, including
|
49
|
-
the original version of the Work and any modifications or additions
|
50
|
-
to that Work or Derivative Works thereof, that is intentionally
|
51
|
-
submitted to Licensor for inclusion in the Work by the copyright owner
|
52
|
-
or by an individual or Legal Entity authorized to submit on behalf of
|
53
|
-
the copyright owner. For the purposes of this definition, "submitted"
|
54
|
-
means any form of electronic, verbal, or written communication sent
|
55
|
-
to the Licensor or its representatives, including but not limited to
|
56
|
-
communication on electronic mailing lists, source code control systems,
|
57
|
-
and issue tracking systems that are managed by, or on behalf of, the
|
58
|
-
Licensor for the purpose of discussing and improving the Work, but
|
59
|
-
excluding communication that is conspicuously marked or otherwise
|
60
|
-
designated in writing by the copyright owner as "Not a Contribution."
|
61
|
-
|
62
|
-
"Contributor" shall mean Licensor and any individual or Legal Entity
|
63
|
-
on behalf of whom a Contribution has been received by Licensor and
|
64
|
-
subsequently incorporated within the Work.
|
65
|
-
|
66
|
-
2. Grant of Copyright License. Subject to the terms and conditions of
|
67
|
-
this License, each Contributor hereby grants to You a perpetual,
|
68
|
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
69
|
-
copyright license to reproduce, prepare Derivative Works of,
|
70
|
-
publicly display, publicly perform, sublicense, and distribute the
|
71
|
-
Work and such Derivative Works in Source or Object form.
|
72
|
-
|
73
|
-
3. Grant of Patent License. Subject to the terms and conditions of
|
74
|
-
this License, each Contributor hereby grants to You a perpetual,
|
75
|
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
76
|
-
(except as stated in this section) patent license to make, have made,
|
77
|
-
use, offer to sell, sell, import, and otherwise transfer the Work,
|
78
|
-
where such license applies only to those patent claims licensable
|
79
|
-
by such Contributor that are necessarily infringed by their
|
80
|
-
Contribution(s) alone or by combination of their Contribution(s)
|
81
|
-
with the Work to which such Contribution(s) was submitted. If You
|
82
|
-
institute patent litigation against any entity (including a
|
83
|
-
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
84
|
-
or a Contribution incorporated within the Work constitutes direct
|
85
|
-
or contributory patent infringement, then any patent licenses
|
86
|
-
granted to You under this License for that Work shall terminate
|
87
|
-
as of the date such litigation is filed.
|
88
|
-
|
89
|
-
4. Redistribution. You may reproduce and distribute copies of the
|
90
|
-
Work or Derivative Works thereof in any medium, with or without
|
91
|
-
modifications, and in Source or Object form, provided that You
|
92
|
-
meet the following conditions:
|
93
|
-
|
94
|
-
(a) You must give any other recipients of the Work or
|
95
|
-
Derivative Works a copy of this License; and
|
96
|
-
|
97
|
-
(b) You must cause any modified files to carry prominent notices
|
98
|
-
stating that You changed the files; and
|
99
|
-
|
100
|
-
(c) You must retain, in the Source form of any Derivative Works
|
101
|
-
that You distribute, all copyright, patent, trademark, and
|
102
|
-
attribution notices from the Source form of the Work,
|
103
|
-
excluding those notices that do not pertain to any part of
|
104
|
-
the Derivative Works; and
|
105
|
-
|
106
|
-
(d) If the Work includes a "NOTICE" text file as part of its
|
107
|
-
distribution, then any Derivative Works that You distribute must
|
108
|
-
include a readable copy of the attribution notices contained
|
109
|
-
within such NOTICE file, excluding those notices that do not
|
110
|
-
pertain to any part of the Derivative Works, in at least one
|
111
|
-
of the following places: within a NOTICE text file distributed
|
112
|
-
as part of the Derivative Works; within the Source form or
|
113
|
-
documentation, if provided along with the Derivative Works; or,
|
114
|
-
within a display generated by the Derivative Works, if and
|
115
|
-
wherever such third-party notices normally appear. The contents
|
116
|
-
of the NOTICE file are for informational purposes only and
|
117
|
-
do not modify the License. You may add Your own attribution
|
118
|
-
notices within Derivative Works that You distribute, alongside
|
119
|
-
or as an addendum to the NOTICE text from the Work, provided
|
120
|
-
that such additional attribution notices cannot be construed
|
121
|
-
as modifying the License.
|
122
|
-
|
123
|
-
You may add Your own copyright statement to Your modifications and
|
124
|
-
may provide additional or different license terms and conditions
|
125
|
-
for use, reproduction, or distribution of Your modifications, or
|
126
|
-
for any such Derivative Works as a whole, provided Your use,
|
127
|
-
reproduction, and distribution of the Work otherwise complies with
|
128
|
-
the conditions stated in this License.
|
129
|
-
|
130
|
-
5. Submission of Contributions. Unless You explicitly state otherwise,
|
131
|
-
any Contribution intentionally submitted for inclusion in the Work
|
132
|
-
by You to the Licensor shall be under the terms and conditions of
|
133
|
-
this License, without any additional terms or conditions.
|
134
|
-
Notwithstanding the above, nothing herein shall supersede or modify
|
135
|
-
the terms of any separate license agreement you may have executed
|
136
|
-
with Licensor regarding such Contributions.
|
137
|
-
|
138
|
-
6. Trademarks. This License does not grant permission to use the trade
|
139
|
-
names, trademarks, service marks, or product names of the Licensor,
|
140
|
-
except as required for reasonable and customary use in describing the
|
141
|
-
origin of the Work and reproducing the content of the NOTICE file.
|
142
|
-
|
143
|
-
7. Disclaimer of Warranty. Unless required by applicable law or
|
144
|
-
agreed to in writing, Licensor provides the Work (and each
|
145
|
-
Contributor provides its Contributions) on an "AS IS" BASIS,
|
146
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
147
|
-
implied, including, without limitation, any warranties or conditions
|
148
|
-
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
149
|
-
PARTICULAR PURPOSE. You are solely responsible for determining the
|
150
|
-
appropriateness of using or redistributing the Work and assume any
|
151
|
-
risks associated with Your exercise of permissions under this License.
|
152
|
-
|
153
|
-
8. Limitation of Liability. In no event and under no legal theory,
|
154
|
-
whether in tort (including negligence), contract, or otherwise,
|
155
|
-
unless required by applicable law (such as deliberate and grossly
|
156
|
-
negligent acts) or agreed to in writing, shall any Contributor be
|
157
|
-
liable to You for damages, including any direct, indirect, special,
|
158
|
-
incidental, or consequential damages of any character arising as a
|
159
|
-
result of this License or out of the use or inability to use the
|
160
|
-
Work (including but not limited to damages for loss of goodwill,
|
161
|
-
work stoppage, computer failure or malfunction, or any and all
|
162
|
-
other commercial damages or losses), even if such Contributor
|
163
|
-
has been advised of the possibility of such damages.
|
164
|
-
|
165
|
-
9. Accepting Warranty or Additional Liability. While redistributing
|
166
|
-
the Work or Derivative Works thereof, You may choose to offer,
|
167
|
-
and charge a fee for, acceptance of support, warranty, indemnity,
|
168
|
-
or other liability obligations and/or rights consistent with this
|
169
|
-
License. However, in accepting such obligations, You may act only
|
170
|
-
on Your own behalf and on Your sole responsibility, not on behalf
|
171
|
-
of any other Contributor, and only if You agree to indemnify,
|
172
|
-
defend, and hold each Contributor harmless for any liability
|
173
|
-
incurred by, or claims asserted against, such Contributor by reason
|
174
|
-
of your accepting any such warranty or additional liability.
|
175
|
-
|
176
|
-
END OF TERMS AND CONDITIONS
|
177
|
-
|
178
|
-
APPENDIX: How to apply the Apache License to your work.
|
179
|
-
|
180
|
-
To apply the Apache License to your work, attach the following
|
181
|
-
boilerplate notice, with the fields enclosed by brackets "[]"
|
182
|
-
replaced with your own identifying information. (Don't include
|
183
|
-
the brackets!) The text should be enclosed in the appropriate
|
184
|
-
comment syntax for the file format. We also recommend that a
|
185
|
-
file or class name and description of purpose be included on the
|
186
|
-
same "printed page" as the copyright notice for easier
|
187
|
-
identification within third-party archives.
|
188
|
-
|
189
|
-
Copyright [yyyy] [name of copyright owner]
|
190
|
-
|
191
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
192
|
-
you may not use this file except in compliance with the License.
|
193
|
-
You may obtain a copy of the License at
|
194
|
-
|
195
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
196
|
-
|
197
|
-
Unless required by applicable law or agreed to in writing, software
|
198
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
199
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
200
|
-
See the License for the specific language governing permissions and
|
201
|
-
limitations under the License.
|
1
|
+
Apache License
|
2
|
+
Version 2.0, January 2004
|
3
|
+
http://www.apache.org/licenses/
|
4
|
+
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
6
|
+
|
7
|
+
1. Definitions.
|
8
|
+
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
11
|
+
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
13
|
+
the copyright owner that is granting the License.
|
14
|
+
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
16
|
+
other entities that control, are controlled by, or are under common
|
17
|
+
control with that entity. For the purposes of this definition,
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
19
|
+
direction or management of such entity, whether by contract or
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
22
|
+
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
24
|
+
exercising permissions granted by this License.
|
25
|
+
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
27
|
+
including but not limited to software source code, documentation
|
28
|
+
source, and configuration files.
|
29
|
+
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
31
|
+
transformation or translation of a Source form, including but
|
32
|
+
not limited to compiled object code, generated documentation,
|
33
|
+
and conversions to other media types.
|
34
|
+
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
36
|
+
Object form, made available under the License, as indicated by a
|
37
|
+
copyright notice that is included in or attached to the work
|
38
|
+
(an example is provided in the Appendix below).
|
39
|
+
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
46
|
+
the Work and Derivative Works thereof.
|
47
|
+
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
49
|
+
the original version of the Work and any modifications or additions
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
61
|
+
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
64
|
+
subsequently incorporated within the Work.
|
65
|
+
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
72
|
+
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
78
|
+
where such license applies only to those patent claims licensable
|
79
|
+
by such Contributor that are necessarily infringed by their
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
82
|
+
institute patent litigation against any entity (including a
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
85
|
+
or contributory patent infringement, then any patent licenses
|
86
|
+
granted to You under this License for that Work shall terminate
|
87
|
+
as of the date such litigation is filed.
|
88
|
+
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
91
|
+
modifications, and in Source or Object form, provided that You
|
92
|
+
meet the following conditions:
|
93
|
+
|
94
|
+
(a) You must give any other recipients of the Work or
|
95
|
+
Derivative Works a copy of this License; and
|
96
|
+
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
98
|
+
stating that You changed the files; and
|
99
|
+
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
102
|
+
attribution notices from the Source form of the Work,
|
103
|
+
excluding those notices that do not pertain to any part of
|
104
|
+
the Derivative Works; and
|
105
|
+
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
108
|
+
include a readable copy of the attribution notices contained
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
111
|
+
of the following places: within a NOTICE text file distributed
|
112
|
+
as part of the Derivative Works; within the Source form or
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
114
|
+
within a display generated by the Derivative Works, if and
|
115
|
+
wherever such third-party notices normally appear. The contents
|
116
|
+
of the NOTICE file are for informational purposes only and
|
117
|
+
do not modify the License. You may add Your own attribution
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
120
|
+
that such additional attribution notices cannot be construed
|
121
|
+
as modifying the License.
|
122
|
+
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
124
|
+
may provide additional or different license terms and conditions
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
128
|
+
the conditions stated in this License.
|
129
|
+
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
133
|
+
this License, without any additional terms or conditions.
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
135
|
+
the terms of any separate license agreement you may have executed
|
136
|
+
with Licensor regarding such Contributions.
|
137
|
+
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
140
|
+
except as required for reasonable and customary use in describing the
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
142
|
+
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
152
|
+
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
158
|
+
incidental, or consequential damages of any character arising as a
|
159
|
+
result of this License or out of the use or inability to use the
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
162
|
+
other commercial damages or losses), even if such Contributor
|
163
|
+
has been advised of the possibility of such damages.
|
164
|
+
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
168
|
+
or other liability obligations and/or rights consistent with this
|
169
|
+
License. However, in accepting such obligations, You may act only
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
174
|
+
of your accepting any such warranty or additional liability.
|
175
|
+
|
176
|
+
END OF TERMS AND CONDITIONS
|
177
|
+
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
179
|
+
|
180
|
+
To apply the Apache License to your work, attach the following
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
182
|
+
replaced with your own identifying information. (Don't include
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
184
|
+
comment syntax for the file format. We also recommend that a
|
185
|
+
file or class name and description of purpose be included on the
|
186
|
+
same "printed page" as the copyright notice for easier
|
187
|
+
identification within third-party archives.
|
188
|
+
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
190
|
+
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
192
|
+
you may not use this file except in compliance with the License.
|
193
|
+
You may obtain a copy of the License at
|
194
|
+
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
196
|
+
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
200
|
+
See the License for the specific language governing permissions and
|
201
|
+
limitations under the License.
|
data/README.md
CHANGED
@@ -1,50 +1,50 @@
|
|
1
|
-
# fluent-plugin-mattermost
|
2
|
-
|
3
|
-
[Fluentd](https://fluentd.org/) output plugin to send message to Mattermost.
|
4
|
-
|
5
|
-
With this plugin you can send messages directly to a channel in Mattermost (for example in case of errors).
|
6
|
-
|
7
|
-
# Installation requirement
|
8
|
-
|
9
|
-
For the plugin to work properly, you need to have the following gem installed
|
10
|
-
- fluent-logger
|
11
|
-
```
|
12
|
-
$ gem install fluent-logger
|
13
|
-
```
|
14
|
-
|
15
|
-
# Installation
|
16
|
-
|
17
|
-
[Installation](documentation/installation.md)
|
18
|
-
[Docker-installation](documentation/docker-installation.md)
|
19
|
-
|
20
|
-
# Usage (Incoming Webhook)
|
21
|
-
Link for
|
22
|
-
[Mattermost incoming webhook](https://docs.mattermost.com/developer/webhooks-incoming.html)
|
23
|
-
|
24
|
-
```apache
|
25
|
-
<match mattermost>
|
26
|
-
@type mattermost
|
27
|
-
webhook_url https://xxx.xx/hooks/xxxxxxxxxxxxxxx
|
28
|
-
channel_id xxxxxxxxxxxxxxx
|
29
|
-
message_color "#FFA500"
|
30
|
-
message_title mattermost
|
31
|
-
message %s
|
32
|
-
enable_tls true
|
33
|
-
</match>
|
34
|
-
```
|
35
|
-
|
36
|
-
### Parameter
|
37
|
-
|
38
|
-
|parameter|description|type|dafault|
|
39
|
-
|---|---|---|---|
|
40
|
-
|webhook_url|Incoming Webhook URI (Required for Incoming Webhook mode). See https://docs.mattermost.com/developer/webhooks-incoming.html|string|nil|
|
41
|
-
|channel_id|the id of the channel where you want to receive the information|string|nil|
|
42
|
-
|message_color|color of the message you are sending, the format is hex code|string|#A9A9A9|
|
43
|
-
|message_title|title you want to add to the message|string|fluent_title_default
|
44
|
-
|message|The message you want to send, can be a static message, which you add at this point, or you can receive the fluent infos with the %s|string|nil
|
45
|
-
|enable_tls|you can set the communication channel if it uses tls|bool|true|
|
46
|
-
|
47
|
-
## Copyright
|
48
|
-
|
49
|
-
* Copyright(c) 2021- [levigo gruppe](https://www.levigo.de/)
|
1
|
+
# fluent-plugin-mattermost
|
2
|
+
|
3
|
+
[Fluentd](https://fluentd.org/) output plugin to send message to Mattermost.
|
4
|
+
|
5
|
+
With this plugin you can send messages directly to a channel in Mattermost (for example in case of errors).
|
6
|
+
|
7
|
+
# Installation requirement
|
8
|
+
|
9
|
+
For the plugin to work properly, you need to have the following gem installed
|
10
|
+
- fluent-logger
|
11
|
+
```
|
12
|
+
$ gem install fluent-logger
|
13
|
+
```
|
14
|
+
|
15
|
+
# Installation
|
16
|
+
|
17
|
+
[Installation](documentation/installation.md)
|
18
|
+
[Docker-installation](documentation/docker-installation.md)
|
19
|
+
|
20
|
+
# Usage (Incoming Webhook)
|
21
|
+
Link for
|
22
|
+
[Mattermost incoming webhook](https://docs.mattermost.com/developer/webhooks-incoming.html)
|
23
|
+
|
24
|
+
```apache
|
25
|
+
<match mattermost>
|
26
|
+
@type mattermost
|
27
|
+
webhook_url https://xxx.xx/hooks/xxxxxxxxxxxxxxx
|
28
|
+
channel_id xxxxxxxxxxxxxxx
|
29
|
+
message_color "#FFA500"
|
30
|
+
message_title mattermost
|
31
|
+
message %s
|
32
|
+
enable_tls true
|
33
|
+
</match>
|
34
|
+
```
|
35
|
+
|
36
|
+
### Parameter
|
37
|
+
|
38
|
+
|parameter|description|type|dafault|
|
39
|
+
|---|---|---|---|
|
40
|
+
|webhook_url|Incoming Webhook URI (Required for Incoming Webhook mode). See https://docs.mattermost.com/developer/webhooks-incoming.html|string|nil|
|
41
|
+
|channel_id|the id of the channel where you want to receive the information|string|nil|
|
42
|
+
|message_color|color of the message you are sending, the format is hex code|string|#A9A9A9|
|
43
|
+
|message_title|title you want to add to the message|string|fluent_title_default
|
44
|
+
|message|The message you want to send, can be a static message, which you add at this point, or you can receive the fluent infos with the %s|string|nil
|
45
|
+
|enable_tls|you can set the communication channel if it uses tls|bool|true|
|
46
|
+
|
47
|
+
## Copyright
|
48
|
+
|
49
|
+
* Copyright(c) 2021- [levigo gruppe](https://www.levigo.de/)
|
50
50
|
* License
|
data/Rakefile
CHANGED
@@ -1,13 +1,13 @@
|
|
1
|
-
require "bundler"
|
2
|
-
Bundler::GemHelper.install_tasks
|
3
|
-
|
4
|
-
require "rake/testtask"
|
5
|
-
|
6
|
-
Rake::TestTask.new(:test) do |t|
|
7
|
-
t.libs.push("lib", "test")
|
8
|
-
t.test_files = FileList["test/**/test_*.rb"]
|
9
|
-
t.verbose = true
|
10
|
-
t.warning = true
|
11
|
-
end
|
12
|
-
|
13
|
-
task default: [:test]
|
1
|
+
require "bundler"
|
2
|
+
Bundler::GemHelper.install_tasks
|
3
|
+
|
4
|
+
require "rake/testtask"
|
5
|
+
|
6
|
+
Rake::TestTask.new(:test) do |t|
|
7
|
+
t.libs.push("lib", "test")
|
8
|
+
t.test_files = FileList["test/**/test_*.rb"]
|
9
|
+
t.verbose = true
|
10
|
+
t.warning = true
|
11
|
+
end
|
12
|
+
|
13
|
+
task default: [:test]
|
@@ -1,13 +1,13 @@
|
|
1
|
-
# Docker installation
|
2
|
-
|
3
|
-
### Dockerfile
|
4
|
-
|
5
|
-
you only need to install the following gem
|
6
|
-
|
7
|
-
```docker
|
8
|
-
...
|
9
|
-
|
10
|
-
RUN gem install fluent-plugin-mattermost
|
11
|
-
|
12
|
-
...
|
1
|
+
# Docker installation
|
2
|
+
|
3
|
+
### Dockerfile
|
4
|
+
|
5
|
+
you only need to install the following gem
|
6
|
+
|
7
|
+
```docker
|
8
|
+
...
|
9
|
+
|
10
|
+
RUN gem install fluent-plugin-mattermost
|
11
|
+
|
12
|
+
...
|
13
13
|
```
|
@@ -1,15 +1,15 @@
|
|
1
|
-
# Installation
|
2
|
-
|
3
|
-
To install the plugin you need to download the package directly from Gitlab and run the installation.
|
4
|
-
|
5
|
-
```
|
6
|
-
$ gem install bundler
|
7
|
-
```
|
8
|
-
```
|
9
|
-
$ rake build
|
10
|
-
```
|
11
|
-
```
|
12
|
-
$ gem install --local ./pkg/fluent-plugin-mattermost-0.1.0.gem
|
13
|
-
```
|
14
|
-
|
1
|
+
# Installation
|
2
|
+
|
3
|
+
To install the plugin you need to download the package directly from Gitlab and run the installation.
|
4
|
+
|
5
|
+
```
|
6
|
+
$ gem install bundler
|
7
|
+
```
|
8
|
+
```
|
9
|
+
$ rake build
|
10
|
+
```
|
11
|
+
```
|
12
|
+
$ gem install --local ./pkg/fluent-plugin-mattermost-0.1.0.gem
|
13
|
+
```
|
14
|
+
|
15
15
|
The installation is completed
|
@@ -1,27 +1,29 @@
|
|
1
|
-
lib = File.expand_path("../lib", __FILE__)
|
2
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
spec.
|
8
|
-
spec.
|
9
|
-
|
10
|
-
spec.
|
11
|
-
|
12
|
-
spec.
|
13
|
-
spec.
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
spec.
|
21
|
-
spec.
|
22
|
-
|
23
|
-
spec.
|
24
|
-
|
25
|
-
spec.add_development_dependency "
|
26
|
-
spec.
|
27
|
-
|
1
|
+
lib = File.expand_path("../lib", __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
|
4
|
+
require_relative "lib/release/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "fluent-plugin-mattermost"
|
8
|
+
spec.version = Release::VERSION
|
9
|
+
spec.authors = ["Pierluigi Minardi"]
|
10
|
+
spec.email = ["p.minardi@levigo.de"]
|
11
|
+
|
12
|
+
spec.summary = "fluent-plugin-mattemost"
|
13
|
+
spec.description = "This plugin allows you to send messages to mattermost in case of errors"
|
14
|
+
spec.homepage = "https://github.com/levigo-systems/fluent-plugin-mattermost"
|
15
|
+
spec.license = "Apache-2.0"
|
16
|
+
|
17
|
+
test_files, files = `git ls-files -z`.split("\x0").partition do |f|
|
18
|
+
f.match(%r{^(test|spec|features)/})
|
19
|
+
end
|
20
|
+
spec.files = files
|
21
|
+
spec.executables = files.grep(%r{^bin/}) { |f| File.basename(f) }
|
22
|
+
spec.test_files = test_files
|
23
|
+
spec.require_paths = ["lib"]
|
24
|
+
|
25
|
+
spec.add_development_dependency "bundler", "~> 2.2.31"
|
26
|
+
spec.add_development_dependency "rake", "~> 13.0.6"
|
27
|
+
spec.add_development_dependency "test-unit", "~> 3.3.9"
|
28
|
+
spec.add_runtime_dependency "fluentd", [">= 0.14.10", "< 2"]
|
29
|
+
end
|
@@ -1,109 +1,109 @@
|
|
1
|
-
require "fluent/plugin/output"
|
2
|
-
require 'fluent-logger'
|
3
|
-
require 'uri'
|
4
|
-
require 'net/http'
|
5
|
-
require 'net/https'
|
6
|
-
require 'logger'
|
7
|
-
require "json"
|
8
|
-
|
9
|
-
module Fluent
|
10
|
-
module Plugin
|
11
|
-
class MattermostOutput < Fluent::Plugin::Output
|
12
|
-
Fluent::Plugin.register_output("mattermost", self)
|
13
|
-
|
14
|
-
# Required parameter: The configuration must have this parameter like 'param1 10'.
|
15
|
-
config_param :webhook_url, :string, default: nil
|
16
|
-
|
17
|
-
config_param :channel_id, :string, default: nil
|
18
|
-
|
19
|
-
config_param :message_title, :string, default: "fluent_title_default"
|
20
|
-
|
21
|
-
config_param :message_color, :string, default: "#A9A9A9"
|
22
|
-
|
23
|
-
config_param :message, :string, default: nil
|
24
|
-
|
25
|
-
config_param :enable_tls, :bool, default: true
|
26
|
-
|
27
|
-
def configure(conf)
|
28
|
-
super
|
29
|
-
end
|
30
|
-
|
31
|
-
def start
|
32
|
-
super
|
33
|
-
check_config_params
|
34
|
-
end
|
35
|
-
|
36
|
-
def write(chunk)
|
37
|
-
begin
|
38
|
-
message = get_infos(chunk)
|
39
|
-
|
40
|
-
post(message)
|
41
|
-
rescue Timeout::Error => e
|
42
|
-
log.warn "out_mattermost:", :error => e.to_s, :error_class => e.class.to_s
|
43
|
-
raise e # let Fluentd retry
|
44
|
-
rescue => e
|
45
|
-
log.error "out_mattermost:", :error => e.to_s, :error_class => e.class.to_s
|
46
|
-
log.warn_backtrace e.backtrace
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
def post(payload)
|
51
|
-
|
52
|
-
url = URI(@webhook_url)
|
53
|
-
|
54
|
-
https = Net::HTTP.new(url.host, url.port)
|
55
|
-
https.use_ssl = @enable_tls
|
56
|
-
|
57
|
-
request = Net::HTTP::Post.new(url)
|
58
|
-
request["Content-Type"] = "application/json"
|
59
|
-
request.body = JSON.dump({
|
60
|
-
"channel_id": @channel_id,
|
61
|
-
"attachments": message(payload)
|
62
|
-
})
|
63
|
-
response = https.request(request)
|
64
|
-
|
65
|
-
if response.read_body != "ok"
|
66
|
-
log.error "response from mattermost: ", response.read_body
|
67
|
-
else
|
68
|
-
puts response.read_body
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
def message(record)
|
73
|
-
payload = [{
|
74
|
-
"author_name": "Fluentd",
|
75
|
-
"thumb_url": "https://coralogix.com/wp-content/uploads/2020/04/fluentd-guide-700x430.png",
|
76
|
-
"color": @message_color,
|
77
|
-
"fields": [
|
78
|
-
{
|
79
|
-
"short": false,
|
80
|
-
"title": @message_title,
|
81
|
-
"value": record
|
82
|
-
}]
|
83
|
-
}]
|
84
|
-
return payload
|
85
|
-
end
|
86
|
-
|
87
|
-
def get_infos(chunk)
|
88
|
-
messages = []
|
89
|
-
messages << "\n"
|
90
|
-
chunk.msgpack_each do |time, record|
|
91
|
-
messages << "#{build_message(record)}\n"
|
92
|
-
end
|
93
|
-
|
94
|
-
return messages
|
95
|
-
end
|
96
|
-
|
97
|
-
def build_message(record)
|
98
|
-
@message % record.to_json
|
99
|
-
end
|
100
|
-
|
101
|
-
def check_config_params()
|
102
|
-
if @webhook_url.nil? || @channel_id.nil? || @message.nil?
|
103
|
-
raise "Check in your Mattermost config, that all parameters in the configuration file are filled"
|
104
|
-
abort
|
105
|
-
end
|
106
|
-
end
|
107
|
-
end
|
108
|
-
end
|
109
|
-
end
|
1
|
+
require "fluent/plugin/output"
|
2
|
+
require 'fluent-logger'
|
3
|
+
require 'uri'
|
4
|
+
require 'net/http'
|
5
|
+
require 'net/https'
|
6
|
+
require 'logger'
|
7
|
+
require "json"
|
8
|
+
|
9
|
+
module Fluent
|
10
|
+
module Plugin
|
11
|
+
class MattermostOutput < Fluent::Plugin::Output
|
12
|
+
Fluent::Plugin.register_output("mattermost", self)
|
13
|
+
|
14
|
+
# Required parameter: The configuration must have this parameter like 'param1 10'.
|
15
|
+
config_param :webhook_url, :string, default: nil
|
16
|
+
|
17
|
+
config_param :channel_id, :string, default: nil
|
18
|
+
|
19
|
+
config_param :message_title, :string, default: "fluent_title_default"
|
20
|
+
|
21
|
+
config_param :message_color, :string, default: "#A9A9A9"
|
22
|
+
|
23
|
+
config_param :message, :string, default: nil
|
24
|
+
|
25
|
+
config_param :enable_tls, :bool, default: true
|
26
|
+
|
27
|
+
def configure(conf)
|
28
|
+
super
|
29
|
+
end
|
30
|
+
|
31
|
+
def start
|
32
|
+
super
|
33
|
+
check_config_params
|
34
|
+
end
|
35
|
+
|
36
|
+
def write(chunk)
|
37
|
+
begin
|
38
|
+
message = get_infos(chunk)
|
39
|
+
|
40
|
+
post(message)
|
41
|
+
rescue Timeout::Error => e
|
42
|
+
log.warn "out_mattermost:", :error => e.to_s, :error_class => e.class.to_s
|
43
|
+
raise e # let Fluentd retry
|
44
|
+
rescue => e
|
45
|
+
log.error "out_mattermost:", :error => e.to_s, :error_class => e.class.to_s
|
46
|
+
log.warn_backtrace e.backtrace
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def post(payload)
|
51
|
+
|
52
|
+
url = URI(@webhook_url)
|
53
|
+
|
54
|
+
https = Net::HTTP.new(url.host, url.port)
|
55
|
+
https.use_ssl = @enable_tls
|
56
|
+
|
57
|
+
request = Net::HTTP::Post.new(url)
|
58
|
+
request["Content-Type"] = "application/json"
|
59
|
+
request.body = JSON.dump({
|
60
|
+
"channel_id": @channel_id,
|
61
|
+
"attachments": message(payload)
|
62
|
+
})
|
63
|
+
response = https.request(request)
|
64
|
+
|
65
|
+
if response.read_body != "ok"
|
66
|
+
log.error "response from mattermost: ", response.read_body
|
67
|
+
else
|
68
|
+
puts response.read_body
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def message(record)
|
73
|
+
payload = [{
|
74
|
+
"author_name": "Fluentd",
|
75
|
+
"thumb_url": "https://coralogix.com/wp-content/uploads/2020/04/fluentd-guide-700x430.png",
|
76
|
+
"color": @message_color,
|
77
|
+
"fields": [
|
78
|
+
{
|
79
|
+
"short": false,
|
80
|
+
"title": @message_title,
|
81
|
+
"value": record
|
82
|
+
}]
|
83
|
+
}]
|
84
|
+
return payload
|
85
|
+
end
|
86
|
+
|
87
|
+
def get_infos(chunk)
|
88
|
+
messages = []
|
89
|
+
messages << "\n"
|
90
|
+
chunk.msgpack_each do |time, record|
|
91
|
+
messages << "#{build_message(record)}\n"
|
92
|
+
end
|
93
|
+
|
94
|
+
return messages
|
95
|
+
end
|
96
|
+
|
97
|
+
def build_message(record)
|
98
|
+
@message % record.to_json
|
99
|
+
end
|
100
|
+
|
101
|
+
def check_config_params()
|
102
|
+
if @webhook_url.nil? || @channel_id.nil? || @message.nil?
|
103
|
+
raise "Check in your Mattermost config, that all parameters in the configuration file are filled"
|
104
|
+
abort
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
data/test/helper.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
$LOAD_PATH.unshift(File.expand_path("../../", __FILE__))
|
2
|
-
require "test-unit"
|
3
|
-
require "fluent/test"
|
4
|
-
require "fluent/test/driver/output"
|
5
|
-
require "fluent/test/helpers"
|
6
|
-
|
7
|
-
Test::Unit::TestCase.include(Fluent::Test::Helpers)
|
8
|
-
Test::Unit::TestCase.extend(Fluent::Test::Helpers)
|
1
|
+
$LOAD_PATH.unshift(File.expand_path("../../", __FILE__))
|
2
|
+
require "test-unit"
|
3
|
+
require "fluent/test"
|
4
|
+
require "fluent/test/driver/output"
|
5
|
+
require "fluent/test/helpers"
|
6
|
+
|
7
|
+
Test::Unit::TestCase.include(Fluent::Test::Helpers)
|
8
|
+
Test::Unit::TestCase.extend(Fluent::Test::Helpers)
|
@@ -1,18 +1,18 @@
|
|
1
|
-
require "helper"
|
2
|
-
require "fluent/plugin/out_mattermost.rb"
|
3
|
-
|
4
|
-
class MattermostOutputTest < Test::Unit::TestCase
|
5
|
-
setup do
|
6
|
-
Fluent::Test.setup
|
7
|
-
end
|
8
|
-
|
9
|
-
test "failure" do
|
10
|
-
flunk
|
11
|
-
end
|
12
|
-
|
13
|
-
private
|
14
|
-
|
15
|
-
def create_driver(conf)
|
16
|
-
Fluent::Test::Driver::Output.new(Fluent::Plugin::MattermostOutput).configure(conf)
|
17
|
-
end
|
18
|
-
end
|
1
|
+
require "helper"
|
2
|
+
require "fluent/plugin/out_mattermost.rb"
|
3
|
+
|
4
|
+
class MattermostOutputTest < Test::Unit::TestCase
|
5
|
+
setup do
|
6
|
+
Fluent::Test.setup
|
7
|
+
end
|
8
|
+
|
9
|
+
test "failure" do
|
10
|
+
flunk
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def create_driver(conf)
|
16
|
+
Fluent::Test::Driver::Output.new(Fluent::Plugin::MattermostOutput).configure(conf)
|
17
|
+
end
|
18
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-mattermost
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pierluigi Minardi
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-02-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -79,7 +79,9 @@ executables: []
|
|
79
79
|
extensions: []
|
80
80
|
extra_rdoc_files: []
|
81
81
|
files:
|
82
|
+
- ".github/workflows/release.yml"
|
82
83
|
- ".gitignore"
|
84
|
+
- CHANGELOG.md
|
83
85
|
- Gemfile
|
84
86
|
- LICENSE
|
85
87
|
- README.md
|
@@ -88,13 +90,14 @@ files:
|
|
88
90
|
- documentation/installation.md
|
89
91
|
- fluent-plugin-mattermost.gemspec
|
90
92
|
- lib/fluent/plugin/out_mattermost.rb
|
93
|
+
- lib/release/version.rb
|
91
94
|
- test/helper.rb
|
92
95
|
- test/plugin/test_out_mattermost.rb
|
93
96
|
homepage: https://github.com/levigo-systems/fluent-plugin-mattermost
|
94
97
|
licenses:
|
95
98
|
- Apache-2.0
|
96
99
|
metadata: {}
|
97
|
-
post_install_message:
|
100
|
+
post_install_message:
|
98
101
|
rdoc_options: []
|
99
102
|
require_paths:
|
100
103
|
- lib
|
@@ -109,8 +112,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
109
112
|
- !ruby/object:Gem::Version
|
110
113
|
version: '0'
|
111
114
|
requirements: []
|
112
|
-
rubygems_version: 3.2.
|
113
|
-
signing_key:
|
115
|
+
rubygems_version: 3.2.22
|
116
|
+
signing_key:
|
114
117
|
specification_version: 4
|
115
118
|
summary: fluent-plugin-mattemost
|
116
119
|
test_files:
|