use of org.graylog2.audit.jersey.NoAuditEvent in project graylog2-server by Graylog2.
the class MessageResource method parse.
@POST
@Path("/parse")
@Timed
@Consumes(MediaType.APPLICATION_JSON)
@ApiOperation(value = "Parse a raw message")
@ApiResponses(value = { @ApiResponse(code = 404, message = "Specified codec does not exist."), @ApiResponse(code = 400, message = "Could not decode message.") })
@NoAuditEvent("only used to parse a test message")
public ResultMessage parse(@ApiParam(name = "JSON body", required = true) MessageParseRequest request) {
Codec codec;
try {
final Configuration configuration = new Configuration(request.configuration());
codec = codecFactory.create(request.codec(), configuration);
} catch (IllegalArgumentException e) {
throw new NotFoundException(e);
}
final ResolvableInetSocketAddress remoteAddress = ResolvableInetSocketAddress.wrap(new InetSocketAddress(request.remoteAddress(), 1234));
final RawMessage rawMessage = new RawMessage(0, new UUID(), Tools.nowUTC(), remoteAddress, request.message().getBytes(StandardCharsets.UTF_8));
final Message message = decodeMessage(codec, remoteAddress, rawMessage);
return ResultMessage.createFromMessage(message);
}
use of org.graylog2.audit.jersey.NoAuditEvent in project graylog2-server by Graylog2.
the class ClusterLoadBalancerStatusResource method override.
@PUT
@Timed
@RequiresAuthentication
@RequiresPermissions(RestPermissions.LBSTATUS_CHANGE)
@ApiOperation(value = "Override load balancer status of this graylog-server node. Next lifecycle " + "change will override it again to its default. Set to ALIVE, DEAD, or THROTTLED.")
@Path("/override/{status}")
@NoAuditEvent("this is a proxy resource, the audit event will be emitted on the target node")
public void override(@ApiParam(name = "nodeId", value = "The id of the node whose LB status will be changed", required = true) @PathParam("nodeId") String nodeId, @ApiParam(name = "status") @PathParam("status") String status) throws IOException, NodeNotFoundException {
final Node targetNode = nodeService.byNodeId(nodeId);
RemoteLoadBalancerStatusResource remoteLoadBalancerStatusResource = remoteInterfaceProvider.get(targetNode, this.authenticationToken, RemoteLoadBalancerStatusResource.class);
final Response response = remoteLoadBalancerStatusResource.override(status).execute();
if (!response.isSuccessful()) {
LOG.warn("Unable to override load balancer status on node {}: {}", nodeId, response.message());
throw new WebApplicationException(response.message(), BAD_GATEWAY);
}
}
use of org.graylog2.audit.jersey.NoAuditEvent in project graylog2-server by Graylog2.
the class AlarmCallbacksResource method test.
@POST
@Timed
@Path("/{alarmCallbackId}/test")
@ApiOperation(value = "Send a test alert for a given alarm callback")
@ApiResponses(value = { @ApiResponse(code = 404, message = "Alarm callback not found."), @ApiResponse(code = 400, message = "Invalid ObjectId."), @ApiResponse(code = 500, message = "Error while testing alarm callback") })
@NoAuditEvent("only used to test alert notifications")
public Response test(@ApiParam(name = "alarmCallbackId", value = "The alarm callback id to send a test alert for.", required = true) @PathParam("alarmCallbackId") String alarmCallbackId) throws TransportConfigurationException, EmailException, NotFoundException {
final AlarmCallbackConfiguration alarmCallbackConfiguration = alarmCallbackConfigurationService.load(alarmCallbackId);
final String streamId = alarmCallbackConfiguration.getStreamId();
checkPermission(RestPermissions.STREAMS_EDIT, streamId);
final Stream stream = streamService.load(streamId);
final DummyAlertCondition testAlertCondition = new DummyAlertCondition(stream, null, Tools.nowUTC(), getSubject().getPrincipal().toString(), Collections.emptyMap(), "Test Alert");
try {
AbstractAlertCondition.CheckResult checkResult = testAlertCondition.runCheck();
AlarmCallback alarmCallback = alarmCallbackFactory.create(alarmCallbackConfiguration);
alarmCallback.call(stream, checkResult);
} catch (Exception e) {
throw new InternalServerErrorException(e.getMessage(), e);
}
return Response.ok().build();
}
use of org.graylog2.audit.jersey.NoAuditEvent in project graylog2-server by Graylog2.
the class StreamAlertConditionResource method testNew.
@POST
@Path("test")
@Timed
@ApiOperation("Test new alert condition")
@NoAuditEvent("resource doesn't modify any data")
public Response testNew(@ApiParam(name = "streamId", value = "The stream ID this alert condition belongs to.", required = true) @PathParam("streamId") String streamId, @ApiParam(name = "Alert condition parameters", required = true) @Valid @NotNull CreateConditionRequest ccr) throws NotFoundException {
checkPermission(RestPermissions.STREAMS_EDIT, streamId);
final Stream stream = streamService.load(streamId);
try {
final AlertCondition alertCondition = alertService.fromRequest(convertConfigurationInRequest(ccr), stream, getCurrentUser().getName());
return Response.ok(testAlertCondition(alertCondition)).build();
} catch (ConfigurationException e) {
throw new BadRequestException("Invalid alert condition parameters", e);
}
}
use of org.graylog2.audit.jersey.NoAuditEvent in project graylog2-server by Graylog2.
the class StreamAlertConditionResource method testExisting.
@POST
@Path("{conditionId}/test")
@Timed
@ApiOperation("Test existing alert condition")
@NoAuditEvent("resource doesn't modify any data")
public Response testExisting(@ApiParam(name = "streamId", value = "The stream ID this alert condition belongs to.", required = true) @PathParam("streamId") String streamId, @ApiParam(name = "conditionId", value = "The alert condition ID to be fetched", required = true) @PathParam("conditionId") String conditionId) throws NotFoundException {
checkPermission(RestPermissions.STREAMS_EDIT, streamId);
final Stream stream = streamService.load(streamId);
final AlertCondition alertCondition = streamService.getAlertCondition(stream, conditionId);
final AlertConditionTestResponse testResultResponse = testAlertCondition(alertCondition);
if (testResultResponse.error()) {
return Response.status(400).entity(testResultResponse).build();
} else {
return Response.ok(testResultResponse).build();
}
}
Aggregations