Authored by htoooth

fix

... ... @@ -22,8 +22,9 @@ const TABLE = {
const DB_NAME = 'web-apm';
const APP_NAME = {
pc: 1,
h5: 2
default: 0,
pc: 'yohobuy-node',
h5: 'yohobuywap-node'
};
const APP_NAME2 = {
... ... @@ -192,7 +193,7 @@ const profile_service = {
const errorModel = new ErrorModel(ctx);
const result = await errorModel.getList(app, start, length);
return {cde: 200, data: result};
return result;
}
};
... ... @@ -201,7 +202,7 @@ const profile_controller = {
await ctx.render('action/profile_server');
},
async server_mean_report_json(ctx) {
const app = APP_NAME[ctx.query.app] || 0;
const app = APP_NAME[ctx.query.app] || APP_NAME.default;
const start = parseInt(ctx.query.start) || 0;
const length = parseInt(ctx.query.length) || 10;
const draw = ctx.query.draw;
... ... @@ -213,7 +214,7 @@ const profile_controller = {
await ctx.render('action/profile_error');
},
async error_report_json(ctx) {
const app = APP_NAME[(ctx.query.app)] || 0;
const app = APP_NAME[(ctx.query.app)] || APP_NAME.default;
const start = parseInt(ctx.query.start) || 0;
const length = parseInt(ctx.query.length) || 10;
const draw = ctx.query.draw;
... ...
const model = require('../../../lib/model');
const mysqlPromise = require('../../../lib/mysql-apm');
const vars = require('./vars');
class errorModel extends model {
constructor(ctx) {
... ... @@ -12,7 +11,7 @@ class errorModel extends model {
pageSize = pageSize || 10;
let recordsTotal = await this.mysql.query('SELECT COUNT(*) as count from error_report where app = ?', [app]).then(([r]) => r.count);
let data = await this.mysql.query('SELECT id, app, type, preq_id, req_id, uid, udid, code, line, `column`, script, message, stack, create_time as time from error_report where app = ? order by create_time desc limit ?, ? ', [app, page, pageSize]).then(r => r.map(vars.handleItem));
let data = await this.mysql.query('SELECT id, app, type, preqid, reqid, uid, udid, code, line, `column`, script, message, stack, create_time as time from error_report where app = ? order by create_time desc limit ?, ? ', [app, page, pageSize]);
return {
recordsTotal,
... ...
const model = require('../../../lib/model');
const mysqlPromise = require('../../../lib/mysql-apm');
const vars = require('./vars');
class slowRouteModel extends model {
constructor(ctx) {
... ... @@ -12,9 +11,7 @@ class slowRouteModel extends model {
pageSize = pageSize || 10;
let recordsTotal = await this.mysql.query('SELECT COUNT(*) as count from slow_duration where app = ?', [app]).then(([r]) => r.count);
let data = await this.mysql.query('SELECT id, app, `type`, preq_id, req_id, uid, udid, api, route, duration, create_time as time from slow_duration where app = ? ORDER BY create_time DESC LIMIT ?, ? ', [app, page, pageSize]).then(r => {
return r.map(vars.handleItem)
});
let data = await this.mysql.query('SELECT id, app, `type`, preqid, reqid, uid, udid, api, route, duration, create_time as time from slow_duration where app = ? ORDER BY duration DESC LIMIT ?, ? ', [app, page, pageSize]);
return {
recordsTotal,
... ...
... ... @@ -69,6 +69,81 @@
<script>
// var selectedServer, selectedApp;
// var data_end_point = '/profile/error.json';
// var dataTable = null;
//
// function ajaxUrl() {
// let url = `${data_end_point}?app=${selectedApp}&server=${selectedServer}`;
// return url
// }
//
// $(function() {
// init();
// initTable();
// initSelect();
// });
//
// function init() {
// selectedServer = 'aws';
// selectedApp = 'default';
// }
//
// function initTable() {
// dataTable = $("#table-servers").DataTable({
// pageLength: 20,
// serverSide: true,
// retrieve: true,
// searching: false,
// ajax: ajaxUrl(),
// dataSrc: 'data',
// pageLength: 25,
// columns: [
// {data: 'time'},
// {data: 'app'},
// {data: 'type'},
// {data: 'reqID'},
// {data: 'uid'},
// {data: 'udid'},
// {data: 'code', defaultContent: '无'},
// {data: 'message', defaultContent: '无'},
// {data: 'script', defaultContent: '无'},
// {data: 'line'},
// {data: 'column'},
// {data: 'stack', defaultContent: '无'}
// ],
// data: [{
// time: "",
// app: "",
// type: "",
// reqID: "",
// uid: "",
// udid: "",
// code: "",
// message: "",
// script: "",
// line: "",
// column: "",
// stack: ""
// }],
// });
// }
//
// function initSelect() {
// $('#selectedApp').change(function() {
// selectedApp = $('#selectedApp').val();
// });
//
// $('#search').on('click', () => {
// _handleChanged();
// })
// }
//
// function _handleChanged() {
// dataTable && dataTable.ajax.url(ajaxUrl()).load();
// }
var selectedServer, selectedApp;
var data_end_point = '/profile/error.json';
var dataTable = null;
... ... @@ -102,7 +177,7 @@
{data: 'time'},
{data: 'app'},
{data: 'type'},
{data: 'reqID'},
{data: 'reqid'},
{data: 'uid'},
{data: 'udid'},
{data: 'code', defaultContent: '无'},
... ... @@ -116,7 +191,7 @@
time: "",
app: "",
type: "",
reqID: "",
reqid: "",
uid: "",
udid: "",
code: "",
... ... @@ -137,7 +212,8 @@
},
targets: 0
}
],
]
});
}
... ...
... ... @@ -50,11 +50,11 @@ const defaults = {
database: 'yoho_seo'
},
apmMysql: {
host: 'localhost',
host: '192.168.102.168',
user: 'root',
password: 'root',
port: '3306',
database: 'web-apm'
database: 'webapm'
},
domains: {
// test3
... ...