query-exporter
query-exporter copied to clipboard
Looping instead of erroring when MySQL query returned all strings
This one took me awhile to figure out.
This was definitely a user error, that made the tool get stuck in a loop blocking all other queries.
Using mysql, the query was accidentally formulated to return all strings.
It was supposed to get max timestamp value from table and also return two labels.
It ended up looking like (fake query below)
select max('columnname here') metric1, 'tablename' as 'label1', 'columnname' as 'label2' from tablename
The results were that it seemed like several metrics were not ever being queried. No Logs, no Errors. I finally tracked down the connection on the db, and saw that it was looping. Continuing to retry this query over and over.
The retries were also not getting calculated under query counts, nor query errors and so was infinitely looping and blocking everything else from happening.
The request is to catch when no value returned is a float.
I did see other errors that caught similar like:
TypeError: float() argument must be a string or a real number, not 'datetime.datetime'
when not wrapping a timestamp in unix_timestamp
Realized my query wasn't clear.
select max('varchar columnname here') metric1, 'tablename' as 'label1', 'columnname' as 'label2' from tablename
So it returns something like:
metric1 label1 label2
foo table column
The output did not like that none of those were integers.