Search in sources :

Example 1 with StorageService

use of io.fabric8.insight.storage.StorageService in project fabric8 by jboss-fuse.

the class InsightRequestLog method log.

@Override
public void log(Request request, Response response) {
    try {
        if (!enabled) {
            return;
        }
        StorageService s = storage.getService();
        if (s == null) {
            return;
        }
        if (ignorePathMap != null && ignorePathMap.getMatch(request.getRequestURI()) != null)
            return;
        String output = "{ " + "\"host\": \"" + host + "\", " + "\"@timestamp\": \"" + InsightUtils.formatDate(request.getTimeStamp()) + "\", " + "\"remote\": \"" + request.getRemoteAddr() + "\", " + "\"user\": \"" + (request.getAuthentication() instanceof Authentication.User ? ((Authentication.User) request.getAuthentication()).getUserIdentity().getUserPrincipal().getName() : "") + "\", " + "\"method\": \"" + request.getMethod() + "\", " + "\"uri\": \"" + request.getUri().toString() + "\", " + "\"protocol\": \"" + request.getProtocol() + "\", " + "\"status\": \"" + response.getStatus() + "\", " + "\"responseLength\": \"" + response.getContentCount() + "\" " + " }";
        s.store(type, request.getTimeStamp(), output);
    } catch (Exception e) {
        LOG.warn(e);
    }
}
Also used : ConfigurationException(org.osgi.service.cm.ConfigurationException) StorageService(io.fabric8.insight.storage.StorageService)

Aggregations

StorageService (io.fabric8.insight.storage.StorageService)1 ConfigurationException (org.osgi.service.cm.ConfigurationException)1