use of org.graylog2.inputs.random.generators.FakeHttpRawMessageGenerator.GeneratorState in project graylog2-server by Graylog2.
the class RandomHttpMessageCodec method decode.
@Nullable
@Override
public Message decode(@Nonnull RawMessage rawMessage) {
if (!rawMessage.getCodecName().equals(getName())) {
log.error("Cannot decode payload type {}, skipping message {}", rawMessage.getCodecName(), rawMessage.getId());
return null;
}
try {
final GeneratorState state = objectMapper.readValue(rawMessage.getPayload(), GeneratorState.class);
final Message message = FakeHttpRawMessageGenerator.generateMessage(state);
return message;
} catch (IOException e) {
log.error("Cannot decode message to class FakeHttpRawMessageGenerator.GeneratorState", e);
}
return null;
}
use of org.graylog2.inputs.random.generators.FakeHttpRawMessageGenerator.GeneratorState in project graylog2-server by Graylog2.
the class FakeHttpRawMessageGenerator method createMessage.
private static Message createMessage(GeneratorState state, int httpCode, Resource resource, int tookMs, DateTime ingestTime) {
final Message msg = new Message(shortMessage(ingestTime, state.method, state.resource, httpCode, tookMs), state.source, Tools.nowUTC());
msg.addFields(ingestTimeFields(ingestTime));
msg.addFields(resourceFields(resource));
msg.addField("ticks", System.nanoTime());
msg.addField("http_method", state.method.name());
msg.addField("http_response_code", httpCode);
msg.addField("user_id", state.userId);
msg.addField("took_ms", tookMs);
return msg;
}
Aggregations