piglei / uwsgi-sloth Goto Github PK
View Code? Open in Web Editor NEWRealtime uwsgi log file analyzer, slow requests analyzer.
License: Apache License 2.0
Realtime uwsgi log file analyzer, slow requests analyzer.
License: Apache License 2.0
Hi, I just tried setting up version 2.1.2 from pypi on CentOS 7, with python 2.7.5, uWSGI 2.0.13.1 and everything appeared to work and it generated the latest_5_mins.html page, but it shows 0 requests.
My uwsgi log file is stock, here is a sample from it:
[pid: 18227|app: 0|req: 203555/404742] 10.10.0.1 () {50 vars in 908 bytes} [Sat Aug 20 20:32:37 2016] GET /api/tournaments/53822/ => generated 1851 bytes in 121 msecs (HTTP/1.1 200) 4 headers in 149 bytes (1 switches on core 0)
[pid: 18563|app: 0|req: 201188/404743] 10.10.0.1 () {48 vars in 1013 bytes} [Sat Aug 20 20:32:37 2016] GET /api/tournaments/54496/ => generated 1835 bytes in 116 msecs (HTTP/1.1 200) 4 headers in 149 bytes (1 switches on core 0)
/var/www/uwsgi_sloth/tk.conf
uwsgi_log_path = '/var/www/logs/uwsgi.log'
data_dir = '/var/www/uwsgi_sloth/tk/'
domain = 'https://example.com/' ; Not real domain name, I do have this set correctly in my config
Running it with:
uwsgi-sloth start -c /var/www/uwsgi_sloth/tk.conf
I also noticed that the demo site shows 0 requests and looks the same as mine:
http://uwsgi-sloth.zlovezl.cn/latest_5mins.html
Traceback (most recent call last):
File "/usr/bin/uwsgi-sloth", line 7, in
execfile(file)
File "/home/ec2-user/src/uwsgi-sloth/uwsgi_sloth/uwsgi-sloth", line 10, in
from commands.analyze import load_subcommand
ImportError: No module named analyze
rolling back to version 0637fcb resolves the issue
There is already #10, I couldn't re-open, so I filed a new ticket instead.
When running on python 3.5 I get errors
(v) harm@sensor1:~/uwsgi-sloth$ uwsgi-sloth start -c josene.conf
[2019-02-28 10:53:29,072] uwsgi_sloth INFO: Start from last savepoint, last_log_datetime: 2019-02-28 10:48:29.071966
[2019-02-28 10:53:35,884] uwsgi_sloth INFO: Rendering HTML file /home/harm/uwsgi-sloth/html/html/latest_5mins.html...
[2019-02-28 10:53:35,916] uwsgi_sloth INFO: Rendering HTML file /home/harm/uwsgi-sloth/html/html/day_2019-02-28.html...
Traceback (most recent call last):
File "/home/harm/uwsgi-sloth/v/bin/uwsgi-sloth", line 32, in <module>
main()
File "/home/harm/uwsgi-sloth/v/bin/uwsgi-sloth", line 25, in main
args.func(args)
File "/home/harm/uwsgi-sloth/v/lib/python3.5/site-packages/uwsgi_sloth/commands/start.py", line 118, in start
day_requests_data.save()
File "/home/harm/uwsgi-sloth/v/lib/python3.5/site-packages/uwsgi_sloth/models.py", line 48, in save
pickle.dump(self.data, fp)
TypeError: write() argument must be str, not bytes
When changing models.py::RequestsData to open() as 'rb' and 'wb' this crash disappears, but then I get
[2019-02-28 10:56:56,919] uwsgi_sloth INFO: Start from last savepoint, last_log_datetime: 2019-02-28 10:51:56.919301
[2019-02-28 10:57:03,777] uwsgi_sloth INFO: Rendering HTML file /home/harm/uwsgi-sloth/html/html/latest_5mins.html...
[2019-02-28 10:57:03,812] uwsgi_sloth INFO: Rendering HTML file /home/harm/uwsgi-sloth/html/html/day_2019-02-28.html...
Traceback (most recent call last):
File "/home/harm/uwsgi-sloth/v/bin/uwsgi-sloth", line 32, in <module>
main()
File "/home/harm/uwsgi-sloth/v/bin/uwsgi-sloth", line 25, in main
args.func(args)
File "/home/harm/uwsgi-sloth/v/lib/python3.5/site-packages/uwsgi_sloth/commands/start.py", line 111, in start
for date in analyzer.data.keys():
RuntimeError: dictionary changed size during iteration
last crash might not be a python3.5 issue, but first crash is I think.
uwsgi-sloth==3.0.1
Python3.5 + compatible. In the file 'uwsgi_sloth/models.py', line 43, fp needs to be encoded or a type error will be reported.For example: fp = fp. encode ()
My application serves 90% of the traffic on a specific URL. Hence, my log file is filled with below logline.
[pid: 25827|app: 0|req: 18/18] 162.158.158.173 () {62 vars in 1255 bytes} [Thu Jul 11 22:08:38 2019] POST /apis/shops/get_aff_url/ => generated 274 bytes in 23 msecs (HTTP/1.1 404) 5 headers in 152 bytes (1 switches on core 0)
However, in the reports, I don't see this URL under the detail section.
Below is the screenshot of Today
period.
Issues
I don't see /apis/shops/get_aff_url/
in the reports at all, even when it was hit 90% of the time.
Total requests are 491, which is incorrect. I'd over 2000 hits on the above URL, and around 100 requests on the other URLs.
Kindly help in explaining the reports.
My uwsgi logging is in utc, the users typically have timezone 'Europe/Amsterdam'.
running uwsgi-sloth start gives:
(v) harm@server:~/uwsgi-sloth$ uwsgi-sloth start -c myconf.conf
[2019-02-28 11:38:14,005] uwsgi_sloth INFO: Start from last savepoint, last_log_datetime: 2019-02-28 11:33:14.005028
[2019-02-28 11:38:20,828] uwsgi_sloth INFO: Rendering HTML file /home/harm/uwsgi-sloth/html/html/latest_5mins.html...
As the uwsgi logging timestamps are in UTC (eg: "Thu Feb 28 10:40:00 2019") uwsgi-sloth does do the lookup for the last 5 minutes correctly.
latest_5mins.html is always empty ( Slow / Total requests == 0 / 0 )
latest_5mins.html shows the last 5 minutes.
html output should use the timezone of the user.
The parsing of the uwsgi logging should be able to deal with the timezone difference between report and uwsgi logging.
$ sudo uwsgi-sloth analyze -f /var/log/uwsgi-project.log.1 --output=report.html --min-msecs=1500
[2014-09-03 14:07:25,054] uwsgi_sloth.analyze INFO: Analyzing log file "/var/log/uwsgi-project.log.1"...
Traceback (most recent call last):
File "/usr/home/user/.virtualenvs/default/bin/uwsgi-sloth", line 8, in <module>
execfile(__file__)
File "/usr/home/user/.virtualenvs/default/src/uwsgi-sloth/uwsgi_sloth/uwsgi-sloth", line 26, in <module>
main()
File "/usr/home/user/.virtualenvs/default/src/uwsgi-sloth/uwsgi_sloth/uwsgi-sloth", line 22, in main
args.func(args)
File "/usr/home/user/.virtualenvs/default/src/uwsgi-sloth/uwsgi_sloth/commands/analyze.py", line 32, in analyze
data = analyze_log(args.filepath, args, url_rules)
File "/usr/home/user/.virtualenvs/default/src/uwsgi-sloth/uwsgi_sloth/commands/analyze.py", line 20, in analyze_log
analyzer.analyze_line(line)
File "/usr/home/user/.virtualenvs/default/src/uwsgi-sloth/uwsgi_sloth/analyzer.py", line 97, in analyze_line
result = self.log_parser.parse(line)
File "/usr/home/user/.virtualenvs/default/src/uwsgi-sloth/uwsgi_sloth/analyzer.py", line 46, in parse
self.DATETIME_FORMAT)
TypeError: must be string without null bytes, not str
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.