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

goatcounter monitor fails with "syntax error" with sqlite #343

Closed
anarcat opened this issue Jul 15, 2020 · 1 comment
Closed

goatcounter monitor fails with "syntax error" with sqlite #343

anarcat opened this issue Jul 15, 2020 · 1 comment
Labels

Comments

@anarcat
Copy link

anarcat commented Jul 15, 2020

I get this when running goatcounter monitor:

   16:37:18 monitor: ERROR: near "'120 seconds'": syntax error
   16:37:18 monitor: ERROR: no hits

I figured maybe something was up with defaults, so I also tried overriding the -period:

root@marcos:~# docker run -it --rm --volume="goatcounter:/home/user/db/" zgoat/goatcounter monitor -period 120
   16:37:18 monitor: ERROR: near "'120 seconds'": syntax error
   16:37:18 monitor: ERROR: no hits

(Note that I use Docker, above, but that should be equivalent to just running goatcounter monitor -period 120.)

The errors comes back once in a while, about every two minutes...

It seems like this is a problem with this database query:

	query += ` created_at > now() - interval '%d seconds'`

I suspect that has been designed for PostgreSQL and does not work with sqlite. Apparently, that only works in MySQL (and PostgreSQL i guess?)... the sqlite-way of doing this seems to be, according to SO:

SELECT mumble FROM blah WHERE blah.heart_beat_time > datetime('now', '-600 seconds');

... and obviously, that is a SQLite-specific extension that doesn't work in the other two...whee!

@arp242
Copy link
Owner

arp242 commented Jul 15, 2020

I just created this quickly after an outage several months ago to make sure I would be notified ASAP, kinda forgot about SQLite 😅 There's already a little helper to deal with this specific syntax difference. Should be a simple fix.

@arp242 arp242 added the bug label Jul 15, 2020
@arp242 arp242 closed this as completed in a303acb Jul 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants