Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple group by columns #27

Closed
alanpearce opened this issue Apr 1, 2014 · 2 comments
Closed

Multiple group by columns #27

alanpearce opened this issue Apr 1, 2014 · 2 comments

Comments

@alanpearce
Copy link

I'd like to show requests by hostname and request path, so I tried:

ngxtop -g http_host,request_path

which gives me

running for 8 seconds, 0 records processed: 0.00 req/sec

Summary:
|   count |   avg_bytes_sent |   2xx |   3xx |   4xx |   5xx |
|---------+------------------+-------+-------+-------+-------|
|       0 |                  |     0 |     0 |     0 |     0 |

Detailed:

Traceback (most recent call last):
  File "/usr/bin/ngxtop", line 9, in <module>
    load_entry_point('ngxtop==0.0.1', 'console_scripts', 'ngxtop')()
  File "/usr/lib/python2.6/site-packages/ngxtop/ngxtop.py", line 446, in main
    process(args)
  File "/usr/lib/python2.6/site-packages/ngxtop/ngxtop.py", line 429, in process
    total = process_log(source, pattern, processor, arguments)
  File "/usr/lib/python2.6/site-packages/ngxtop/ngxtop.py", line 334, in process_log
    total = processor.process(records)
  File "/usr/lib/python2.6/site-packages/ngxtop/ngxtop.py", line 282, in process
    cursor.execute(insert, r)
sqlite3.OperationalError: no such column: request_path

So then I tried nginxtop -g http_host -g request_path, which just gives me back the usage information. Grouping by either http_host or request_path works fine, it's just the combination together that I can't seem to get working.

@lebinh
Copy link
Owner

lebinh commented Apr 9, 2014

Close as fixed by merged #29

@lebinh lebinh closed this as completed Apr 9, 2014
@Henner
Copy link

Henner commented Jun 2, 2019

this still does not work for me.
the app dies without a trace.
if running with -d
ngxtop -g http_host,request_path -d
the output is:
DEBUG: arguments:
{'--a': None,
'--access-log': None,
'--config': None,
'--debug': True,
'--filter': None,
'--group-by': 'http_host,request_path',
'--having': '1',
'--help': False,
'--interval': '2.0',
'--limit': '10',
'--log-format': 'combined',
'--no-follow': False,
'--order-by': 'count',
'--pre-filter': None,
'--verbose': False,
'--version': False,
'': [],
'': [],
'avg': False,
'info': False,
'print': False,
'query': False,
'sum': False,
'top': False}
INFO: access_log: /var/log/nginx/access.log
INFO: log_format: $remote_addr - $remote_user [$time_local] "$request" $status $body_bytes_sent "$http_referer" "$http_user_agent"
INFO: query for "Summary:":
SELECT
count(1) AS count,
avg(bytes_sent) AS avg_bytes_sent,
count(CASE WHEN status_type = 2 THEN 1 END) AS '2xx',
count(CASE WHEN status_type = 3 THEN 1 END) AS '3xx',
count(CASE WHEN status_type = 4 THEN 1 END) AS '4xx',
count(CASE WHEN status_type = 5 THEN 1 END) AS '5xx'
FROM log
ORDER BY count DESC
LIMIT 10
INFO: query for "Detailed:":
SELECT
http_host,request_path,
count(1) AS count,
avg(bytes_sent) AS avg_bytes_sent,
count(CASE WHEN status_type = 2 THEN 1 END) AS '2xx',
count(CASE WHEN status_type = 3 THEN 1 END) AS '3xx',
count(CASE WHEN status_type = 4 THEN 1 END) AS '4xx',
count(CASE WHEN status_type = 5 THEN 1 END) AS '5xx'
FROM log
GROUP BY http_host,request_path
HAVING 1
ORDER BY count DESC
LIMIT 10
INFO: sqlite init: create table log (http_host,request_path,bytes_sent,status_type)
INFO: sqlite insert: insert into log (http_host,request_path,bytes_sent,status_type) values (:http_host,:request_path,:bytes_sent,:status_type)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants