log_sense 2.2.1 → 2.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c2acfa576d18214e05df5520518000955d12957756674c26a5fd63ac6efc9969
4
- data.tar.gz: 781b38f2a7118efe8f0c1ca0cba6d21bdf0a77bd3fe27a8c1dc27ca5cdc2b3e7
3
+ metadata.gz: 8a9992db2fa42d1de3dac0bacbeed543a097e351c8bc9999c60febb3f67714a9
4
+ data.tar.gz: 06b9ed1329cbf3fdfdf889d154576dff85f16178e817b29fffede535eb1f12be
5
5
  SHA512:
6
- metadata.gz: bc877d0198d6f170addfd9a0972ed7df57df2d5c00fdac850808ab1f8f86c3ed3d2aa37cc1058f1c6ca1da86bbdc6e6e09a44778edca3a48aaf825f4d5aefa26
7
- data.tar.gz: ed99ed592a9a689fac9d319b1f346e705fcbbde021f45332d219097ed0df351d6b1d8a7bf2e0a72307b9932e2ab63ece7d0d8c2f2ef4fb9be45d14e2a5c6c863
6
+ metadata.gz: 0510a72e71e67e7bba948219f3ab35e7422c95a5a167815ccd30f589c172f19f7704e6e583364ac2493a7ff32c18df1316ef36d05f7e0346f582516b62d9f806
7
+ data.tar.gz: a374eea7ae662ac5be2458620baa4276bd7957871ccea67e82ba2987f941257ec2ffd1d1e7b62efd764093204976759470ccf7ca08a8152ecf1776d5eb023499
data/CHANGELOG.org CHANGED
@@ -2,6 +2,10 @@
2
2
  #+AUTHOR: Adolfo Villafiorita
3
3
  #+STARTUP: showall
4
4
 
5
+ * 2.3.0
6
+
7
+ - Adds average response time by day
8
+
5
9
  * 2.2.1
6
10
 
7
11
  - [Bug] Small fixes
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- log_sense (2.2.0)
4
+ log_sense (2.2.1)
5
5
  browser (~> 5.3.0)
6
6
  ipaddr (~> 1.2.0)
7
7
  iso_country_codes (~> 0.7.0)
@@ -11,7 +11,13 @@ PATH
11
11
  GEM
12
12
  remote: https://rubygems.org/
13
13
  specs:
14
+ ast (2.4.2)
14
15
  browser (5.3.1)
16
+ bundle-audit (0.1.0)
17
+ bundler-audit
18
+ bundler-audit (0.9.2)
19
+ bundler (>= 1.2.0, < 3)
20
+ thor (~> 1.0)
15
21
  debug (1.9.2)
16
22
  irb (~> 1.10)
17
23
  reline (>= 0.3.8)
@@ -21,30 +27,59 @@ GEM
21
27
  rdoc (>= 4.0.0)
22
28
  reline (>= 0.4.2)
23
29
  iso_country_codes (0.7.8)
30
+ json (2.7.2)
31
+ language_server-protocol (3.17.0.3)
24
32
  mini_portile2 (2.8.7)
25
33
  minitest (5.24.1)
34
+ parallel (1.26.3)
35
+ parser (3.3.4.2)
36
+ ast (~> 2.4.1)
37
+ racc
26
38
  psych (5.1.2)
27
39
  stringio
40
+ racc (1.8.1)
41
+ rainbow (3.1.1)
28
42
  rake (13.2.1)
29
43
  rdoc (6.7.0)
30
44
  psych (>= 4.0.0)
45
+ regexp_parser (2.9.2)
31
46
  reline (0.5.9)
32
47
  io-console (~> 0.5)
48
+ rexml (3.3.6)
49
+ strscan
50
+ rubocop (1.65.1)
51
+ json (~> 2.3)
52
+ language_server-protocol (>= 3.17.0)
53
+ parallel (~> 1.10)
54
+ parser (>= 3.3.0.2)
55
+ rainbow (>= 2.2.2, < 4.0)
56
+ regexp_parser (>= 2.4, < 3.0)
57
+ rexml (>= 3.2.5, < 4.0)
58
+ rubocop-ast (>= 1.31.1, < 2.0)
59
+ ruby-progressbar (~> 1.7)
60
+ unicode-display_width (>= 2.4.0, < 3.0)
61
+ rubocop-ast (1.32.1)
62
+ parser (>= 3.3.1.0)
63
+ ruby-progressbar (1.13.0)
33
64
  sqlite3 (2.0.3)
34
65
  mini_portile2 (~> 2.8.0)
35
66
  stringio (3.1.1)
67
+ strscan (3.1.0)
36
68
  terminal-table (3.0.2)
37
69
  unicode-display_width (>= 1.1.1, < 3)
70
+ thor (1.3.1)
38
71
  unicode-display_width (2.5.0)
39
72
 
40
73
  PLATFORMS
41
74
  ruby
42
75
 
43
76
  DEPENDENCIES
77
+ bundle-audit
44
78
  debug (~> 1.9.0)
45
79
  log_sense!
46
80
  minitest (~> 5.24.0)
47
81
  rake (~> 13.0)
82
+ rubocop
48
83
 
49
84
  BUNDLED WITH
50
85
  2.5.3
@@ -21,33 +21,33 @@ module LogSense
21
21
  # 116.179.32.16 - - [19/Dec/2021:22:35:11 +0100] "GET / HTTP/1.1" 200 135 "-" "Mozilla/5.0 (compatible; Baiduspider/2.0; +http://www.baidu.com/search/spider.html)"
22
22
  #
23
23
  class LogLineParser
24
- DAY = /[0-9]{2}/
25
- MONTH = /[A-Za-z]{3}/
26
- YEAR = /[0-9]{4}/
27
- TIMEC = /[0-9]{2}/
28
- TIMEZONE = /(\+|-)[0-9]{4}/
24
+ DAY = "[0-9]{2}"
25
+ MONTH = "[A-Za-z]{3}"
26
+ YEAR = "[0-9]{4}"
27
+ TIMEC = "[0-9]{2}"
28
+ TIMEZONE = "(\\+|-)[0-9]{4}"
29
29
 
30
- IP = /(?<ip>[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}|::1|unknown)/
31
- IDENT = /(?<ident>[^ ]+|-)/
32
- USERID = /(?<userid>[^ ]+|-)/
30
+ IP = "(?<ip>[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}|::1|unknown)"
31
+ IDENT = "(?<ident>[^ ]+|-)"
32
+ USERID = "(?<userid>[^ ]+|-)"
33
33
 
34
- TIMESTAMP = /(?<date>#{DAY}\/#{MONTH}\/#{YEAR}):(?<time>#{TIMEC}:#{TIMEC}:#{TIMEC} #{TIMEZONE})/
34
+ TIMESTAMP = "(?<date>#{DAY}\\/#{MONTH}\\/#{YEAR}):(?<time>#{TIMEC}:#{TIMEC}:#{TIMEC} #{TIMEZONE})"
35
35
 
36
- HTTP_METHODS = /GET|HEAD|POST|PUT|DELETE|CONNECT|OPTIONS|TRACE|PATCH/
37
- WEBDAV_METHODS = /COPY|LOCK|MKCOL|MOVE|PROPFIND|PROPPATCH|UNLOCK/
38
- OTHER_METHODS = /SEARCH|REPORT|PRI|HEAD\/robots.txt/
39
- METHOD = /(?<method>#{HTTP_METHODS}|#{WEBDAV_METHODS}|#{OTHER_METHODS})/
40
- PROTOCOL = /(?<protocol>HTTP\/[0-9]\.[0-9]|-|.*)/
41
- URL = /(?<url>[^ ]+)/
42
- REFERER = /(?<referer>[^"]*)/
43
- RETURN_CODE = /(?<status>[1-5][0-9][0-9])/
44
- SIZE = /(?<size>[0-9]+|-)/
45
- USER_AGENT = /(?<user_agent>[^"]*)/
36
+ HTTP_METHODS = "GET|HEAD|POST|PUT|DELETE|CONNECT|OPTIONS|TRACE|PATCH"
37
+ WEBDAV_METHODS = "COPY|LOCK|MKCOL|MOVE|PROPFIND|PROPPATCH|UNLOCK"
38
+ OTHER_METHODS = "SEARCH|REPORT|PRI|HEAD/robots.txt"
39
+ METHOD = "(?<method>#{HTTP_METHODS}|#{WEBDAV_METHODS}|#{OTHER_METHODS})"
40
+ PROTOCOL = "(?<protocol>HTTP\/[0-9]\.[0-9]|-|.*)"
41
+ URL = "(?<url>[^ ]+)"
42
+ REFERER = '(?<referer>[^"]*)'
43
+ RETURN_CODE = "(?<status>[1-5][0-9][0-9])"
44
+ SIZE = "(?<size>[0-9]+|-)"
45
+ USER_AGENT = '(?<user_agent>[^"]*)'
46
46
 
47
47
  attr_reader :format
48
48
 
49
49
  def initialize
50
- @format = /#{IP} #{IDENT} #{USERID} \[#{TIMESTAMP}\] "(#{METHOD} #{URL} #{PROTOCOL}|-|.+)" #{RETURN_CODE} #{SIZE} "#{REFERER}" "#{USER_AGENT}"/
50
+ @format = /#{IP} #{IDENT} #{USERID} \[#{TIMESTAMP}\] "(#{METHOD} #{URL} #{PROTOCOL}|-|.+)" #{RETURN_CODE} #{SIZE} "#{REFERER}" "#{USER_AGENT}"/o
51
51
  end
52
52
 
53
53
  def parse(line)
@@ -54,6 +54,7 @@ module LogSense
54
54
 
55
55
  @most_requested_pages = @db.execute resource_query(html, gs)
56
56
  @most_requested_resources = @db.execute resource_query(non_html, gs)
57
+
57
58
  @missed_pages = @db.execute resource_query(html, bs)
58
59
  @missed_resources = @db.execute resource_query(non_html, bs)
59
60
 
@@ -94,7 +94,7 @@ module LogSense
94
94
  method TEXT,
95
95
  request_format TEXT,
96
96
  anon_ip TEXT,
97
- timestamp TEXT
97
+ started_at TEXT
98
98
  )
99
99
  EOS
100
100
 
@@ -107,7 +107,7 @@ module LogSense
107
107
  method,
108
108
  request_format,
109
109
  anon_ip,
110
- timestamp
110
+ started_at
111
111
  )
112
112
  values (?, ?, ?, ?, ?, ?, ?, ?)
113
113
  EOS
@@ -550,7 +550,7 @@ module LogSense
550
550
  method: matchdata[:method],
551
551
  request_format: matchdata[:request_format],
552
552
  anon_ip: matchdata[:anon_ip],
553
- timestamp: matchdata[:timestamp],
553
+ started_at: matchdata[:timestamp],
554
554
  }
555
555
  end
556
556
  end
@@ -1,4 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module LogSense
4
+ # Aggregate data from Logs
2
5
  class RailsAggregator < Aggregator
3
6
  WORDS_SEPARATOR = ' · '
4
7
 
@@ -42,6 +45,18 @@ module LogSense
42
45
  where #{filter}
43
46
  group by controller order by controller).gsub("\n", "")
44
47
 
48
+ @performance_over_time = @db.execute %(
49
+ SELECT strftime("%Y-%m-%d", ended_at),
50
+ count(controller),
51
+ printf("%.2f", min(duration_total_ms)),
52
+ printf("%.2f", avg(duration_total_ms)),
53
+ printf("%.2f", max(duration_total_ms))
54
+ from Event
55
+ where #{filter}
56
+ group by strftime("%Y-%m-%d", ended_at)
57
+ order by strftime("%Y-%m-%d", ended_at)
58
+ ).gsub("\n", "")
59
+
45
60
  #
46
61
  # Use the performance information to build a tree map.
47
62
  # We then compute by device and show the treemap and the table by device
@@ -1,4 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module LogSense
4
+ # Specification of the Rails Reports
2
5
  class RailsReportShaper < ReportShaper
3
6
  def shape(data)
4
7
  [
@@ -42,6 +45,7 @@ module LogSense
42
45
  time_distribution(data),
43
46
  total_statuses(data),
44
47
  daily_statuses(data),
48
+ performance_over_time(data, col: "small-12 cell"),
45
49
  {
46
50
  title: "Rails Performance",
47
51
  header: %w[Controller Hits Min Avg Max],
@@ -86,6 +86,56 @@ module LogSense
86
86
  }
87
87
  end
88
88
 
89
+ def performance_over_time(data, colors: ["#d30001", "#888888"], col: "small-12 cell")
90
+ {
91
+ title: "Performance over Time",
92
+ header: %w[Date Count Min Avg Max],
93
+ column_alignment: %i[center right right right right],
94
+ rows: data[:performance_over_time],
95
+ col: col,
96
+ echarts_spec: "{
97
+ xAxis: {
98
+ type: 'category',
99
+ data: SERIES_DATA.map(row => row['Date'])
100
+ },
101
+ yAxis: [
102
+ {
103
+ type: 'value',
104
+ name: 'Average'
105
+ },
106
+ {
107
+ type: 'value',
108
+ name: 'Max'
109
+ }
110
+ ],
111
+ tooltip: {
112
+ trigger: 'axis'
113
+ },
114
+ series: [
115
+ {
116
+ data: SERIES_DATA.map(row => row['Avg']),
117
+ type: 'line',
118
+ color: '#{colors[0]}',
119
+ label: {
120
+ show: true,
121
+ position: 'top'
122
+ },
123
+ },
124
+ {
125
+ data: SERIES_DATA.map(row => row['Max']),
126
+ type: 'line',
127
+ color: '#{colors[1]}',
128
+ yAxisIndex: 1,
129
+ label: {
130
+ show: true,
131
+ position: 'top'
132
+ },
133
+ },
134
+ ]
135
+ }",
136
+ }
137
+ end
138
+
89
139
  #
90
140
  # Reports shared between rails and apache/nginx
91
141
  #
@@ -1,3 +1,3 @@
1
1
  module LogSense
2
- VERSION = "2.2.1"
2
+ VERSION = "2.3.0"
3
3
  end
data/log_sense.gemspec CHANGED
@@ -12,7 +12,7 @@ Gem::Specification.new do |spec|
12
12
  spec.license = "MIT"
13
13
  spec.required_ruby_version = Gem::Requirement.new(">= 2.6.9")
14
14
 
15
- spec.metadata["allowed_push_host"] = "https://rubygems.org/"
15
+ # spec.metadata["allowed_push_host"] = "https://rubygems.org/"
16
16
 
17
17
  spec.metadata["homepage_uri"] = spec.homepage
18
18
  spec.metadata["source_code_uri"] = "https://github.com/shair-tech/log_sense/"
@@ -34,5 +34,7 @@ Gem::Specification.new do |spec|
34
34
  spec.add_dependency "terminal-table", "~> 3.0.0"
35
35
 
36
36
  spec.add_development_dependency "debug", "~> 1.9.0"
37
+ spec.add_development_dependency "rubocop"
38
+ spec.add_development_dependency "bundle-audit"
37
39
  spec.add_development_dependency "minitest", "~> 5.24.0"
38
40
  end
data/todo.org CHANGED
@@ -1,7 +1,10 @@
1
1
  #+TITLE: Todo
2
2
 
3
3
  * Todo (2024-08-01)
4
-
4
+ ** T Show page with method
5
+ - we could generate a page with the result of the calls to a given method
6
+ (how many calls, distribution, ...). This would be the "show" of a rails app.
7
+
5
8
  ** T Break rails log_parser in subclasses (one per log type)
6
9
 
7
10
  ** T Distinguish between exceptions, errors with no timestamps and errors with timestamps :feature:
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: log_sense
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.1
4
+ version: 2.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adolfo Villafiorita
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-08-23 00:00:00.000000000 Z
11
+ date: 2025-02-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: browser
@@ -94,6 +94,34 @@ dependencies:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
96
  version: 1.9.0
97
+ - !ruby/object:Gem::Dependency
98
+ name: rubocop
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: bundle-audit
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
97
125
  - !ruby/object:Gem::Dependency
98
126
  name: minitest
99
127
  requirement: !ruby/object:Gem::Requirement
@@ -172,7 +200,6 @@ homepage: https://github.com/shair-tech/log_sense/
172
200
  licenses:
173
201
  - MIT
174
202
  metadata:
175
- allowed_push_host: https://rubygems.org/
176
203
  homepage_uri: https://github.com/shair-tech/log_sense/
177
204
  source_code_uri: https://github.com/shair-tech/log_sense/
178
205
  changelog_uri: https://github.com/shair-tech/log_sense/blob/main/CHANGELOG.org
@@ -191,7 +218,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
191
218
  - !ruby/object:Gem::Version
192
219
  version: '0'
193
220
  requirements: []
194
- rubygems_version: 3.5.17
221
+ rubygems_version: 3.5.22
195
222
  signing_key:
196
223
  specification_version: 4
197
224
  summary: Generate analytics for Rails and Apache/Nginx log file.