Skip to content

Instantly share code, notes, and snippets.

View lennartkoopmann's full-sized avatar
🤠

Lennart Koopmann lennartkoopmann

🤠
View GitHub Profile
Input string:
2015-12-15T07:36:25+00:00 sundaysister kernel[0]: **** [IOBluetoothHostControllerUSBTransport][ClearFeatureInterruptEndpointHalt] -- successfully posting another read for the mInt0InterruptPipe -- mInterruptPipeInOutstandingIOCount = 1 -- this = 0xb800";
veryDescriptiveMatch: ^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\+\d{2}:\d{2}
descriptiveMatch: .{4}-.{2}-.{2}T.{2}:.{2}:.{2}\+.{2}:.{2}
openMatch: .*-.*-.*T.*:.*:.*\+
@State(Scope.Benchmark)
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.MICROSECONDS)
public class DateRegexBenchmark {
private static final String MESSAGE = "2015-12-15T07:36:25+00:00 sundaysister kernel[0]: **** [IOBluetoothHostControllerUSBTransport][ClearFeatureInterruptEndpointHalt] -- successfully posting another read for the mInt0InterruptPipe -- mInterruptPipeInOutstandingIOCount = 1 -- this = 0xb800";
private static Pattern VERY_DESCRIPTIVE;
private static Pattern DESCRIPTIVE;
private static Pattern OPEN;
# Run complete. Total time: 00:03:53
Benchmark Mode Cnt Score Error Units
DateRegexBenchmark.descriptiveMatch avgt 50 0.237 ± 0.003 us/op
DateRegexBenchmark.openMatch avgt 50 32.325 ± 0.361 us/op
DateRegexBenchmark.veryDescriptiveMatch avgt 50 0.190 ± 0.002 us/op
import org.graylog2.plugin.Message
import java.util.regex.Matcher
import java.util.regex.Pattern
rule "Rename level field to avoid ES type collision"
when
m : Message( message matches ".*level=.*" );
then
Matcher matcher = Pattern.compile("level=(.+?)(\\s|$)").matcher(m.getMessage());
if (matcher.find()) {
lennart ~/workspace/graylog2/graylog2-server(0.20)$ mongo
MongoDB shell version: 2.4.1
connecting to: test
> use graylog2
switched to db graylog2
> db.system_messages.remove()
2014-03-13 12:05:13,673 INFO : org.graylog2.Core - SIGNAL received. Shutting down.
2014-03-13 12:05:13,676 INFO : org.graylog2.system.shutdown.GracefulShutdown - Graceful shutdown initiated.
2014-03-13 12:05:14,677 INFO : org.graylog2.system.shutdown.GracefulShutdown - Attempting to close input <org.graylog2.inputs.random.FakeHttpMessageInput.52d693bb300492055ae543f5> [Random HTTP message generator].
2014-03-13 12:05:14,678 INFO : org.graylog2.system.shutdown.GracefulShutdown - Input [org.graylog2.inputs.random.FakeHttpMessageInput.52d693bb300492055ae543f5] closed. Took [0ms]
2014-03-13 12:05:14,678 INFO : org.graylog2.system.shutdown.GracefulShutdown - Attempting to close input <org.graylog2.inputs.gelf.udp.GELFUDPInput.52ddb63b300472bb4ed52012> [GELF UDP].
2014-03-13 12:05:14,680 INFO : org.graylog2.system.shutdown.GracefulShutdown - Input [org.graylog2.inputs.gelf.udp.GELFUDPInput.52ddb63b300472bb4ed52012] closed. Took [2ms]
2014-03-13 12:05:14,681 INFO : org.graylog2.system.shutdown.GracefulShutdown - Att
2.0.0p0 :001 > Time.now
=> 2014-02-21 19:41:13 +0100
2.0.0p0 :002 > Time.now.utc.iso8601
NoMethodError: undefined method `iso8601' for 2014-02-21 18:41:16 UTC:Time
from (irb):2
from /Users/lennart/.rvm/rubies/ruby-2.0.0-p0/bin/irb:16:in `<main>'
2.0.0p0 :003 > require 'time'
=> true
2.0.0p0 :004 > Time.now.utc.iso8601
=> "2014-02-21T18:41:20Z"
import org.graylog2.plugin.Message
rule "reproduce IRC issue"
when
m : Message( getField("message") matches "(?i).*mycrazystringtotrack(.|\n|\r)*" )
then
m.addField("track", "crazystring" );
System.out.println("matched!");
end
2014-01-11 17:40:14,349 DEBUG: org.graylog2.periodical.AlertScannerThread - Running alert checks.
2014-01-11 17:40:14,350 DEBUG: org.graylog2.periodical.AlertScannerThread - There are 1 streams with configured alert conditions.
2014-01-11 17:40:14,350 DEBUG: org.graylog2.periodical.AlertScannerThread - Stream [52d153f3300497641fae85c3: "Alerts test"] has [1] configured alert conditions.
2014-01-11 17:40:14,350 DEBUG: org.graylog2.alerts.AlertCondition - Checking alert condition [892e7056-7640-46c5-8def-8a7a5efdd59e:MESSAGE_COUNT={time: 1, threshold_type: more, threshold: 10, grace: 2}, stream:={52d153f3300497641fae85c3: "Alerts test"}]
2014-01-11 17:40:14,353 DEBUG: org.graylog2.alerts.types.MessageCountAlertCondition - Alert check <892e7056-7640-46c5-8def-8a7a5efdd59e> result: [20]
2014-01-11 17:40:14,353 INFO : org.graylog2.periodical.AlertScannerThread - Alert condition [892e7056-7640-46c5-8def-8a7a5efdd59e:MESSAGE_COUNT={time: 1, threshold_type: more, threshold: 10, grace: 2}, stream:={52d153f3300497641fa
@lennartkoopmann
lennartkoopmann / StreamsResource.java
Created January 9, 2014 13:42
Graylog2 REST resource method head
@RequiresAuthentication
@Api(value = "Streams", description = "Manage streams")
@Path("/streams")
public class StreamResource extends RestResource {
...
@PUT @Timed
@Path("/{streamId}")
@ApiOperation(value = "Update a stream")