Search in sources :

Example 61 with Timed

use of com.codahale.metrics.annotation.Timed in project graylog2-server by Graylog2.

the class ThroughputResource method total.

@GET
@Timed
@RequiresPermissions(RestPermissions.THROUGHPUT_READ)
@ApiOperation(value = "Current throughput of this node in messages per second")
@Produces(MediaType.APPLICATION_JSON)
public Throughput total() {
    final SortedMap<String, Gauge> gauges = metricRegistry.getGauges(MetricUtils.filterSingleMetric(GlobalMetricNames.OUTPUT_THROUGHPUT_RATE));
    final Gauge gauge = Iterables.getOnlyElement(gauges.values(), null);
    if (gauge == null || !(gauge.getValue() instanceof Number)) {
        return Throughput.create(0);
    } else {
        return Throughput.create(((Number) gauge.getValue()).longValue());
    }
}
Also used : Gauge(com.codahale.metrics.Gauge) RequiresPermissions(org.apache.shiro.authz.annotation.RequiresPermissions) Produces(javax.ws.rs.Produces) Timed(com.codahale.metrics.annotation.Timed) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation)

Example 62 with Timed

use of com.codahale.metrics.annotation.Timed in project graylog2-server by Graylog2.

the class InputTypesResource method info.

@GET
@Timed
@Path("{inputType}")
@ApiOperation(value = "Get information about a single input type")
@ApiResponses(value = { @ApiResponse(code = 404, message = "No such input type registered.") })
public InputTypeInfo info(@ApiParam(name = "inputType", required = true) @PathParam("inputType") String inputType) {
    final InputDescription description = messageInputFactory.getAvailableInputs().get(inputType);
    if (description == null) {
        final String message = "Unknown input type " + inputType + " requested.";
        LOG.error(message);
        throw new NotFoundException(message);
    }
    return InputTypeInfo.create(inputType, description.getName(), description.isExclusive(), description.getRequestedConfiguration(), description.getLinkToDocs());
}
Also used : NotFoundException(javax.ws.rs.NotFoundException) InputDescription(org.graylog2.shared.inputs.InputDescription) Path(javax.ws.rs.Path) Timed(com.codahale.metrics.annotation.Timed) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 63 with Timed

use of com.codahale.metrics.annotation.Timed in project graylog2-server by Graylog2.

the class IndexRangesResource method rebuildIndexSet.

@POST
@Timed
@Path("/index_set/{indexSetId}/rebuild")
@RequiresPermissions(RestPermissions.INDEXRANGES_REBUILD)
@ApiOperation(value = "Rebuild/sync index range information for the given index set.", notes = "This triggers a systemjob that scans every index in the given index set and stores meta information " + "about what indices contain messages in what timeranges. It atomically overwrites " + "already existing meta information.")
@ApiResponses(value = { @ApiResponse(code = 202, message = "Rebuild/sync systemjob triggered.") })
@Produces(MediaType.APPLICATION_JSON)
@AuditEvent(type = AuditEventTypes.ES_INDEX_RANGE_UPDATE_JOB)
public Response rebuildIndexSet(@ApiParam(name = "indexSetId") @PathParam("indexSetId") @NotBlank final String indexSetId) {
    final IndexSet indexSet = indexSetRegistry.get(indexSetId).orElseThrow(() -> new javax.ws.rs.NotFoundException("Index set <" + indexSetId + "> not found!"));
    submitIndexRangesJob(Collections.singleton(indexSet));
    return Response.accepted().build();
}
Also used : IndexSet(org.graylog2.indexer.IndexSet) Path(javax.ws.rs.Path) RequiresPermissions(org.apache.shiro.authz.annotation.RequiresPermissions) POST(javax.ws.rs.POST) Produces(javax.ws.rs.Produces) Timed(com.codahale.metrics.annotation.Timed) ApiOperation(io.swagger.annotations.ApiOperation) AuditEvent(org.graylog2.audit.jersey.AuditEvent) ApiResponses(io.swagger.annotations.ApiResponses)

Example 64 with Timed

use of com.codahale.metrics.annotation.Timed in project graylog2-server by Graylog2.

the class IndexRangesResource method show.

@GET
@Path("/{index: [a-z_0-9]+}")
@Timed
@ApiOperation(value = "Show single index range")
@Produces(MediaType.APPLICATION_JSON)
public IndexRangeSummary show(@ApiParam(name = "index", value = "The name of the Graylog-managed Elasticsearch index", required = true) @PathParam("index") @NotEmpty String index) throws NotFoundException {
    if (!indexSetRegistry.isManagedIndex(index)) {
        throw new BadRequestException(index + " is not a Graylog-managed Elasticsearch index.");
    }
    checkPermission(RestPermissions.INDEXRANGES_READ, index);
    final IndexRange indexRange = indexRangeService.get(index);
    return IndexRangeSummary.create(indexRange.indexName(), indexRange.begin(), indexRange.end(), indexRange.calculatedAt(), indexRange.calculationDuration());
}
Also used : IndexRange(org.graylog2.indexer.ranges.IndexRange) BadRequestException(javax.ws.rs.BadRequestException) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) Timed(com.codahale.metrics.annotation.Timed) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation)

Example 65 with Timed

use of com.codahale.metrics.annotation.Timed in project graylog2-server by Graylog2.

the class MessageProcessorsResource method config.

@GET
@Timed
@ApiOperation(value = "Get message processor configuration")
@Path("config")
public MessageProcessorsConfigWithDescriptors config() {
    checkPermission(RestPermissions.CLUSTER_CONFIG_ENTRY_READ);
    final MessageProcessorsConfig config = clusterConfigService.getOrDefault(MessageProcessorsConfig.class, MessageProcessorsConfig.defaultConfig());
    return MessageProcessorsConfigWithDescriptors.fromConfig(config.withProcessors(processorClassNames), processorDescriptors);
}
Also used : MessageProcessorsConfig(org.graylog2.messageprocessors.MessageProcessorsConfig) Path(javax.ws.rs.Path) Timed(com.codahale.metrics.annotation.Timed) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation)

Aggregations

Timed (com.codahale.metrics.annotation.Timed)414 ApiOperation (io.swagger.annotations.ApiOperation)255 ApiResponses (io.swagger.annotations.ApiResponses)196 Path (javax.ws.rs.Path)169 Counted (com.codahale.metrics.annotation.Counted)128 Produces (javax.ws.rs.Produces)112 GET (javax.ws.rs.GET)107 Authorisation (no.arkivlab.hioa.nikita.webapp.security.Authorisation)105 AuditEvent (org.graylog2.audit.jersey.AuditEvent)82 POST (javax.ws.rs.POST)78 Consumes (javax.ws.rs.Consumes)58 ExceptionMetered (com.codahale.metrics.annotation.ExceptionMetered)53 NotFoundException (javax.ws.rs.NotFoundException)52 PUT (javax.ws.rs.PUT)52 URI (java.net.URI)45 DELETE (javax.ws.rs.DELETE)45 BadRequestException (javax.ws.rs.BadRequestException)41 RequiresPermissions (org.apache.shiro.authz.annotation.RequiresPermissions)41 HashMap (java.util.HashMap)34 Event (keywhiz.log.Event)29