simple_apm 1.0.14 → 1.1.1
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/README.md +39 -31
- data/Rakefile +0 -5
- data/app/assets/stylesheets/simple_apm/application.css +611 -1
- data/app/controllers/simple_apm/apm_controller.rb +12 -6
- data/app/controllers/simple_apm/application_controller.rb +15 -1
- 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 +57 -65
- 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/config/locales/simple_apm.en.yml +131 -0
- data/config/locales/simple_apm.zh-CN.yml +131 -0
- data/config/routes.rb +1 -0
- 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 +39 -13
|
@@ -3,6 +3,7 @@ module SimpleApm
|
|
|
3
3
|
class Request
|
|
4
4
|
attr_accessor :request_id, :action_name,
|
|
5
5
|
:during, :started, :db_runtime, :view_runtime,
|
|
6
|
+
:queries_count, :cached_queries_count,
|
|
6
7
|
:controller, :action, :format, :method,
|
|
7
8
|
:host, :remote_addr, :url, :completed_memory, :memory_during,
|
|
8
9
|
:exception, :status, :net_http_during
|
|
@@ -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,17 +41,21 @@
|
|
|
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
|
-
[dashboard_path,
|
|
90
|
-
[index_path,
|
|
91
|
-
[actions_path,
|
|
92
|
-
[data_path,
|
|
55
|
+
[dashboard_path, t("simple_apm.layout.nav_dashboard")],
|
|
56
|
+
[index_path, t("simple_apm.layout.nav_slow_requests")],
|
|
57
|
+
[actions_path, t("simple_apm.layout.nav_actions")],
|
|
58
|
+
[data_path, t("simple_apm.layout.nav_data")]
|
|
93
59
|
].each do |m|
|
|
94
60
|
%>
|
|
95
61
|
<a class="navbar-brand <%= 'active' if request.url =~ /#{m[0]}/ %>"
|
|
@@ -98,36 +64,62 @@
|
|
|
98
64
|
</a>
|
|
99
65
|
<% end %>
|
|
100
66
|
</div>
|
|
101
|
-
<div class="
|
|
102
|
-
|
|
67
|
+
<div class="apm-language-switch" aria-label="<%= t("simple_apm.layout.language") %>">
|
|
68
|
+
<% SimpleApm::ApplicationController::AVAILABLE_LOCALES.each do |locale| %>
|
|
69
|
+
<%= link_to t("simple_apm.locales.#{locale}"),
|
|
70
|
+
set_locale_path(locale: locale),
|
|
71
|
+
class: ("active" if simple_apm_locale == locale) %>
|
|
72
|
+
<% end %>
|
|
73
|
+
</div>
|
|
74
|
+
<div class="select-apm-date apm-date-select">
|
|
75
|
+
<span><%= t("simple_apm.layout.date") %></span>
|
|
103
76
|
<%= select_tag 'apm_date', options_for_select(SimpleApm::Redis.in_apm_days, apm_date), class: 'form-control' %>
|
|
104
77
|
</div>
|
|
105
|
-
|
|
106
78
|
</div>
|
|
107
79
|
</nav>
|
|
108
|
-
<
|
|
80
|
+
<main class="apm-content">
|
|
109
81
|
<%= yield %>
|
|
110
|
-
</
|
|
82
|
+
</main>
|
|
111
83
|
</div>
|
|
112
|
-
<footer
|
|
113
|
-
|
|
114
|
-
<label><%= k %>:</label><span><%= v %></span>
|
|
115
|
-
<% end %>
|
|
116
|
-
<p>
|
|
84
|
+
<footer class="apm-footer">
|
|
85
|
+
<div class="apm-footer-status">
|
|
117
86
|
<% if SimpleApm::Redis.running? %>
|
|
118
|
-
<span
|
|
87
|
+
<span class="apm-status apm-status-ok"><%= t("simple_apm.layout.collected") %></span>
|
|
119
88
|
<% else %>
|
|
120
|
-
<span
|
|
89
|
+
<span class="apm-status apm-status-danger"><%= t("simple_apm.common.paused") %></span>
|
|
121
90
|
<% end %>
|
|
122
|
-
</
|
|
91
|
+
</div>
|
|
92
|
+
<div class="apm-footer-meta">
|
|
93
|
+
<% SimpleApm::Redis.simple_info.each do |k, v| %>
|
|
94
|
+
<%
|
|
95
|
+
redis_label_key =
|
|
96
|
+
case k
|
|
97
|
+
when '系统内存'
|
|
98
|
+
'system_memory'
|
|
99
|
+
when '当前内存占用'
|
|
100
|
+
'current_memory'
|
|
101
|
+
when '当前内存占用(rss)'
|
|
102
|
+
'current_memory_rss'
|
|
103
|
+
when '占用内存峰值'
|
|
104
|
+
'peak_memory'
|
|
105
|
+
when 'redis版本'
|
|
106
|
+
'redis_version'
|
|
107
|
+
when /db[0-9]+/
|
|
108
|
+
'db'
|
|
109
|
+
end
|
|
110
|
+
redis_label = redis_label_key ? t("simple_apm.layout.redis_info.#{redis_label_key}") : k
|
|
111
|
+
%>
|
|
112
|
+
<span><label><%= redis_label %>:</label><%= v %></span>
|
|
113
|
+
<% end %>
|
|
114
|
+
</div>
|
|
123
115
|
</footer>
|
|
124
116
|
<div id="sql-modal" class="modal" aria-hidden="true" role="dialog" style="display: none;" tabindex="-1">
|
|
125
117
|
<div class="modal-dialog modal-lg modal-dialog-popout">
|
|
126
|
-
<div class="panel
|
|
127
|
-
<div class="
|
|
128
|
-
<div class="
|
|
118
|
+
<div class="apm-modal-panel">
|
|
119
|
+
<div class="apm-modal-header">
|
|
120
|
+
<div class="apm-modal-title">SQL</div>
|
|
129
121
|
</div>
|
|
130
|
-
<div class="
|
|
122
|
+
<div class="apm-modal-body">
|
|
131
123
|
<pre class="modal-content" data-lang="SQL"></pre>
|
|
132
124
|
</div>
|
|
133
125
|
</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"><%= t("simple_apm.action_info.title") %></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"><%= t("simple_apm.action_info.daily_hits") %></p>
|
|
11
|
+
<div class="apm-stat-value"><%= @action.click_count %></div>
|
|
12
|
+
</div>
|
|
13
|
+
<div class="apm-stat">
|
|
14
|
+
<p class="apm-stat-label"><%= t("simple_apm.action_info.avg_response_time") %></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"><%= t("simple_apm.action_info.avg_db_time") %></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"><%= t("simple_apm.action_info.avg_sql_count") %></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"><%= t("simple_apm.action_info.slowest_response_time") %></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"><%= t("simple_apm.action_info.fastest") %> <%= 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"><%= t("simple_apm.action_info.slow_samples_title") %></h2>
|
|
36
|
+
<p class="apm-panel-subtitle"><%= t("simple_apm.action_info.slow_samples_subtitle") %></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><%= t("simple_apm.action_info.response_time") %></th>
|
|
44
|
+
<th><%= t("simple_apm.action_info.access_time") %></th>
|
|
45
|
+
<th><%= t("simple_apm.action_info.memory_delta") %></th>
|
|
46
|
+
<th><%= t("simple_apm.action_info.request_id") %></th>
|
|
47
|
+
<th><%= t("simple_apm.action_info.ip") %></th>
|
|
48
|
+
<th><%= t("simple_apm.common.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
|
+
<%= t("simple_apm.common.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"><%= t("simple_apm.actions.title") %></h1>
|
|
4
|
+
<p class="apm-page-subtitle"><%= t("simple_apm.actions.subtitle") %></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"><%= t("simple_apm.actions.list_title") %></h2>
|
|
12
|
+
<p class="apm-panel-subtitle"><%= t("simple_apm.actions.list_subtitle") %></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><%= t("simple_apm.actions.name") %></th>
|
|
21
|
+
<th><%= t("simple_apm.actions.click_count") %></th>
|
|
22
|
+
<th><%= t("simple_apm.actions.avg_response_time") %></th>
|
|
23
|
+
<th><%= t("simple_apm.actions.avg_db_time") %></th>
|
|
24
|
+
<th><%= t("simple_apm.actions.avg_sql_count") %></th>
|
|
25
|
+
<th><%= t("simple_apm.actions.avg_http_time") %></th>
|
|
26
|
+
<th><%= t("simple_apm.actions.fastest_response_time") %></th>
|
|
27
|
+
<th><%= t("simple_apm.actions.slowest_response_time") %></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"><%= t("simple_apm.dashboard.title") %></h1>
|
|
4
|
+
<p class="apm-page-subtitle"><%= t("simple_apm.dashboard.subtitle") %></p>
|
|
5
|
+
</div>
|
|
6
|
+
</div>
|
|
7
|
+
|
|
8
|
+
<div class="apm-metrics">
|
|
9
|
+
<div class="apm-stat">
|
|
10
|
+
<p class="apm-stat-label"><%= t("simple_apm.dashboard.stat_points") %></p>
|
|
11
|
+
<div class="apm-stat-value"><%= @x_names.length %></div>
|
|
12
|
+
<div class="apm-stat-meta"><%= t("simple_apm.dashboard.ten_minute_intervals") %></div>
|
|
13
|
+
</div>
|
|
14
|
+
<div class="apm-stat">
|
|
15
|
+
<p class="apm-stat-label"><%= t("simple_apm.dashboard.hits") %></p>
|
|
16
|
+
<div class="apm-stat-value"><%= @hits_arr.map(&:to_i).sum %></div>
|
|
17
|
+
<div class="apm-stat-meta"><%= t("simple_apm.dashboard.current_day_total") %></div>
|
|
18
|
+
</div>
|
|
19
|
+
<div class="apm-stat">
|
|
20
|
+
<p class="apm-stat-label"><%= t("simple_apm.dashboard.peak_avg_response") %></p>
|
|
21
|
+
<div class="apm-stat-value"><%= sec_str(@time_arr.map(&:to_f).max.to_f) %></div>
|
|
22
|
+
<div class="apm-stat-meta"><%= t("simple_apm.dashboard.interval_peak") %></div>
|
|
23
|
+
</div>
|
|
24
|
+
<div class="apm-stat">
|
|
25
|
+
<p class="apm-stat-label"><%= t("simple_apm.dashboard.current_collection") %></p>
|
|
26
|
+
<div class="apm-stat-value">
|
|
27
|
+
<% if SimpleApm::Redis.running? %>
|
|
28
|
+
<span class="apm-status apm-status-ok"><%= t("simple_apm.common.running") %></span>
|
|
29
|
+
<% else %>
|
|
30
|
+
<span class="apm-status apm-status-danger"><%= t("simple_apm.common.paused") %></span>
|
|
31
|
+
<% end %>
|
|
32
|
+
</div>
|
|
33
|
+
<div class="apm-stat-meta"><%= t("simple_apm.dashboard.redis_status") %></div>
|
|
34
|
+
</div>
|
|
35
|
+
<div class="apm-stat">
|
|
36
|
+
<p class="apm-stat-label"><%= t("simple_apm.dashboard.query_date") %></p>
|
|
37
|
+
<div class="apm-stat-value"><%= SimpleApm::RedisKey.query_date || Time.now.strftime('%Y-%m-%d') %></div>
|
|
38
|
+
<div class="apm-stat-meta"><%= t("simple_apm.dashboard.switch_in_top_right") %></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"><%= t("simple_apm.dashboard.response_time") %></h2>
|
|
47
|
+
<p class="apm-panel-subtitle"><%= t("simple_apm.dashboard.response_time_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"><%= t("simple_apm.dashboard.hit_count") %></h2>
|
|
59
|
+
<p class="apm-panel-subtitle"><%= t("simple_apm.dashboard.hit_count_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"><%= t("simple_apm.data.title") %></h1>
|
|
4
|
+
<p class="apm-page-subtitle"><%= t("simple_apm.data.subtitle") %></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"><%= t("simple_apm.data.collection_status") %></h2>
|
|
12
|
+
<p class="apm-panel-subtitle"><%= t("simple_apm.data.collection_subtitle") %></p>
|
|
13
|
+
</div>
|
|
14
|
+
<div class="apm-toolbar-actions">
|
|
15
|
+
<% if SimpleApm::Redis.running? %>
|
|
16
|
+
<span class="apm-status apm-status-ok"><%= t("simple_apm.common.running") %></span>
|
|
17
|
+
<%= link_to t("simple_apm.data.pause_collection"), data_delete_path(type: 'stop_data'), class: 'btn btn-warning btn-sm', 'data-confirm'=> t("simple_apm.data.confirm_pause") %>
|
|
18
|
+
<% else %>
|
|
19
|
+
<span class="apm-status apm-status-danger"><%= t("simple_apm.common.paused") %></span>
|
|
20
|
+
<%= link_to t("simple_apm.data.resume_collection"), 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><%= t("simple_apm.data.delete_data") %></strong>
|
|
28
|
+
<p class="apm-page-subtitle"><%= t("simple_apm.data.delete_subtitle") %></p>
|
|
29
|
+
</div>
|
|
30
|
+
<div class="apm-toolbar-actions">
|
|
31
|
+
<%= link_to t("simple_apm.data.keep_one_week"), data_delete_path(type: 'week'), class: 'btn btn-danger', 'data-confirm' => t("simple_apm.data.confirm_delete_week") %>
|
|
32
|
+
<%= link_to t("simple_apm.data.keep_one_month"), data_delete_path(type: 'month'), class: 'btn btn-danger', 'data-confirm' => t("simple_apm.data.confirm_delete_month") %>
|
|
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"><%= t("simple_apm.data.history_title") %></h2>
|
|
42
|
+
<p class="apm-panel-subtitle"><%= t("simple_apm.data.history_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><%= t("simple_apm.data.date") %></th>
|
|
51
|
+
<th><%= t("simple_apm.data.request_count") %></th>
|
|
52
|
+
<th><%= t("simple_apm.data.avg_response_time") %></th>
|
|
53
|
+
<th><%= t("simple_apm.data.operation") %></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 t("simple_apm.data.delete"), data_delete_path(date: d[:day]), class: 'apm-danger-link', 'data-confirm' => t("simple_apm.data.confirm_delete") %></td>
|
|
64
|
+
</tr>
|
|
65
|
+
<% end %>
|
|
66
|
+
</tbody>
|
|
67
|
+
</table>
|
|
68
|
+
</div>
|
|
69
|
+
</div>
|
|
70
|
+
</section>
|