Search in sources :

Example 16 with Timestamp

use of io.fabric8.maven.docker.util.Timestamp 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

Timestamp (io.fabric8.maven.docker.util.Timestamp)6 Test (org.junit.Test)6 Expectations (mockit.Expectations)4 QueryResult (io.fabric8.insight.metrics.model.QueryResult)3 Map (java.util.Map)3 LogResults (io.fabric8.insight.log.LogResults)2 MBeanAttrResult (io.fabric8.insight.metrics.model.MBeanAttrResult)2 MBeanAttrsResult (io.fabric8.insight.metrics.model.MBeanAttrsResult)2 MBeanOperResult (io.fabric8.insight.metrics.model.MBeanOperResult)2 MBeanOpersResult (io.fabric8.insight.metrics.model.MBeanOpersResult)2 Result (io.fabric8.insight.metrics.model.Result)2 List (java.util.List)2 Set (java.util.Set)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 GitVersion (io.fabric8.api.commands.GitVersion)1 GitVersions (io.fabric8.api.commands.GitVersions)1 JMXResult (io.fabric8.api.commands.JMXResult)1 LogEvent (io.fabric8.insight.log.LogEvent)1 MBeanAttrs (io.fabric8.insight.metrics.model.MBeanAttrs)1 MBeanOpers (io.fabric8.insight.metrics.model.MBeanOpers)1