chenweida 6 lat temu
rodzic
commit
3daa33a851

+ 1 - 8
.gitignore

@ -8,6 +8,7 @@
*.pyc
*.pyo
.idea/
*.log
.idea_modules/
build/*.jar
.settings
@ -43,30 +44,22 @@ project/build/target/
project/plugins/target/
project/plugins/lib_managed/
project/plugins/src_managed/
logs/
log/
spark-tests.log
streaming-tests.log
dependency-reduced-pom.xml
.ensime
.ensime_cache/
.ensime_lucene
checkpoint
derby.log
dist/
dev/create-release/*txt
dev/create-release/*final
spark-*-bin-*.tgz
unit-tests.log
/lib/
ec2/lib/
rat-results.txt
scalastyle.txt
scalastyle-output.xml
R-unit-tests.log
R/unit-tests.out
python/lib/pyspark.zip
lint-r-report.log
# For Hive
metastore_db/

+ 204 - 0
admin/admin-server-starter/src/main/java/com/yihu/admin/server/log/LogEndPoint.java

@ -0,0 +1,204 @@
package com.yihu.admin.server.log;
import com.yihu.admin.server.properties.AdminServerProperties;
import com.yihu.admin.server.util.DateUtil;
import com.yihu.base.es.config.ElastricSearchHelper;
import net.sf.json.JSONObject;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.*;
/**
 * Created by chenweida on 2018/5/24 0024.1
 */
@RestController
@RequestMapping("admin_log")
public class LogEndPoint {
    @Autowired
    private ElastricSearchHelper elastricSearchHelper;
    @Autowired
    private AdminServerProperties adminServerProperties;
    @GetMapping("list")
    public List<LogModel> list(
            @RequestParam(value = "traceId", required = false) String traceId,  // GET POST DELETE PUT
            @RequestParam(value = "time", required = false) Integer time,  // GET POST DELETE PUT
            @RequestParam(value = "page", required = true) Integer page,
            @RequestParam(value = "pageSize", required = true) Integer pageSize
    ) {
        List<LogModel> logs = new ArrayList<>();
        StringBuffer sql = new StringBuffer("SELECT traceid, max(eventendtime) eventendtime ,min(eventstarttime) eventstarttime, max(excutetime) excutetime FROM " + adminServerProperties.getDefaultIndexName() + " where eventname='system_http_tracer'  ");
        StringBuffer whereSQL = new StringBuffer();
        if (!StringUtils.isEmpty(traceId)) {
            whereSQL.append(" and traceid='" + traceId + "'");
        }
        if (time != null && time > 0) {
            whereSQL.append(" and  excutetime >" + time + "");
        }
        StringBuffer groupby = new StringBuffer(" group by traceid  order by eventstarttime desc limit " + (page * pageSize) + "," + pageSize);
        String finalSql = sql.toString() + whereSQL.toString() + groupby.toString();
        List<Map<String, Object>> traceidList = elastricSearchHelper.excuceSQL(finalSql);
        for (int i = 0; i < traceidList.size(); i++) {
            LogModel logTemp = new LogModel();
            Map<String, Object> value = traceidList.get(i);
            if (value.size() == 0) {
                continue;
            }
            logTemp.setTraceid(value.get("traceid").toString());
            Long startTime = ((Double) value.get("eventstarttime")).longValue();
            logTemp.setEventstarttime(startTime);
            logTemp.setEventstarttimestr(DateUtil.dateToStr(new Date(startTime), DateUtil.YYYY_MM_DD_HH_MM_SS_SSS));
            Long endtime = ((Double) value.get("eventendtime")).longValue();
            logTemp.setEventendtime(endtime);
            logTemp.setEventendtimestr(DateUtil.dateToStr(new Date(endtime), DateUtil.YYYY_MM_DD_HH_MM_SS_SSS));
            logs.add(logTemp);
        }
        return logs;
    }
    @GetMapping("tracelist")
    public List<LogModel> tracelist(
            @RequestParam(value = "traceId", required = false) String traceId,
            @RequestParam(value = "spanname", required = false) String spanname,
            @RequestParam(value = "time", required = false) Integer time,  // GET POST DELETE PUT
            @RequestParam(value = "eventname", required = false) String eventname,
            @RequestParam(value = "uri", required = false) String uri
    ) {
        if (!StringUtils.isEmpty(spanname)) {
            spanname = spanname.toLowerCase();
        }
        List<LogModel> logs = new ArrayList<>();
        StringBuffer sql = new StringBuffer("SELECT * FROM " + adminServerProperties.getDefaultIndexName());
        StringBuffer whereSQL = initWhere(traceId, spanname, eventname, time, uri);
        StringBuffer groupBY = new StringBuffer("order by eventstarttime asc");
        String finalSQL = sql.append(whereSQL).append(groupBY).toString();
        List<Map<String, Object>> traceidList = elastricSearchHelper.excuceSQL(finalSQL);
        for (int i = 0; i < traceidList.size(); i++) {
            LogModel logTemp = new LogModel();
            Map<String, Object> value = traceidList.get(i);
            logTemp.setTraceid(value.get("traceid").toString());
            logTemp.setSpanid(value.get("spanid").toString());
            logTemp.setSpanname(value.get("spanname").toString());
            logTemp.setEventname(value.get("eventname").toString());
            if (value.containsKey("eventstarttime") && value.get("eventstarttime") != null) {
                Long startTime = (Long) value.get("eventstarttime");
                logTemp.setEventstarttime(startTime);
                logTemp.setEventstarttimestr(DateUtil.dateToStr(new Date(startTime), DateUtil.YYYY_MM_DD_HH_MM_SS_SSS));
            }
            if (value.containsKey("eventendtime") && value.get("eventendtime") != null) {
                Long endtime = (Long) value.get("eventendtime");
                logTemp.setEventendtime(endtime);
                logTemp.setEventendtimestr(DateUtil.dateToStr(new Date(endtime), DateUtil.YYYY_MM_DD_HH_MM_SS_SSS));
            }
            if (value.containsKey("method") && value.get("method") != null) {
                logTemp.setMethod(value.get("method").toString());
            }
            if (value.containsKey("sql") && value.get("sql") != null) {
                logTemp.setSql(value.get("sql").toString());
            }
            if (value.containsKey("ip") && value.get("ip") != null) {
                logTemp.setIp(value.get("ip").toString());
            }
            if (value.containsKey("uri") && value.get("uri") != null) {
                logTemp.setUri(value.get("uri").toString());
            }
            if (value.containsKey("excutetime") && value.get("excutetime") != null) {
                logTemp.setExcutetime((Integer) value.get("excutetime"));
            }
            //设置header
            JSONObject headerJO = new JSONObject();
            JSONObject requestJO = new JSONObject();
            JSONObject responseJO = new JSONObject();
            for (Map.Entry<String, Object> one : value.entrySet()) {
                if (one.getKey().contains("header")) {
                    headerJO.put(one.getKey(), one.getValue());
                } else if (one.getKey().contains("requestparams")) {
                    requestJO.put(one.getKey(), one.getValue());
                } else if (one.getKey().contains("responseparams")) {
                    responseJO.put(one.getKey(), one.getValue());
                }
            }
            logTemp.setHeader(headerJO.toString());
            logTemp.setRequestparams(requestJO.toString());
            logTemp.setResponseparams(responseJO.toString());
            logs.add(logTemp);
        }
        return logs;
    }
    private StringBuffer initWhere(String traceId, String spanname, String eventname, Integer time, String uri) {
        StringBuffer whereSQL = new StringBuffer();
        Map<String, Object> params = new HashMap<>();
        if (!StringUtils.isEmpty(traceId)) {
            params.put("traceid", traceId);
        }
        if (!StringUtils.isEmpty(spanname)) {
            params.put("spanname", spanname);
        }
        if (!StringUtils.isEmpty(eventname)) {
            params.put("eventname", eventname);
        }
        if (!StringUtils.isEmpty(uri)) {
            params.put("uri", uri);
        }
        if (time != null && time > 0) {
            params.put("time", time);
        }
        String key = " where ";
        for (Map.Entry<String, Object> one : params.entrySet()) {
            if ("time".equals(one.getKey())) {
                whereSQL.append(key).append("excutetime > '" + one.getValue() + "'");
            } else if ("uri".equals(one.getKey())) {
                whereSQL.append(key).append("uri like '%" + one.getValue() + "%'");
            }  {
                whereSQL.append(key).append(one.getKey() + " = '" + one.getValue() + "'");
            }
            key = " and ";
        }
        return whereSQL;
    }
    @GetMapping("spanNamelist")
    public List<QuotaModel> spanNamelist(
            @RequestParam(value = "spanname", required = true) String spanname) {
        spanname = spanname.toLowerCase();
        List<QuotaModel> logs = new ArrayList<>();
        StringBuffer sql = new StringBuffer("SELECT uri,sum(success) success,sum(fail) fail,avg(excutetime) avgtime ,max(excutetime) maxtime ,count(*) allcount FROM  " + adminServerProperties.getDefaultIndexName() + " " +
                " where spanname ='" + spanname + "' and eventname='system_http_tracer'  " +
                " group by  uri ");
        List<Map<String, Object>> traceidList = elastricSearchHelper.excuceSQL(sql.toString());
        if (traceidList.size() > 0) {
            for (Map<String, Object> one : traceidList) {
                if (one.size() > 0) {
                    QuotaModel quotaModel = new QuotaModel();
                    quotaModel.setUri(one.get("uri").toString());
                    //quotaModel.setAllcount(.toString());
                    quotaModel.setAllcount(Double.valueOf(one.get("allcount").toString()).intValue());
                    quotaModel.setSuccess(Double.valueOf(one.get("success").toString()).intValue());
                    quotaModel.setFail(Double.valueOf(one.get("fail").toString()).intValue());
                    quotaModel.setAvgtime(Double.valueOf(one.get("avgtime").toString()));
                    quotaModel.setMaxtime(Double.valueOf(one.get("maxtime").toString()).intValue());
                    BeanUtils.copyProperties(one, quotaModel);
                    logs.add(quotaModel);
                }
            }
        }
        return logs;
    }
}

+ 158 - 0
admin/admin-server-starter/src/main/java/com/yihu/admin/server/log/LogModel.java

@ -0,0 +1,158 @@
package com.yihu.admin.server.log;
import com.yihu.admin.server.util.DateUtil;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.Date;
/**
 * Created by chenweida on 2018/5/24 0024.1
 */
public class LogModel {
    private String sql;
    private String spanid;
    private String spanname;
    private String eventname;
    private String traceid;
    private String method;
    private String ip;
    private String uri;
    private String requestparams;
    private String responseparams;
    private Long eventstarttime;
    private String eventstarttimestr;
    private Long eventendtime;
    private String eventendtimestr;
    private Integer excutetime;
    private String header;
    public String getSql() {
        return sql;
    }
    public void setSql(String sql) {
        this.sql = sql;
    }
    public Integer getExcutetime() {
        return excutetime;
    }
    public void setExcutetime(Integer excutetime) {
        this.excutetime = excutetime;
    }
    public String getSpanid() {
        return spanid;
    }
    public void setSpanid(String spanid) {
        this.spanid = spanid;
    }
    public String getSpanname() {
        return spanname;
    }
    public void setSpanname(String spanname) {
        this.spanname = spanname;
    }
    public String getEventname() {
        return eventname;
    }
    public void setEventname(String eventname) {
        this.eventname = eventname;
    }
    public String getTraceid() {
        return traceid;
    }
    public void setTraceid(String traceid) {
        this.traceid = traceid;
    }
    public String getMethod() {
        return method;
    }
    public void setMethod(String method) {
        this.method = method;
    }
    public Long getEventstarttime() {
        return eventstarttime;
    }
    public void setEventstarttime(Long eventstarttime) {
        this.eventstarttime = eventstarttime;
    }
    public String getEventstarttimestr() {
        return eventstarttimestr;
    }
    public void setEventstarttimestr(String eventstarttimestr) {
        this.eventstarttimestr = eventstarttimestr;
    }
    public String getIp() {
        return ip;
    }
    public void setIp(String ip) {
        this.ip = ip;
    }
    public String getResponseparams() {
        return responseparams;
    }
    public void setResponseparams(String responseparams) {
        this.responseparams = responseparams;
    }
    public Long getEventendtime() {
        return eventendtime;
    }
    public void setEventendtime(Long eventendtime) {
        this.eventendtime = eventendtime;
    }
    public String getEventendtimestr() {
        return eventendtimestr;
    }
    public void setEventendtimestr(String eventendtimestr) {
        this.eventendtimestr = eventendtimestr;
    }
    public String getHeader() {
        return header;
    }
    public void setHeader(String header) {
        this.header = header;
    }
    public String getUri() {
        return uri;
    }
    public void setUri(String uri) {
        this.uri = uri;
    }
    public String getRequestparams() {
        return requestparams;
    }
    public void setRequestparams(String requestparams) {
        this.requestparams = requestparams;
    }
}

+ 62 - 0
admin/admin-server-starter/src/main/java/com/yihu/admin/server/log/QuotaModel.java

@ -0,0 +1,62 @@
package com.yihu.admin.server.log;
/**
 * Created by chenweida on 2018/5/24 0024.1
 */
public class QuotaModel {
    private String uri;//接口路径
    private Integer allcount; //请求总次数
    private Integer success;  //成功次数
    private Integer fail;  // 失败次数
    private Double avgtime;  //请求平均时间
    private Integer maxtime;   // 最长请求时间
    public String getUri() {
        return uri;
    }
    public void setUri(String uri) {
        this.uri = uri;
    }
    public Integer getAllcount() {
        return allcount;
    }
    public void setAllcount(Integer allcount) {
        this.allcount = allcount;
    }
    public Integer getSuccess() {
        return success;
    }
    public void setSuccess(Integer success) {
        this.success = success;
    }
    public Integer getFail() {
        return fail;
    }
    public void setFail(Integer fail) {
        this.fail = fail;
    }
    public Double getAvgtime() {
        return avgtime;
    }
    public void setAvgtime(Double avgtime) {
        this.avgtime = avgtime;
    }
    public Integer getMaxtime() {
        return maxtime;
    }
    public void setMaxtime(Integer maxtime) {
        this.maxtime = maxtime;
    }
}

+ 127 - 0
admin/admin-server-ui-starter/src/main/resources/admin/log/html/distributedLog.html

@ -0,0 +1,127 @@
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="../../common/css/bootstrap/bootstrap.min.css?v=3.4.0" rel="stylesheet">
    <link href="../../common/css/bootstrap/font-awesome.min.css?v=4.3.0" rel="stylesheet">
    <link href="../../common/css/bootstrap/animate.min.css" rel="stylesheet">
    <link href="../../common/css/bootstrap/style.min.css?v=3.0.0" rel="stylesheet">
    <!-- Data Tables -->
    <link href="../../common/css/bootstrap/plugins/dataTables/dataTables.bootstrap.css" rel="stylesheet">
    <link href="../../common/css/jw.css" rel="stylesheet">
</head>
<body class="gray-bg">
<div class="row">
    <div class="col-sm-12">
        <div class="ibox float-e-margins">
            <div class="ibox-title">
                <h5>查询条件</h5>
                <div class="ibox-tools">
                    <a class="collapse-link">
                        <i class="fa fa-chevron-up"></i>
                    </a>
                    <a class="close-link">
                        <i class="fa fa-times"></i>
                    </a>
                </div>
            </div>
            <div class="ibox-content" id="search_params">
                <div class="form-horizontal">
                    <div class="form-group">
                        <div class="form-group col-sm-4 ">
                            <label class="control-label col-sm-2">流程ID:</label>
                            <input type="text" placeholder="流程ID" id="search_trace_iD" class="form-control col-sm-2">
                        </div>
                        <div class="form-group col-sm-4 ">
                            <label class="control-label col-sm-2">时间:</label>
                            <input type="text" placeholder="耗费时间大于(?)毫秒" id="time_trace_iD" class="form-control col-sm-2">
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-sm-4 col-sm-offset-2">
                            <button class="btn btn-primary" onclick="searchDistributedLog()">查询</button>
                            <button class="btn btn-white" onclick="clearDistributedLog()">清空条件</button>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="col-sm-12">
        <div class="wrapper wrapper-content">
            <div class="row animated fadeInRight">
                <div class="col-sm-12">
                    <div class="ibox float-e-margins">
                        <div class="" id="ibox-content">
                            <div id="vertical-timeline" class="vertical-container light-timeline"
                                 v-for="message in messages">
                                <div class="vertical-timeline-block">
                                    <div class="vertical-timeline-icon navy-bg">
                                        <i class="fa fa-briefcase"></i>
                                    </div>
                                    <div class="vertical-timeline-content">
                                        <h2>流程ID : {{message.traceid}},流程总耗费时间:{{message.eventendtime -
                                            message.eventstarttime}}ms</h2>
                                        <p>流程开始时间:{{message.eventstarttimestr}}</p>
                                        <p>流程结束时间:{{message.eventendtimestr}}</p>
                                        <button class="btn btn-primary" style="margin-left: 10px;"
                                                :onclick="'seeLog(\''+message.traceid+'\')'">更多信息
                                        </button>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<!-- 全局js -->
<script type="text/javascript" src="../../common/js/jquery/jquery-2.1.1.min.js"></script>
<script type="text/javascript" src="../../common/js/bootstrap/bootstrap.min.js"></script>
<script type="text/javascript" src="../../common/js/content.min.js?v=1.0.0"></script>
<script type="text/javascript" src="../../common/js/layer/layer.min.js"></script>
<script type="text/javascript" src="../../common/js/plugins/iCheck/icheck.min.js"></script>
<script type="text/javascript" src="../../common/js/vue/vue.min.js"></script>
<script type="text/javascript" src="../../common/js/util/util.js"></script>
<script type="text/javascript" src="../../common/js/common.js"></script>
<script type="text/javascript" src="../js/distributedLog.js"></script>
<script>
    $(document).ready(function () {
        $("#lightVersion").click(function (event) {
            event.preventDefault();
            $("#ibox-content").removeClass("ibox-content");
            $("#vertical-timeline").removeClass("dark-timeline");
            $("#vertical-timeline").addClass("light-timeline")
        });
        $("#darkVersion").click(function (event) {
            event.preventDefault();
            $("#ibox-content").addClass("ibox-content");
            $("#vertical-timeline").removeClass("light-timeline");
            $("#vertical-timeline").addClass("dark-timeline")
        });
        $("#leftVersion").click(function (event) {
            event.preventDefault();
            $("#vertical-timeline").toggleClass("center-orientation")
        })
    });
</script>
</body>
</html>

+ 94 - 0
admin/admin-server-ui-starter/src/main/resources/admin/log/html/distributedLogDetail.html

@ -0,0 +1,94 @@
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="../../common/css/bootstrap/bootstrap.min.css?v=3.4.0" rel="stylesheet">
    <link href="../../common/css/bootstrap/font-awesome.min.css?v=4.3.0" rel="stylesheet">
    <link href="../../common/css/bootstrap/animate.min.css" rel="stylesheet">
    <link href="../../common/css/bootstrap/style.min.css?v=3.0.0" rel="stylesheet">
    <!-- Data Tables -->
    <link href="../../common/css/bootstrap/plugins/dataTables/dataTables.bootstrap.css" rel="stylesheet">
    <link href="../../common/css/jw.css" rel="stylesheet">
</head>
<body class="gray-bg">
<div class="ibox-content">
    <div class="" id="ibox-content-log-detail">
        <div id="vertical-timeline" class="vertical-container light-timeline"
             v-for="message in messages">
            <div class="vertical-timeline-block">
                <div class="vertical-timeline-icon navy-bg">
                    <i class="fa fa-briefcase"></i>
                </div>
                <div class="vertical-timeline-content">
                    <h2>微服务名称:{{message.spanname}}</h2>
                    <p>流程ID:{{message.traceid}}</p>
                    <p>模块ID:{{message.spanid}}</p>
                    <p>事件名称:{{message.eventname}}</p>
                    <p>事件开始时间:{{message.eventstartstr}}</p>
                    <p>事件结束时间:{{message.eventendstr}}</p>
                    <p>事件执行时间:{{message.excutetime}} ms</p>
                    <template v-if="message.eventname === 'system_http_tracer'">
                        <p>请求用户IP地址:{{message.ip}}</p>
                        <p>请求方式:{{message.method}}</p>
                        <p>请求路径:{{message.uri}}</p>
                        <p>请求头信息:{{message.header}}</p>
                        <p>请求参数:{{message.requestparams}}</p>
                        <p>返回参数:{{message.responseparams}}</p>
                    </template>
                    <template v-if="message.eventname === 'system_sql_tracer'">
                        <p>sql语句:{{message.sql}}</p>
                    </template>
                </div>
            </div>
        </div>
    </div>
</div>
<!-- 全局js -->
<script type="text/javascript" src="../../common/js/jquery/jquery-2.1.1.min.js"></script>
<script type="text/javascript" src="../../common/js/bootstrap/bootstrap.min.js"></script>
<script  type="text/javascript"src="../../common/js/content.min.js?v=1.0.0"></script>
<script type="text/javascript" src="../../common/js/layer/layer.min.js"></script>
<script type="text/javascript" src="../../common/js/plugins/iCheck/icheck.min.js"></script>
<script type="text/javascript" src="../../common/js/vue/vue.min.js"></script>
<script type="text/javascript" src="../../common/js/util/util.js"></script>
<script type="text/javascript" src="../../common/js/common.js"></script>
<script type="text/javascript" src="../js/distributedLogDetail.js"></script>
<script>
    $(document).ready(function () {
        $("#lightVersion").click(function (event) {
            event.preventDefault();
            $("#ibox-content").removeClass("ibox-content");
            $("#vertical-timeline").removeClass("dark-timeline");
            $("#vertical-timeline").addClass("light-timeline")
        });
        $("#darkVersion").click(function (event) {
            event.preventDefault();
            $("#ibox-content").addClass("ibox-content");
            $("#vertical-timeline").removeClass("light-timeline");
            $("#vertical-timeline").addClass("dark-timeline")
        });
        $("#leftVersion").click(function (event) {
            event.preventDefault();
            $("#vertical-timeline").toggleClass("center-orientation")
        })
    });
</script>
</body>
</html>

+ 128 - 0
admin/admin-server-ui-starter/src/main/resources/admin/log/html/spanLog.html

@ -0,0 +1,128 @@
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="../../common/css/bootstrap/bootstrap.min.css?v=3.4.0" rel="stylesheet">
    <link href="../../common/css/bootstrap/font-awesome.min.css?v=4.3.0" rel="stylesheet">
    <link href="../../common/css/bootstrap/animate.min.css" rel="stylesheet">
    <link href="../../common/css/bootstrap/style.min.css?v=3.0.0" rel="stylesheet">
    <!-- Data Tables -->
    <link href="../../common/css/bootstrap/plugins/dataTables/dataTables.bootstrap.css" rel="stylesheet">
    <link href="../../common/css/jw.css" rel="stylesheet">
</head>
<body class="gray-bg">
<div class="ibox-content">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>查询条件</h5>
                    <div class="ibox-tools">
                        <a class="collapse-link">
                            <i class="fa fa-chevron-up"></i>
                        </a>
                        <a class="close-link">
                            <i class="fa fa-times"></i>
                        </a>
                    </div>
                </div>
                <div class="ibox-content" id="search_params">
                    <div class="form-horizontal">
                        <div class="form-group">
                            <div class="form-group col-sm-4 ">
                                <label class="control-label col-sm-2">uri::</label>
                                <input type="text" placeholder="例如:/demo/testSQL" id="spanLog_search_url" class="form-control col-sm-2">
                            </div>
                            <div class="form-group col-sm-4 ">
                                <label class="control-label col-sm-2">时间:</label>
                                <input type="text" placeholder="耗费时间大于(?)毫秒" id="spanLog_time_search" class="form-control col-sm-2">
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-sm-4 col-sm-offset-2">
                                <button class="btn btn-primary" onclick="searchSpanLog()">查询</button>
                                <button class="btn btn-white" onclick="clearSpanLog()">清空条件</button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        </div>
    </div>
    <div class="col-sm-12">
        <div class="" id="ibox-content-log-detail">
            <div id="vertical-timeline" class="vertical-container light-timeline" v-for="message in messages">
                <div class="vertical-timeline-block">
                    <div class="vertical-timeline-icon navy-bg">
                        <i class="fa fa-briefcase"></i>
                    </div>
                    <div class="vertical-timeline-content">
                        <h2>请求路径:{{message.uri}}</h2>
                        <p>请求用户IP地址:   {{message.ip}}</p>
                        <p>请求方式:   {{message.method}}</p>
                        <p>请求头信息:   {{message.header}}</p>
                        <p>请求参数:   {{message.requestparams}}</p>
                        <p>返回参数:   {{message.responseparams}}</p>
                        <p>流程ID:   {{message.traceid}}</p>
                        <p>模块ID:   {{message.spanid}}</p>
                        <p>事件名称:   {{message.eventname}}</p>
                        <p>事件开始时间:{{message.eventstarttimestr}}</p>
                        <p>事件结束时间:{{message.eventendtimestr}}</p>
                        <p>事件执行时间:{{message.excutetime}} ms</p>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<!-- 全局js -->
<script type="text/javascript" src="../../common/js/jquery/jquery-2.1.1.min.js"></script>
<script type="text/javascript" src="../../common/js/bootstrap/bootstrap.min.js"></script>
<script  type="text/javascript"src="../../common/js/content.min.js?v=1.0.0"></script>
<script type="text/javascript" src="../../common/js/layer/layer.min.js"></script>
<script type="text/javascript" src="../../common/js/plugins/iCheck/icheck.min.js"></script>
<script type="text/javascript" src="../../common/js/vue/vue.min.js"></script>
<script type="text/javascript" src="../../common/js/util/util.js"></script>
<script type="text/javascript" src="../../common/js/common.js"></script>
<script type="text/javascript" src="../js/spanLog.js"></script>
<script>
    $(document).ready(function () {
        $("#lightVersion").click(function (event) {
            event.preventDefault();
            $("#ibox-content").removeClass("ibox-content");
            $("#vertical-timeline").removeClass("dark-timeline");
            $("#vertical-timeline").addClass("light-timeline")
        });
        $("#darkVersion").click(function (event) {
            event.preventDefault();
            $("#ibox-content").addClass("ibox-content");
            $("#vertical-timeline").removeClass("light-timeline");
            $("#vertical-timeline").addClass("dark-timeline")
        });
        $("#leftVersion").click(function (event) {
            event.preventDefault();
            $("#vertical-timeline").toggleClass("center-orientation")
        })
    });
</script>
</body>
</html>

+ 48 - 0
admin/admin-server-ui-starter/src/main/resources/admin/log/html/spanQuota.html

@ -0,0 +1,48 @@
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="../../common/css/bootstrap/bootstrap.min.css?v=3.4.0" rel="stylesheet">
    <link href="../../common/css/bootstrap/font-awesome.min.css?v=4.3.0" rel="stylesheet">
    <link href="../../common/css/bootstrap/animate.min.css" rel="stylesheet">
    <link href="../../common/css/bootstrap/style.min.css?v=3.0.0" rel="stylesheet">
    <!-- Data Tables -->
    <link href="../../common/css/bootstrap/plugins/dataTables/dataTables.bootstrap.css" rel="stylesheet">
    <link href="../../common/css/jw.css" rel="stylesheet">
</head>
<body class="gray-bg">
<div class="ibox-content">
    <div class="" id="ibox-content-jqGrid_wrapper">
        <div class="jqGrid_wrapper">
            <table id="table_list_1"></table>
            <!--<div id="pager_list_1"></div>-->
        </div>
    </div>
</div>
<!-- 全局js -->
<script type="text/javascript" src="../../common/js/jquery/jquery-2.1.1.min.js"></script>
<script type="text/javascript" src="../../common/js/bootstrap/bootstrap.min.js"></script>
<script  type="text/javascript"src="../../common/js/content.min.js?v=1.0.0"></script>
<script type="text/javascript" src="../../common/js/layer/layer.min.js"></script>
<script type="text/javascript" src="../../common/js/plugins/iCheck/icheck.min.js"></script>
<script type="text/javascript" src="../../common/js/vue/vue.min.js"></script>
<script type="text/javascript" src="../../common/js/util/util.js"></script>
<script type="text/javascript" src="../../common/js/common.js"></script>
<script src="../../common/js/plugins/jqgrid/i18n/grid.locale-cn.js_0820"></script>
<script src="../../common/js/plugins/jqgrid/jquery.jqGrid.min.js_0820"></script>
<script type="text/javascript" src="../js/spanQuota.js"></script>
</body>
</html>

+ 45 - 0
admin/admin-server-ui-starter/src/main/resources/admin/log/js/distributedLog.js

@ -0,0 +1,45 @@
//获取日志信息
var contentVM = new Vue({
    el: '#ibox-content',
    data: {
        messages: []
    }
});
var page = 0
var pageSize = 10
search();
function searchDistributedLog() {
    do_get(
        server + "admin_log/list",
        {
            page: page,
            pageSize: pageSize,
            traceId: $("#search_trace_iD").val()?$("#search_trace_iD").val():"",
            time:$("#time_trace_iD").val()?$("#time_trace_iD").val():0
        },
        function (data) {
            contentVM.messages = data
        },
        function (data) {
            alert("获取日志失败");
        }
    )
}
function clearDistributedLog() {
    $("#search_trace_iD").val("");
    return
}
function seeLog(traceid) {
    parent.layer.open({
        type: 2,
        title: '流程详情',
        shadeClose: true,
        shade: 0.8,
        area: ['80%', '80%'],
        content: '../log/html/distributedLogDetail.html?traceId=' + traceid //iframe的url
    });
    return
}

+ 22 - 0
admin/admin-server-ui-starter/src/main/resources/admin/log/js/distributedLogDetail.js

@ -0,0 +1,22 @@
var traceId = GetRequest().traceId.replace("?v","");
var contentLogDetail = new Vue({
    el: '#ibox-content-log-detail',
    data: {
        messages: []
    }
});
do_get(
    server + "admin_log/tracelist",
    {
        traceId: traceId
    },
    function (data) {
        contentLogDetail.messages = data
    },
    function (data) {
        alert("获取日志详情失败");
    }
)
function closeLogDetail(){
}

+ 45 - 0
admin/admin-server-ui-starter/src/main/resources/admin/log/js/spanLog.js

@ -0,0 +1,45 @@
var appName = GetRequest().appName.replace("?v","");
var page = 0
var pageSize = 20
var contentLogDetail = new Vue({
    el: '#ibox-content-log-detail',
    data: {
        messages: []
    }
});
do_get(
    server + "admin_log/tracelist",
    {
        spanname: appName,
        eventname:"system_http_tracer"
    },
    function (data) {
        contentLogDetail.messages = data
    },
    function (data) {
        alert("获取日志详情失败");
    }
)
function searchSpanLog() {
    do_get(
        server + "admin_log/tracelist",
        {
            page: page,
            pageSize: pageSize,
            spanname: appName,
            eventname:"system_http_tracer",
            uri: $("#spanLog_search_url").val()?$("#spanLog_search_url").val():"",
            time:$("#spanLog_time_search").val()?$("#spanLog_time_search").val():0
        },
        function (data) {
            contentVM.messages = data
        },
        function (data) {
            alert("获取日志失败");
        }
    )
}
function clearSpanLog() {
    $("#search_trace_iD").val("");
    return
}

+ 27 - 0
admin/admin-server-ui-starter/src/main/resources/admin/log/js/spanQuota.js

@ -0,0 +1,27 @@
var appName = GetRequest().appName.replace("?v", "");
$.jgrid.defaults.styleUI = "Bootstrap";
//SELECT sum(success) success,sum(fail) fail,avg(excutetime) avgtime ,max(excutetime) maxtime ,count(*) allcount FROM  admin_log where spanname ="demo-socket-client" group by  uri
$("#table_list_1").jqGrid({
    url:server + "admin_log/spanNamelist?spanname="+appName,
    datatype: "json",
    mtype: "GET",
    height: "100%",
    autowidth: true,
    shrinkToFit: true,
    //colNames: ["序号", "接口路径", "请求总次数", "成功次数", "失败次数", "请求平均时间(ms)", "最长请求时间(ms)"],
    colModel: [
        //{label:"序号",name: "id",width: 30, sorttype: "int", align: "center" },
        {label:"接口路径",name: "uri",width: 150,align: "left"},
        {label:"请求总次数",name: "allcount",align: "right",  width: 100, sorttype: "int"},
        {label:"成功次数",name: "success",width: 80,align: "right", sorttype: "int"},
        {label:"失败次数",name: "fail",  width: 80, align: "right", sorttype: "int" },
        {label:"请求平均时间(ms)",name: "avgtime",width: 80,align: "right", sorttype: "int"},
        {label:"最长请求时间(ms)",name: "maxtime",  width: 80,align: "right", sorttype: "int"}
    ],
    loadonce: true,
    // pager: "#pager_list_1",
    viewrecords: true,
    caption: "接口统计分析",
    hidegrid: false
});