Search in sources :

Example 56 with Message

use of org.graylog2.plugin.Message in project graylog2-server by Graylog2.

the class FunctionsSnippetsTest method split.

@Test
public void split() {
    final Rule rule = parser.parseRule(ruleForTest(), false);
    final Message message = evaluateRule(rule);
    assertThat(actionsTriggered.get()).isTrue();
    assertThat(message).isNotNull();
    assertThat(message.getField("limit_0")).asList().isNotEmpty().containsExactly("foo", "bar", "baz");
    assertThat(message.getField("limit_1")).asList().isNotEmpty().containsExactly("foo:bar:baz");
    assertThat(message.getField("limit_2")).asList().isNotEmpty().containsExactly("foo", "bar|baz");
}
Also used : CreateMessage(org.graylog.plugins.pipelineprocessor.functions.messages.CreateMessage) CloneMessage(org.graylog.plugins.pipelineprocessor.functions.messages.CloneMessage) DropMessage(org.graylog.plugins.pipelineprocessor.functions.messages.DropMessage) Message(org.graylog2.plugin.Message) MockitoRule(org.mockito.junit.MockitoRule) Rule(org.graylog.plugins.pipelineprocessor.ast.Rule) BaseParserTest(org.graylog.plugins.pipelineprocessor.BaseParserTest) Test(org.junit.Test)

Example 57 with Message

use of org.graylog2.plugin.Message in project graylog2-server by Graylog2.

the class PipelineRuleParserTest method messageRef.

@Test
public void messageRef() throws Exception {
    final Rule rule = parseRuleWithOptionalCodegen();
    Message message = new Message("hello test", "source", DateTime.now(DateTimeZone.UTC));
    message.addField("responseCode", 500);
    final Message processedMsg = evaluateRule(rule, message);
    assertNotNull(processedMsg);
    assertEquals("server_error", processedMsg.getField("response_category"));
}
Also used : Message(org.graylog2.plugin.Message) Rule(org.graylog.plugins.pipelineprocessor.ast.Rule) BaseParserTest(org.graylog.plugins.pipelineprocessor.BaseParserTest) Test(org.junit.Test)

Example 58 with Message

use of org.graylog2.plugin.Message in project graylog2-server by Graylog2.

the class PipelineRuleParserTest method indexedAccess.

@Test
public void indexedAccess() {
    final Rule rule = parseRuleWithOptionalCodegen();
    evaluateRule(rule, new Message("hallo", "test", DateTime.now(DateTimeZone.UTC)));
    assertTrue("condition should be true", actionsTriggered.get());
}
Also used : Message(org.graylog2.plugin.Message) Rule(org.graylog.plugins.pipelineprocessor.ast.Rule) BaseParserTest(org.graylog.plugins.pipelineprocessor.BaseParserTest) Test(org.junit.Test)

Example 59 with Message

use of org.graylog2.plugin.Message in project graylog2-server by Graylog2.

the class PipelineRuleParserTest method nestedFieldAccess.

@Test
public void nestedFieldAccess() throws Exception {
    final Rule rule = parseRuleWithOptionalCodegen();
    evaluateRule(rule, new Message("hello", "world", DateTime.now(DateTimeZone.UTC)));
    assertTrue("condition should be true", actionsTriggered.get());
}
Also used : Message(org.graylog2.plugin.Message) Rule(org.graylog.plugins.pipelineprocessor.ast.Rule) BaseParserTest(org.graylog.plugins.pipelineprocessor.BaseParserTest) Test(org.junit.Test)

Example 60 with Message

use of org.graylog2.plugin.Message in project graylog2-server by Graylog2.

the class PipelineInterpreterTest method messageInDefaultStream.

private Message messageInDefaultStream(String message, String source) {
    final Message msg = new Message(message, source, Tools.nowUTC());
    final Stream mockedStream = mock(Stream.class);
    when(mockedStream.getId()).thenReturn(DEFAULT_STREAM_ID);
    msg.addStream(mockedStream);
    return msg;
}
Also used : CreateMessage(org.graylog.plugins.pipelineprocessor.functions.messages.CreateMessage) DropMessage(org.graylog.plugins.pipelineprocessor.functions.messages.DropMessage) Message(org.graylog2.plugin.Message) Stream(org.graylog2.plugin.streams.Stream)

Aggregations

Message (org.graylog2.plugin.Message)420 Test (org.junit.Test)391 ApiOperation (io.swagger.annotations.ApiOperation)120 ApiResponses (io.swagger.annotations.ApiResponses)107 Timed (com.codahale.metrics.annotation.Timed)105 RawMessage (org.graylog2.plugin.journal.RawMessage)103 DateTime (org.joda.time.DateTime)102 Path (javax.ws.rs.Path)87 StreamRule (org.graylog2.plugin.streams.StreamRule)77 AuditEvent (org.graylog2.audit.jersey.AuditEvent)69 Produces (javax.ws.rs.Produces)57 Stream (org.graylog2.plugin.streams.Stream)55 CreateMessage (org.graylog.plugins.pipelineprocessor.functions.messages.CreateMessage)46 DropMessage (org.graylog.plugins.pipelineprocessor.functions.messages.DropMessage)46 BaseParserTest (org.graylog.plugins.pipelineprocessor.BaseParserTest)45 Rule (org.graylog.plugins.pipelineprocessor.ast.Rule)45 POST (javax.ws.rs.POST)41 GET (javax.ws.rs.GET)40 CloneMessage (org.graylog.plugins.pipelineprocessor.functions.messages.CloneMessage)36 MockitoRule (org.mockito.junit.MockitoRule)35