use of com.codahale.metrics.annotation.Timed in project graylog2-server by Graylog2.
the class IndicesResource method indexSetClosed.
@GET
@Timed
@Path("/{indexSetId}/closed")
@ApiOperation(value = "Get a list of closed indices that can be reopened.")
@Produces(MediaType.APPLICATION_JSON)
public ClosedIndices indexSetClosed(@ApiParam(name = "indexSetId") @PathParam("indexSetId") String indexSetId) {
final IndexSet indexSet = getIndexSet(indexSetRegistry, indexSetId);
final Set<String> closedIndices = indices.getClosedIndices(indexSet).stream().filter((indexName) -> isPermitted(RestPermissions.INDICES_READ, indexName) && indexSetRegistry.isManagedIndex(indexName)).collect(Collectors.toSet());
return ClosedIndices.create(closedIndices, closedIndices.size());
}
use of com.codahale.metrics.annotation.Timed in project graylog2-server by Graylog2.
the class IndicesResource method indexSetReopened.
@GET
@Timed
@Path("/{indexSetId}/reopened")
@ApiOperation(value = "Get a list of reopened indices, which will not be cleaned by retention cleaning")
@Produces(MediaType.APPLICATION_JSON)
public ClosedIndices indexSetReopened(@ApiParam(name = "indexSetId") @PathParam("indexSetId") String indexSetId) {
final IndexSet indexSet = getIndexSet(indexSetRegistry, indexSetId);
final Set<String> reopenedIndices = indices.getReopenedIndices(indexSet).stream().filter((indexName) -> isPermitted(RestPermissions.INDICES_READ, indexName) && indexSetRegistry.isManagedIndex(indexName)).collect(Collectors.toSet());
return ClosedIndices.create(reopenedIndices, reopenedIndices.size());
}
use of com.codahale.metrics.annotation.Timed in project graylog2-server by Graylog2.
the class LoggersResource method loggers.
@GET
@Timed
@ApiOperation(value = "List all loggers and their current levels")
@Produces(MediaType.APPLICATION_JSON)
public LoggersSummary loggers() {
final Collection<LoggerConfig> loggerConfigs = getLoggerConfigs();
final Map<String, SingleLoggerSummary> loggers = Maps.newHashMapWithExpectedSize(loggerConfigs.size());
for (LoggerConfig config : loggerConfigs) {
if (!isPermitted(RestPermissions.LOGGERS_READ, config.getName())) {
continue;
}
final Level level = config.getLevel();
loggers.put(config.getName(), SingleLoggerSummary.create(level.toString().toLowerCase(Locale.ENGLISH), level.intLevel()));
}
return LoggersSummary.create(loggers);
}
use of com.codahale.metrics.annotation.Timed in project graylog2-server by Graylog2.
the class LoggersResource method setSingleLoggerLevel.
@PUT
@Timed
@ApiOperation(value = "Set the loglevel of a single logger", notes = "Provided level is falling back to DEBUG if it does not exist")
@Path("/{loggerName}/level/{level}")
@AuditEvent(type = AuditEventTypes.LOG_LEVEL_UPDATE)
public void setSingleLoggerLevel(@ApiParam(name = "loggerName", required = true) @PathParam("loggerName") @NotEmpty String loggerName, @ApiParam(name = "level", required = true) @NotEmpty @PathParam("level") String level) {
checkPermission(RestPermissions.LOGGERS_EDIT, loggerName);
final Level newLevel = Level.toLevel(level.toUpperCase(Locale.ENGLISH));
setLoggerLevel(loggerName, newLevel);
LOG.debug("Successfully set log level for logger \"{}\" to \"{}\"", loggerName, newLevel);
}
use of com.codahale.metrics.annotation.Timed in project graylog2-server by Graylog2.
the class LoggersResource method subsystems.
@GET
@Timed
@Path("/subsystems")
@ApiOperation(value = "List all logger subsystems and their current levels")
@Produces(MediaType.APPLICATION_JSON)
public SubsystemSummary subsystems() {
final Map<String, SingleSubsystemSummary> subsystems = Maps.newHashMap();
for (Map.Entry<String, Subsystem> subsystem : SUBSYSTEMS.entrySet()) {
if (!isPermitted(RestPermissions.LOGGERS_READSUBSYSTEM, subsystem.getKey())) {
continue;
}
try {
final String category = subsystem.getValue().getCategory();
final Level level = getLoggerLevel(category);
subsystems.put(subsystem.getKey(), SingleSubsystemSummary.create(subsystem.getValue().getTitle(), subsystem.getValue().getCategory(), subsystem.getValue().getDescription(), level.toString().toLowerCase(Locale.ENGLISH), level.intLevel()));
} catch (Exception e) {
LOG.error("Error while listing logger subsystem.", e);
}
}
return SubsystemSummary.create(subsystems);
}
Aggregations