simple_apm 1.0.14 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/Rakefile +0 -5
- data/app/assets/stylesheets/simple_apm/application.css +572 -1
- data/app/controllers/simple_apm/apm_controller.rb +1 -0
- data/app/models/simple_apm/action.rb +20 -1
- data/app/models/simple_apm/request.rb +1 -0
- data/app/views/layouts/simple_apm/application.html.erb +28 -61
- data/app/views/simple_apm/apm/action_info.html.erb +72 -47
- data/app/views/simple_apm/apm/actions.html.erb +49 -26
- data/app/views/simple_apm/apm/dashboard.html.erb +100 -14
- data/app/views/simple_apm/apm/data.html.erb +69 -32
- data/app/views/simple_apm/apm/index.html.erb +35 -21
- data/app/views/simple_apm/apm/show.html.erb +132 -82
- data/lib/simple_apm/redis.rb +2 -2
- data/lib/simple_apm/setting.rb +11 -1
- data/lib/simple_apm/version.rb +1 -1
- data/lib/simple_apm/worker.rb +3 -1
- data/lib/simple_apm.rb +12 -9
- metadata +37 -13
|
@@ -7,49 +7,11 @@
|
|
|
7
7
|
<meta content="width=device-width, initial-scale=1.0" name="viewport">
|
|
8
8
|
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
|
|
9
9
|
<link rel="stylesheet" href="//cdn.datatables.net/1.10.15/css/jquery.dataTables.min.css">
|
|
10
|
+
<%= stylesheet_link_tag "simple_apm/application", media: "all" %>
|
|
10
11
|
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
|
|
11
12
|
<script src="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
|
|
12
13
|
<script src="//cdnjs.cloudflare.com/ajax/libs/echarts/4.1.0/echarts.js"></script>
|
|
13
14
|
<script src="//cdn.datatables.net/1.10.15/js/jquery.dataTables.min.js"></script>
|
|
14
|
-
<style>
|
|
15
|
-
footer {
|
|
16
|
-
text-align: center;
|
|
17
|
-
padding: 10px;
|
|
18
|
-
border-top: 1px solid #999999;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
a.navbar-brand.active {
|
|
22
|
-
color: #00AEEF !important;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
#page-container {
|
|
26
|
-
min-height: 80vh;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
.select-apm-date {
|
|
30
|
-
width: auto;
|
|
31
|
-
float: right;
|
|
32
|
-
margin-top: 8px;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
.select-apm-date > select {
|
|
36
|
-
display: inline-block;
|
|
37
|
-
width: auto;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
.sql {
|
|
41
|
-
max-width: 300px;
|
|
42
|
-
white-space: nowrap;
|
|
43
|
-
text-overflow: ellipsis;
|
|
44
|
-
overflow: hidden;
|
|
45
|
-
color: #00AEEF;
|
|
46
|
-
cursor: pointer;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
pre {
|
|
50
|
-
white-space: pre-wrap;
|
|
51
|
-
}
|
|
52
|
-
</style>
|
|
53
15
|
<script type="text/javascript">
|
|
54
16
|
// JqueryDataTable自定义排序方法
|
|
55
17
|
jQuery.extend(jQuery.fn.dataTableExt.oSort, {
|
|
@@ -79,11 +41,15 @@
|
|
|
79
41
|
|
|
80
42
|
<%= csrf_meta_tags %>
|
|
81
43
|
</head>
|
|
82
|
-
<body>
|
|
83
|
-
<div id="page-container">
|
|
84
|
-
<nav class="
|
|
85
|
-
<div class="
|
|
86
|
-
<div class="
|
|
44
|
+
<body class="simple-apm">
|
|
45
|
+
<div id="page-container" class="apm-shell">
|
|
46
|
+
<nav class="apm-topbar">
|
|
47
|
+
<div class="apm-topbar-inner">
|
|
48
|
+
<div class="apm-brand">
|
|
49
|
+
<span class="apm-brand-mark">SA</span>
|
|
50
|
+
<span class="apm-brand-name">Simple APM</span>
|
|
51
|
+
</div>
|
|
52
|
+
<div class="apm-nav">
|
|
87
53
|
<%
|
|
88
54
|
[
|
|
89
55
|
[dashboard_path, 'Dashboard'],
|
|
@@ -98,36 +64,37 @@
|
|
|
98
64
|
</a>
|
|
99
65
|
<% end %>
|
|
100
66
|
</div>
|
|
101
|
-
<div class="select-apm-date">
|
|
102
|
-
|
|
67
|
+
<div class="select-apm-date apm-date-select">
|
|
68
|
+
<span>统计日期</span>
|
|
103
69
|
<%= select_tag 'apm_date', options_for_select(SimpleApm::Redis.in_apm_days, apm_date), class: 'form-control' %>
|
|
104
70
|
</div>
|
|
105
|
-
|
|
106
71
|
</div>
|
|
107
72
|
</nav>
|
|
108
|
-
<
|
|
73
|
+
<main class="apm-content">
|
|
109
74
|
<%= yield %>
|
|
110
|
-
</
|
|
75
|
+
</main>
|
|
111
76
|
</div>
|
|
112
|
-
<footer
|
|
113
|
-
|
|
114
|
-
<label><%= k %>:</label><span><%= v %></span>
|
|
115
|
-
<% end %>
|
|
116
|
-
<p>
|
|
77
|
+
<footer class="apm-footer">
|
|
78
|
+
<div class="apm-footer-status">
|
|
117
79
|
<% if SimpleApm::Redis.running? %>
|
|
118
|
-
<span
|
|
80
|
+
<span class="apm-status apm-status-ok">数据收集中</span>
|
|
119
81
|
<% else %>
|
|
120
|
-
<span
|
|
82
|
+
<span class="apm-status apm-status-danger">已暂停</span>
|
|
121
83
|
<% end %>
|
|
122
|
-
</
|
|
84
|
+
</div>
|
|
85
|
+
<div class="apm-footer-meta">
|
|
86
|
+
<% SimpleApm::Redis.simple_info.each do |k, v| %>
|
|
87
|
+
<span><label><%= k %>:</label><%= v %></span>
|
|
88
|
+
<% end %>
|
|
89
|
+
</div>
|
|
123
90
|
</footer>
|
|
124
91
|
<div id="sql-modal" class="modal" aria-hidden="true" role="dialog" style="display: none;" tabindex="-1">
|
|
125
92
|
<div class="modal-dialog modal-lg modal-dialog-popout">
|
|
126
|
-
<div class="panel
|
|
127
|
-
<div class="
|
|
128
|
-
<div class="
|
|
93
|
+
<div class="apm-modal-panel">
|
|
94
|
+
<div class="apm-modal-header">
|
|
95
|
+
<div class="apm-modal-title">SQL</div>
|
|
129
96
|
</div>
|
|
130
|
-
<div class="
|
|
97
|
+
<div class="apm-modal-body">
|
|
131
98
|
<pre class="modal-content" data-lang="SQL"></pre>
|
|
132
99
|
</div>
|
|
133
100
|
</div>
|
|
@@ -1,48 +1,73 @@
|
|
|
1
|
-
<
|
|
2
|
-
<
|
|
3
|
-
<
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
</
|
|
7
|
-
<p>
|
|
8
|
-
<label>平均响应时间:</label>
|
|
9
|
-
<span><%= sec_str @action.time.to_f/@action.click_count.to_i %></span>
|
|
10
|
-
</p>
|
|
11
|
-
<p>
|
|
12
|
-
<label>最慢响应时间:</label>
|
|
13
|
-
<span><%= link_to sec_str(@action.slow_time), show_path(id: @action.slow_id) %></span>
|
|
14
|
-
</p>
|
|
15
|
-
<p>
|
|
16
|
-
<label>最快响应时间:</label>
|
|
17
|
-
<span><%= link_to sec_str(@action.fast_time), show_path(id: @action.fast_id) %></span>
|
|
18
|
-
</p>
|
|
19
|
-
<table class="table table-bordered">
|
|
20
|
-
<tr>
|
|
21
|
-
<th>响应时间</th>
|
|
22
|
-
<th>访问时间</th>
|
|
23
|
-
<th>内存波动</th>
|
|
24
|
-
<th>请求id</th>
|
|
25
|
-
<th>访问ip</th>
|
|
26
|
-
<th>server</th>
|
|
27
|
-
</tr>
|
|
28
|
-
<% @action.slow_requests.each do |slow_request| %>
|
|
29
|
-
<%
|
|
30
|
-
r = slow_request.request
|
|
31
|
-
next if r.blank?
|
|
32
|
-
%>
|
|
33
|
-
<tr>
|
|
34
|
-
<td>
|
|
35
|
-
<%= sec_str r.during %>
|
|
36
|
-
(DB: <%= sec_str r.db_runtime %> ,
|
|
37
|
-
View: <%= sec_str r.view_runtime %>
|
|
38
|
-
<%= "HTTP: #{sec_str r.net_http_during}" if r.net_http_during.to_f > 0 %>)
|
|
39
|
-
</td>
|
|
40
|
-
<td><%= time_label r.started %></td>
|
|
41
|
-
<td><%= r.memory_during.to_f.round(1) %></td>
|
|
42
|
-
<td><%= link_to r.request_id, show_path(id: r.request_id) %></td>
|
|
43
|
-
<td><%= r.remote_addr %></td>
|
|
44
|
-
<td><%= r.host %></td>
|
|
45
|
-
</tr>
|
|
46
|
-
<% end %>
|
|
47
|
-
</table>
|
|
1
|
+
<div class="apm-page-header">
|
|
2
|
+
<div>
|
|
3
|
+
<h1 class="apm-page-title">Action 概况</h1>
|
|
4
|
+
<p class="apm-page-subtitle"><%= @action.name %></p>
|
|
5
|
+
</div>
|
|
6
|
+
</div>
|
|
48
7
|
|
|
8
|
+
<div class="apm-metrics">
|
|
9
|
+
<div class="apm-stat">
|
|
10
|
+
<p class="apm-stat-label">当日点击次数</p>
|
|
11
|
+
<div class="apm-stat-value"><%= @action.click_count %></div>
|
|
12
|
+
</div>
|
|
13
|
+
<div class="apm-stat">
|
|
14
|
+
<p class="apm-stat-label">平均响应时间</p>
|
|
15
|
+
<div class="apm-stat-value"><%= sec_str @action.time.to_f/@action.click_count.to_i %></div>
|
|
16
|
+
</div>
|
|
17
|
+
<div class="apm-stat">
|
|
18
|
+
<p class="apm-stat-label">平均DB时间</p>
|
|
19
|
+
<div class="apm-stat-value"><%= sec_str @action.avg_db_time %></div>
|
|
20
|
+
</div>
|
|
21
|
+
<div class="apm-stat">
|
|
22
|
+
<p class="apm-stat-label">平均SQL次数</p>
|
|
23
|
+
<div class="apm-stat-value"><%= @action.avg_queries_count.round(1) %></div>
|
|
24
|
+
</div>
|
|
25
|
+
<div class="apm-stat">
|
|
26
|
+
<p class="apm-stat-label">最慢响应时间</p>
|
|
27
|
+
<div class="apm-stat-value"><%= link_to sec_str(@action.slow_time), show_path(id: @action.slow_id) %></div>
|
|
28
|
+
<div class="apm-stat-meta">最快 <%= link_to sec_str(@action.fast_time), show_path(id: @action.fast_id) %></div>
|
|
29
|
+
</div>
|
|
30
|
+
</div>
|
|
31
|
+
|
|
32
|
+
<section class="apm-panel">
|
|
33
|
+
<div class="apm-panel-header">
|
|
34
|
+
<div>
|
|
35
|
+
<h2 class="apm-panel-title">慢请求样本</h2>
|
|
36
|
+
<p class="apm-panel-subtitle">保留该 Action 下响应最慢的请求。</p>
|
|
37
|
+
</div>
|
|
38
|
+
</div>
|
|
39
|
+
<div class="apm-panel-body">
|
|
40
|
+
<div class="apm-table-wrap">
|
|
41
|
+
<table class="table table-bordered">
|
|
42
|
+
<tr>
|
|
43
|
+
<th>响应时间</th>
|
|
44
|
+
<th>访问时间</th>
|
|
45
|
+
<th>内存波动</th>
|
|
46
|
+
<th>请求id</th>
|
|
47
|
+
<th>访问ip</th>
|
|
48
|
+
<th>server</th>
|
|
49
|
+
</tr>
|
|
50
|
+
<% @action.slow_requests.each do |slow_request| %>
|
|
51
|
+
<%
|
|
52
|
+
r = slow_request.request
|
|
53
|
+
next if r.blank?
|
|
54
|
+
%>
|
|
55
|
+
<tr>
|
|
56
|
+
<td>
|
|
57
|
+
<%= sec_str r.during %>
|
|
58
|
+
(DB: <%= sec_str r.db_runtime %> ,
|
|
59
|
+
SQL: <%= r.queries_count.to_i %> ,
|
|
60
|
+
View: <%= sec_str r.view_runtime %>
|
|
61
|
+
<%= "HTTP: #{sec_str r.net_http_during}" if r.net_http_during.to_f > 0 %>)
|
|
62
|
+
</td>
|
|
63
|
+
<td><%= time_label r.started %></td>
|
|
64
|
+
<td><%= r.memory_during.to_f.round(1) %></td>
|
|
65
|
+
<td><%= link_to r.request_id, show_path(id: r.request_id) %></td>
|
|
66
|
+
<td><%= r.remote_addr %></td>
|
|
67
|
+
<td><%= r.host %></td>
|
|
68
|
+
</tr>
|
|
69
|
+
<% end %>
|
|
70
|
+
</table>
|
|
71
|
+
</div>
|
|
72
|
+
</div>
|
|
73
|
+
</section>
|
|
@@ -1,34 +1,57 @@
|
|
|
1
|
-
<
|
|
2
|
-
<
|
|
3
|
-
|
|
4
|
-
<
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
<
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
1
|
+
<div class="apm-page-header">
|
|
2
|
+
<div>
|
|
3
|
+
<h1 class="apm-page-title">Action 性能</h1>
|
|
4
|
+
<p class="apm-page-subtitle">按 Controller#Action 聚合访问次数、响应时间和 SQL 行为。</p>
|
|
5
|
+
</div>
|
|
6
|
+
</div>
|
|
7
|
+
|
|
8
|
+
<section class="apm-panel">
|
|
9
|
+
<div class="apm-panel-header">
|
|
10
|
+
<div>
|
|
11
|
+
<h2 class="apm-panel-title">Action 列表</h2>
|
|
12
|
+
<p class="apm-panel-subtitle">点击 Action 名称查看该接口的慢请求样本。</p>
|
|
13
|
+
</div>
|
|
14
|
+
</div>
|
|
15
|
+
<div class="apm-panel-body">
|
|
16
|
+
<div class="apm-table-wrap">
|
|
17
|
+
<table id="actions-table" class="table">
|
|
18
|
+
<thead>
|
|
19
|
+
<tr>
|
|
20
|
+
<th>Name</th>
|
|
21
|
+
<th>点击次数</th>
|
|
22
|
+
<th>平均响应时间</th>
|
|
23
|
+
<th>平均DB时间</th>
|
|
24
|
+
<th>平均SQL次数</th>
|
|
25
|
+
<th>平均http访问时间</th>
|
|
26
|
+
<th>最快响应时间</th>
|
|
27
|
+
<th>最慢响应时间</th>
|
|
28
|
+
</tr>
|
|
29
|
+
</thead>
|
|
30
|
+
<tbody>
|
|
31
|
+
<% @actions.each do |action| %>
|
|
32
|
+
<tr>
|
|
33
|
+
<td><%= link_to action.name, action_info_path(action_name: action.name) %></td>
|
|
34
|
+
<td><%= action.click_count %></td>
|
|
35
|
+
<td><%= sec_str action.avg_time %></td>
|
|
36
|
+
<td><%= sec_str action.avg_db_time %></td>
|
|
37
|
+
<td><%= action.avg_queries_count.round(1) %></td>
|
|
38
|
+
<td><%= sec_str action.avg_http_time %></td>
|
|
39
|
+
<td><%= link_to sec_str(action.fast_time), show_path(id: action.fast_id) %></td>
|
|
40
|
+
<td><%= link_to sec_str(action.slow_time), show_path(id: action.slow_id) %></td>
|
|
41
|
+
</tr>
|
|
42
|
+
<% end %>
|
|
43
|
+
</tbody>
|
|
44
|
+
</table>
|
|
45
|
+
</div>
|
|
46
|
+
</div>
|
|
47
|
+
</section>
|
|
25
48
|
<script type="text/javascript">
|
|
26
49
|
$(document).ready(function(){
|
|
27
50
|
$('#actions-table').DataTable({
|
|
28
51
|
iDisplayLength: 25,
|
|
29
52
|
// 自定义的排序方法
|
|
30
|
-
aoColumnDefs: [ {sType: "sec", aTargets: [2,3,
|
|
53
|
+
aoColumnDefs: [ {sType: "sec", aTargets: [2,3,5,6]}]
|
|
31
54
|
})
|
|
32
55
|
|
|
33
56
|
})
|
|
34
|
-
</script>
|
|
57
|
+
</script>
|
|
@@ -1,37 +1,123 @@
|
|
|
1
|
-
<div
|
|
2
|
-
<div
|
|
1
|
+
<div class="apm-page-header">
|
|
2
|
+
<div>
|
|
3
|
+
<h1 class="apm-page-title">性能概览</h1>
|
|
4
|
+
<p class="apm-page-subtitle">按 10 分钟粒度观察响应时间和访问量趋势。</p>
|
|
5
|
+
</div>
|
|
6
|
+
</div>
|
|
7
|
+
|
|
8
|
+
<div class="apm-metrics">
|
|
9
|
+
<div class="apm-stat">
|
|
10
|
+
<p class="apm-stat-label">统计点</p>
|
|
11
|
+
<div class="apm-stat-value"><%= @x_names.length %></div>
|
|
12
|
+
<div class="apm-stat-meta">10 分钟区间</div>
|
|
13
|
+
</div>
|
|
14
|
+
<div class="apm-stat">
|
|
15
|
+
<p class="apm-stat-label">访问次数</p>
|
|
16
|
+
<div class="apm-stat-value"><%= @hits_arr.map(&:to_i).sum %></div>
|
|
17
|
+
<div class="apm-stat-meta">当前日期累计</div>
|
|
18
|
+
</div>
|
|
19
|
+
<div class="apm-stat">
|
|
20
|
+
<p class="apm-stat-label">最高平均响应</p>
|
|
21
|
+
<div class="apm-stat-value"><%= sec_str(@time_arr.map(&:to_f).max.to_f) %></div>
|
|
22
|
+
<div class="apm-stat-meta">区间峰值</div>
|
|
23
|
+
</div>
|
|
24
|
+
<div class="apm-stat">
|
|
25
|
+
<p class="apm-stat-label">当前采集</p>
|
|
26
|
+
<div class="apm-stat-value">
|
|
27
|
+
<% if SimpleApm::Redis.running? %>
|
|
28
|
+
<span class="apm-status apm-status-ok">运行中</span>
|
|
29
|
+
<% else %>
|
|
30
|
+
<span class="apm-status apm-status-danger">已暂停</span>
|
|
31
|
+
<% end %>
|
|
32
|
+
</div>
|
|
33
|
+
<div class="apm-stat-meta">Redis 状态</div>
|
|
34
|
+
</div>
|
|
35
|
+
<div class="apm-stat">
|
|
36
|
+
<p class="apm-stat-label">查询日期</p>
|
|
37
|
+
<div class="apm-stat-value"><%= SimpleApm::RedisKey.query_date || Time.now.strftime('%Y-%m-%d') %></div>
|
|
38
|
+
<div class="apm-stat-meta">可在右上角切换</div>
|
|
39
|
+
</div>
|
|
40
|
+
</div>
|
|
41
|
+
|
|
42
|
+
<div class="apm-grid">
|
|
43
|
+
<section class="apm-panel apm-col-6">
|
|
44
|
+
<div class="apm-panel-header">
|
|
45
|
+
<div>
|
|
46
|
+
<h2 class="apm-panel-title">响应时间</h2>
|
|
47
|
+
<p class="apm-panel-subtitle">每个时间段的平均响应耗时。</p>
|
|
48
|
+
</div>
|
|
49
|
+
</div>
|
|
50
|
+
<div class="apm-panel-body">
|
|
51
|
+
<div id="time_chart" class="apm-chart"></div>
|
|
52
|
+
</div>
|
|
53
|
+
</section>
|
|
54
|
+
|
|
55
|
+
<section class="apm-panel apm-col-6">
|
|
56
|
+
<div class="apm-panel-header">
|
|
57
|
+
<div>
|
|
58
|
+
<h2 class="apm-panel-title">访问次数</h2>
|
|
59
|
+
<p class="apm-panel-subtitle">每个时间段的请求数量。</p>
|
|
60
|
+
</div>
|
|
61
|
+
</div>
|
|
62
|
+
<div class="apm-panel-body">
|
|
63
|
+
<div id="hits_chart" class="apm-chart"></div>
|
|
64
|
+
</div>
|
|
65
|
+
</section>
|
|
66
|
+
</div>
|
|
67
|
+
|
|
3
68
|
<script>
|
|
4
69
|
var time_chart = echarts.init(document.getElementById('time_chart')),
|
|
5
70
|
hits_chart = echarts.init(document.getElementById('hits_chart'));
|
|
6
71
|
time_chart.setOption({
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
},
|
|
10
|
-
tooltip: {},
|
|
72
|
+
color: ['#0f766e'],
|
|
73
|
+
grid: {left: 48, right: 18, top: 24, bottom: 36},
|
|
74
|
+
tooltip: {trigger: 'axis'},
|
|
11
75
|
xAxis: {
|
|
12
|
-
data: <%= @x_names.to_json.html_safe
|
|
76
|
+
data: <%= @x_names.to_json.html_safe %>,
|
|
77
|
+
axisLine: {lineStyle: {color: '#c8d2df'}},
|
|
78
|
+
axisLabel: {color: '#667085'}
|
|
79
|
+
},
|
|
80
|
+
yAxis: {
|
|
81
|
+
type: 'value',
|
|
82
|
+
axisLine: {show: false},
|
|
83
|
+
splitLine: {lineStyle: {color: '#eef2f7'}},
|
|
84
|
+
axisLabel: {color: '#667085'}
|
|
13
85
|
},
|
|
14
|
-
yAxis: {type: 'value'},
|
|
15
86
|
series: [{
|
|
16
87
|
type: 'line',
|
|
17
88
|
smooth: true,
|
|
89
|
+
symbolSize: 6,
|
|
90
|
+
areaStyle: {color: 'rgba(15, 118, 110, 0.10)'},
|
|
18
91
|
data: <%= @time_arr.to_json.html_safe %>
|
|
19
92
|
}]
|
|
20
93
|
})
|
|
21
94
|
|
|
22
95
|
hits_chart.setOption({
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
},
|
|
26
|
-
tooltip: {},
|
|
96
|
+
color: ['#2563eb'],
|
|
97
|
+
grid: {left: 48, right: 18, top: 24, bottom: 36},
|
|
98
|
+
tooltip: {trigger: 'axis'},
|
|
27
99
|
xAxis: {
|
|
28
|
-
data: <%= @x_names.to_json.html_safe
|
|
100
|
+
data: <%= @x_names.to_json.html_safe %>,
|
|
101
|
+
axisLine: {lineStyle: {color: '#c8d2df'}},
|
|
102
|
+
axisLabel: {color: '#667085'}
|
|
103
|
+
},
|
|
104
|
+
yAxis: {
|
|
105
|
+
type: 'value',
|
|
106
|
+
axisLine: {show: false},
|
|
107
|
+
splitLine: {lineStyle: {color: '#eef2f7'}},
|
|
108
|
+
axisLabel: {color: '#667085'}
|
|
29
109
|
},
|
|
30
|
-
yAxis: {type: 'value'},
|
|
31
110
|
series: [{
|
|
32
111
|
type: 'line',
|
|
33
112
|
smooth: true,
|
|
113
|
+
symbolSize: 6,
|
|
114
|
+
areaStyle: {color: 'rgba(37, 99, 235, 0.10)'},
|
|
34
115
|
data: <%= @hits_arr.to_json.html_safe %>
|
|
35
116
|
}]
|
|
36
117
|
})
|
|
118
|
+
|
|
119
|
+
$(window).on('resize', function () {
|
|
120
|
+
time_chart.resize()
|
|
121
|
+
hits_chart.resize()
|
|
122
|
+
})
|
|
37
123
|
</script>
|
|
@@ -1,33 +1,70 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
<p class="pull-right">
|
|
8
|
-
<span class="text-danger">删除数据:</span>
|
|
9
|
-
<%= link_to '保留一周数据', data_delete_path(type: 'week'), class: 'btn btn-danger', 'data-confirm' => '确定删除所有一周以前的数据?' %>
|
|
10
|
-
<%= link_to '保留一个月数据', data_delete_path(type: 'month'), class: 'btn btn-danger', 'data-confirm' => '确定删除所有一个月以前的数据?' %>
|
|
11
|
-
</p>
|
|
1
|
+
<div class="apm-page-header">
|
|
2
|
+
<div>
|
|
3
|
+
<h1 class="apm-page-title">数据管理</h1>
|
|
4
|
+
<p class="apm-page-subtitle">管理采集开关和历史 Redis 数据。</p>
|
|
5
|
+
</div>
|
|
6
|
+
</div>
|
|
12
7
|
|
|
13
|
-
<
|
|
14
|
-
<
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
<
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
8
|
+
<section class="apm-panel">
|
|
9
|
+
<div class="apm-panel-header">
|
|
10
|
+
<div>
|
|
11
|
+
<h2 class="apm-panel-title">采集状态</h2>
|
|
12
|
+
<p class="apm-panel-subtitle">暂停后 middleware 不再记录新的请求性能数据。</p>
|
|
13
|
+
</div>
|
|
14
|
+
<div class="apm-toolbar-actions">
|
|
15
|
+
<% if SimpleApm::Redis.running? %>
|
|
16
|
+
<span class="apm-status apm-status-ok">运行中</span>
|
|
17
|
+
<%= link_to '暂停收集数据', data_delete_path(type: 'stop_data'), class: 'btn btn-warning btn-sm', 'data-confirm'=>'确定暂停吗?' %>
|
|
18
|
+
<% else %>
|
|
19
|
+
<span class="apm-status apm-status-danger">已暂停</span>
|
|
20
|
+
<%= link_to '继续收集数据', data_delete_path(type: 'rerun_data'), class: 'btn btn-primary btn-sm' %>
|
|
21
|
+
<% end %>
|
|
22
|
+
</div>
|
|
23
|
+
</div>
|
|
24
|
+
<div class="apm-panel-body">
|
|
25
|
+
<div class="apm-toolbar">
|
|
26
|
+
<div>
|
|
27
|
+
<strong>删除数据</strong>
|
|
28
|
+
<p class="apm-page-subtitle">按保留周期清理历史数据,或删除单日数据。</p>
|
|
29
|
+
</div>
|
|
30
|
+
<div class="apm-toolbar-actions">
|
|
31
|
+
<%= link_to '保留一周数据', data_delete_path(type: 'week'), class: 'btn btn-danger', 'data-confirm' => '确定删除所有一周以前的数据?' %>
|
|
32
|
+
<%= link_to '保留一个月数据', data_delete_path(type: 'month'), class: 'btn btn-danger', 'data-confirm' => '确定删除所有一个月以前的数据?' %>
|
|
33
|
+
</div>
|
|
34
|
+
</div>
|
|
35
|
+
</div>
|
|
36
|
+
</section>
|
|
37
|
+
|
|
38
|
+
<section class="apm-panel">
|
|
39
|
+
<div class="apm-panel-header">
|
|
40
|
+
<div>
|
|
41
|
+
<h2 class="apm-panel-title">历史数据</h2>
|
|
42
|
+
<p class="apm-panel-subtitle">以日期为单位查看采集量和平均响应时间。</p>
|
|
43
|
+
</div>
|
|
44
|
+
</div>
|
|
45
|
+
<div class="apm-panel-body">
|
|
46
|
+
<div class="apm-table-wrap">
|
|
47
|
+
<table class="table table-bordered">
|
|
48
|
+
<thead>
|
|
49
|
+
<tr>
|
|
50
|
+
<th>日期</th>
|
|
51
|
+
<th>请求数量</th>
|
|
52
|
+
<th>平均响应时间</th>
|
|
53
|
+
<th>操作</th>
|
|
54
|
+
</tr>
|
|
55
|
+
</thead>
|
|
56
|
+
<tbody>
|
|
57
|
+
<!-- {day: date_str, hits: hits, time: time, avg_time: avg_time}-->
|
|
58
|
+
<% @data.each do |d| %>
|
|
59
|
+
<tr>
|
|
60
|
+
<td><%= d[:day] %></td>
|
|
61
|
+
<td><%= d[:hits] %></td>
|
|
62
|
+
<td><%= sec_str d[:avg_time] %></td>
|
|
63
|
+
<td><%= link_to '删除', data_delete_path(date: d[:day]), class: 'apm-danger-link', 'data-confirm' => '确定删除?' %></td>
|
|
64
|
+
</tr>
|
|
65
|
+
<% end %>
|
|
66
|
+
</tbody>
|
|
67
|
+
</table>
|
|
68
|
+
</div>
|
|
69
|
+
</div>
|
|
70
|
+
</section>
|
|
@@ -1,24 +1,38 @@
|
|
|
1
|
-
<
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
</
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
<
|
|
10
|
-
<
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
<
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
</
|
|
1
|
+
<div class="apm-page-header">
|
|
2
|
+
<div>
|
|
3
|
+
<h1 class="apm-page-title">慢事务列表</h1>
|
|
4
|
+
<p class="apm-page-subtitle">按响应耗时排序,快速定位 DB、SQL、View 和外部请求占比。</p>
|
|
5
|
+
</div>
|
|
6
|
+
</div>
|
|
7
|
+
|
|
8
|
+
<section class="apm-panel">
|
|
9
|
+
<div class="apm-panel-header">
|
|
10
|
+
<div>
|
|
11
|
+
<h2 class="apm-panel-title">请求样本</h2>
|
|
12
|
+
<p class="apm-panel-subtitle">默认加载最近的慢请求记录。</p>
|
|
13
|
+
</div>
|
|
14
|
+
</div>
|
|
15
|
+
<div class="apm-panel-body">
|
|
16
|
+
<div class="apm-table-wrap">
|
|
17
|
+
<table id="slow-requests" class="table">
|
|
18
|
+
<thead>
|
|
19
|
+
<tr>
|
|
20
|
+
<th>请求时间</th>
|
|
21
|
+
<th>ActionName</th>
|
|
22
|
+
<th>TotalTime</th>
|
|
23
|
+
<th>DB</th>
|
|
24
|
+
<th>SQL</th>
|
|
25
|
+
<th>View</th>
|
|
26
|
+
<th>HTTP</th>
|
|
27
|
+
<th>Memory(Mb)</th>
|
|
28
|
+
<th>server</th>
|
|
29
|
+
<th>ip</th>
|
|
30
|
+
</tr>
|
|
31
|
+
</thead>
|
|
32
|
+
</table>
|
|
33
|
+
</div>
|
|
34
|
+
</div>
|
|
35
|
+
</section>
|
|
22
36
|
|
|
23
37
|
<script type="text/javascript">
|
|
24
38
|
$(document).ready(function () {
|