All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.graylog2.telemetry.server.TelemetryServerResource Maven / Gradle / Ivy

package org.graylog2.telemetry.server;

import com.codahale.metrics.annotation.Timed;
import com.wordnik.swagger.annotations.Api;
import com.wordnik.swagger.annotations.ApiOperation;
import com.wordnik.swagger.annotations.ApiResponse;
import com.wordnik.swagger.annotations.ApiResponses;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.graylog2.plugin.rest.PluginRestResource;
import org.graylog2.shared.rest.resources.RestResource;
import org.graylog2.telemetry.TelemetryNodeService;
import org.graylog2.telemetry.dto.ClusterDataSet;
import org.graylog2.telemetry.dto.NodeDataSet;
import org.graylog2.telemetry.server.TelemetryClusterService;

import javax.inject.Inject;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

@RequiresAuthentication
@Api(value = "Telemetry", description = "Telemetry data about this Graylog setup")
@Path("/")
public class TelemetryServerResource extends RestResource implements PluginRestResource {
    private final TelemetryNodeService telemetryNodeService;
    private final TelemetryClusterService telemetryClusterService;

    @Inject
    public TelemetryServerResource(TelemetryNodeService telemetryNodeService,
                                   TelemetryClusterService telemetryClusterService) {
        this.telemetryNodeService = telemetryNodeService;
        this.telemetryClusterService = telemetryClusterService;
    }

    @GET
    @Path("node")
    @Timed
    @ApiOperation(value = "Return the telemetry data of this Graylog node")
    @Produces(MediaType.APPLICATION_JSON)
    @ApiResponses(value = {
            @ApiResponse(code = 500, message = "Internal Server Error")
    })
    public NodeDataSet telemetryNodeDataSet() {
        return telemetryNodeService.buildNodeDataSet();
    }

    @GET
    @Path("cluster")
    @Timed
    @ApiOperation(value = "Return the telemetry data of this Graylog cluster")
    @Produces(MediaType.APPLICATION_JSON)
    @ApiResponses(value = {
            @ApiResponse(code = 500, message = "Internal Server Error")
    })
    public ClusterDataSet telemetryClusterDataSet() {
        return telemetryClusterService.buildClusterDataSet();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy