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

Get string data from query results #189

Open
NikSudo opened this issue Mar 1, 2024 · 3 comments
Open

Get string data from query results #189

NikSudo opened this issue Mar 1, 2024 · 3 comments

Comments

@NikSudo
Copy link

NikSudo commented Mar 1, 2024

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.

@albertodonato
Copy link
Owner

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.

@NikSudo
Copy link
Author

NikSudo commented Mar 4, 2024

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?

@albertodonato
Copy link
Owner

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.

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

No branches or pull requests

2 participants