Get string data from query results
NikSudo opened this issue · comments
Is it possible now to get string/float data in query by this exporter? For example I have table with columns: product_name; id; last_price; count
So the problem with id and product_name, I can't type some query which show me:
product_name | last_price | count |
foo | 0.0053 | 45031 |
bar | 234 | 500 |
Means some query which show results per 24 hours with product_name info about last_price (the value can be float) and sorting by descending order.
Or is it possible now? If no - it will be great to get this feature.
I also got an error when I tried to send a query and there is a datetime.datetime type.
You can use string values as labels for a metric, you just need to define the label and match the name with the one of the returned column.
As for detatime, you can't use them directly as prometheus only supports numeric values as metrics. Therefore, you have to either convert them to float (e,.g. as epochs) or as strings if you need them as label values.
Labels way seems like hard coding no?
I don't know what the "product" will be in the DB at the table, that's why it will be great to have possibility to get string data in queries by your exporter. The same way as it's working now for numbers in your project(metric = "column name"). Plus... Even if I'll make some kind of automatisations to update config files based on DB state to provide relative data in monitoring, I use Grafana to visualisation of Prometheus data. And creation dashboards via using labels - it will be painful and hardly IMO. Labels can be added to ENV for example (like DEV,QA,PROD), and string data from DB will be in the same lvl of abstractions as ENV label..
Transform datetime to string as well? Or transformation datetime from DB to unix time by query-exporter?
I'm not quite sure I understand your need. If what you want (from your initial query output) is to be able to filter in the graphs by product_name
, you could add a label for that to the last_price metric, so that it gets tagged that way.
WRT datetime, I meant trasform them via the query to e.g. unix timestamps.