|
43 | 43 | <bnd-module-name>org.apache.logging.log4j.layout.template.json.test</bnd-module-name>
|
44 | 44 | <Fragment-Host>org.apache.logging.log4j.core</Fragment-Host>
|
45 | 45 |
|
| 46 | + <!-- `elastic.version` is used for two purposes: |
| 47 | +
|
| 48 | + 1. `co.elastic.clients:elasticsearch-java` version |
| 49 | + 2. The Docker image version of the ELK-stack |
| 50 | +
|
| 51 | + As of 2024-09-16, these all (Maven artifacts and Elastic products) get released with the same version. --> |
| 52 | + <elastic.version>8.15.1</elastic.version> |
| 53 | + |
46 | 54 | </properties>
|
47 | 55 |
|
48 | 56 | <dependencies>
|
|
85 | 93 | <dependency>
|
86 | 94 | <groupId>co.elastic.clients</groupId>
|
87 | 95 | <artifactId>elasticsearch-java</artifactId>
|
| 96 | + <version>${elastic.version}</version> |
88 | 97 | <scope>test</scope>
|
89 | 98 | </dependency>
|
90 | 99 |
|
|
129 | 138 | <build>
|
130 | 139 | <plugins>
|
131 | 140 |
|
132 |
| - <!-- Disable ITs, which are Docker-dependent, by default. --> |
133 |
| - <plugin> |
134 |
| - <groupId>org.apache.maven.plugins</groupId> |
135 |
| - <artifactId>maven-failsafe-plugin</artifactId> |
136 |
| - <configuration> |
137 |
| - <skip>true</skip> |
138 |
| - </configuration> |
139 |
| - <executions> |
140 |
| - <execution> |
141 |
| - <goals> |
142 |
| - <goal>integration-test</goal> |
143 |
| - <goal>verify</goal> |
144 |
| - </goals> |
145 |
| - </execution> |
146 |
| - </executions> |
147 |
| - </plugin> |
148 |
| - |
149 | 141 | <plugin>
|
150 | 142 | <groupId>org.apache.maven.plugins</groupId>
|
151 | 143 | <artifactId>maven-surefire-plugin</artifactId>
|
|
170 | 162 |
|
171 | 163 | <id>docker</id>
|
172 | 164 |
|
| 165 | + <!-- |
| 166 | + ~ Only the `ubuntu` CI runners have access to Docker |
| 167 | + --> |
173 | 168 | <activation>
|
174 |
| - <activeByDefault>false</activeByDefault> |
| 169 | + <os> |
| 170 | + <family>linux</family> |
| 171 | + </os> |
| 172 | + <property> |
| 173 | + <name>env.CI</name> |
| 174 | + <value>true</value> |
| 175 | + </property> |
175 | 176 | </activation>
|
176 | 177 |
|
177 | 178 | <properties>
|
178 |
| - <elastic.version>8.10.2</elastic.version> |
| 179 | + |
| 180 | + <!-- Suppress `docker-maven-plugin` output --> |
| 181 | + <docker.showLogs>false</docker.showLogs> |
| 182 | + <docker.verbose>false</docker.verbose> |
| 183 | + |
179 | 184 | <!-- `docker run elasticsearch:<TAG>` exists with code 137 due to insufficient memory.
|
180 | 185 | We limit the used JVM memory to avoid this OOM failure. -->
|
181 |
| - <elastic.java-opts>-Xms750m -Xmx750m</elastic.java-opts> |
| 186 | + <elastic.javaOpts>-Xms750m -Xmx750m</elastic.javaOpts> |
| 187 | + |
182 | 188 | </properties>
|
183 | 189 |
|
184 | 190 | <build>
|
|
188 | 194 | <groupId>io.fabric8</groupId>
|
189 | 195 | <artifactId>docker-maven-plugin</artifactId>
|
190 | 196 | <configuration>
|
191 |
| - <verbose>all</verbose> |
192 | 197 | <startParallel>true</startParallel>
|
193 | 198 | <autoCreateCustomNetworks>true</autoCreateCustomNetworks>
|
194 | 199 | <images>
|
|
199 | 204 | <env>
|
200 | 205 | <discovery.type>single-node</discovery.type>
|
201 | 206 | <xpack.security.enabled>false</xpack.security.enabled>
|
202 |
| - <ES_JAVA_OPTS>${elastic.java-opts}</ES_JAVA_OPTS> |
| 207 | + <ES_JAVA_OPTS>${elastic.javaOpts}</ES_JAVA_OPTS> |
203 | 208 | </env>
|
204 | 209 | <ports>
|
205 |
| - <port>9200:9200</port> |
| 210 | + <!-- Binds an ephemeral port to the `elasticsearch.port` Maven property. --> |
| 211 | + <port>localhost:elasticsearch.port:9200</port> |
206 | 212 | </ports>
|
207 | 213 | <network>
|
208 | 214 | <mode>custom</mode>
|
|
214 | 220 | <color>cyan</color>
|
215 | 221 | </log>
|
216 | 222 | <wait>
|
217 |
| - <log>recovered \[0\] indices into cluster_state</log> |
| 223 | + <tcp> |
| 224 | + <ports> |
| 225 | + <port>9200</port> |
| 226 | + </ports> |
| 227 | + </tcp> |
218 | 228 | <time>60000</time>
|
219 | 229 | </wait>
|
220 | 230 | </run>
|
|
232 | 242 | <alias>logstash</alias>
|
233 | 243 | </network>
|
234 | 244 | <env>
|
235 |
| - <LS_JAVA_OPTS>${elastic.java-opts}</LS_JAVA_OPTS> |
| 245 | + <LS_JAVA_OPTS>${elastic.javaOpts}</LS_JAVA_OPTS> |
236 | 246 | </env>
|
237 | 247 | <ports>
|
238 |
| - <port>12222:12222</port> |
239 |
| - <port>12345:12345</port> |
| 248 | + <!-- Binds an ephemeral port to the `logstash.gelf.port` Maven property. --> |
| 249 | + <port>localhost:logstash.gelf.port:12222</port> |
| 250 | + <!-- Binds an ephemeral port to the `logstash.tcp.port` Maven property. --> |
| 251 | + <port>localhost:logstash.tcp.port:12345</port> |
240 | 252 | </ports>
|
241 | 253 | <log>
|
242 | 254 | <prefix>[LS]</prefix>
|
|
248 | 260 | <arg>--pipeline.batch.size</arg>
|
249 | 261 | <arg>1</arg>
|
250 | 262 | <arg>-e</arg>
|
251 |
| - <arg>input { |
| 263 | + <arg><![CDATA[ |
| 264 | +
|
| 265 | + input { |
| 266 | +
|
| 267 | + # Documentation: https://www.elastic.co/guide/en/logstash/current/plugins-inputs-gelf.html |
252 | 268 | gelf {
|
253 |
| - host => "logstash" |
254 |
| - use_tcp => true |
255 |
| - use_udp => false |
256 |
| - port => 12222 |
257 |
| - type => "gelf" |
| 269 | + host => "logstash" |
| 270 | + use_tcp => true |
| 271 | + use_udp => false |
| 272 | + port => 12222 |
| 273 | + type => "gelf" |
258 | 274 | }
|
| 275 | +
|
| 276 | + # Documentation: https://www.elastic.co/guide/en/logstash/current/plugins-inputs-tcp.html |
259 | 277 | tcp {
|
260 |
| - port => 12345 |
261 |
| - codec => json |
262 |
| - type => "tcp" |
| 278 | + port => 12345 |
| 279 | + codec => json |
| 280 | + type => "tcp" |
263 | 281 | }
|
| 282 | +
|
264 | 283 | }
|
265 | 284 |
|
266 | 285 | filter {
|
267 | 286 | if [type] == "gelf" {
|
268 | 287 | # These are GELF/Syslog logging levels as defined in RFC 3164.
|
269 |
| - # Map the integer level to its human readable format. |
| 288 | + # Map the integer level to its human-readable format. |
| 289 | + # Documentation: https://www.elastic.co/guide/en/logstash/current/plugins-filters-translate.html |
270 | 290 | translate {
|
271 |
| - field => "[level]" |
272 |
| - destination => "[levelName]" |
273 |
| - dictionary => { |
274 |
| - "0" => "EMERG" |
275 |
| - "1" => "ALERT" |
276 |
| - "2" => "CRITICAL" |
277 |
| - "3" => "ERROR" |
278 |
| - "4" => "WARN" |
279 |
| - "5" => "NOTICE" |
280 |
| - "6" => "INFO" |
281 |
| - "7" => "DEBUG" |
| 291 | + source => "[level]" |
| 292 | + target => "[levelName]" |
| 293 | + dictionary => { |
| 294 | + "0" => "EMERG" |
| 295 | + "1" => "ALERT" |
| 296 | + "2" => "CRITICAL" |
| 297 | + "3" => "ERROR" |
| 298 | + "4" => "WARN" |
| 299 | + "5" => "NOTICE" |
| 300 | + "6" => "INFO" |
| 301 | + "7" => "DEBUG" |
282 | 302 | }
|
283 | 303 | }
|
284 | 304 | }
|
285 | 305 | }
|
286 | 306 |
|
| 307 | + # Documentation: https://www.elastic.co/guide/en/logstash/current/plugins-filters-elasticsearch.html |
287 | 308 | output {
|
288 | 309 | # (Un)comment for debugging purposes
|
289 |
| - # stdout { codec => rubydebug } |
| 310 | + # stdout { codec => rubydebug } |
290 | 311 | elasticsearch {
|
291 |
| - hosts => ["http://elasticsearch:9200"] |
292 |
| - index => "log4j" |
| 312 | + hosts => ["http://elasticsearch:9200"] |
| 313 | + index => "log4j" |
293 | 314 | }
|
294 |
| - }</arg> |
| 315 | + } |
| 316 | +
|
| 317 | + ]]></arg> |
295 | 318 | </exec>
|
296 | 319 | </entrypoint>
|
297 | 320 | <wait>
|
298 |
| - <log>Successfully started Logstash API endpoint</log> |
| 321 | + <tcp> |
| 322 | + <host>localhost</host> |
| 323 | + <ports> |
| 324 | + <port>12222</port> |
| 325 | + <port>12345</port> |
| 326 | + </ports> |
| 327 | + </tcp> |
299 | 328 | <time>60000</time>
|
300 | 329 | </wait>
|
301 | 330 | </run>
|
|
327 | 356 | <includes>
|
328 | 357 | <include>**/*IT.java</include>
|
329 | 358 | </includes>
|
| 359 | + <systemPropertyVariables> |
| 360 | + <log4j.elasticsearch.port>${elasticsearch.port}</log4j.elasticsearch.port> |
| 361 | + <log4j.logstash.gelf.port>${logstash.gelf.port}</log4j.logstash.gelf.port> |
| 362 | + <log4j.logstash.tcp.port>${logstash.tcp.port}</log4j.logstash.tcp.port> |
| 363 | + </systemPropertyVariables> |
330 | 364 | </configuration>
|
331 | 365 | <executions>
|
332 | 366 | <execution>
|
|
0 commit comments