-
Notifications
You must be signed in to change notification settings - Fork 170
How to query promscale data without using count(*) #614
Comments
Sorry, do you mean using something like |
Well thinking about this further, I was originally thinking that promscale was reporting the current count to timescaledb every minute, but I might have been doing something else wrong. Let me check blow my data away and look into this again. |
Ok getting back to this it seems there is a record every ~15 seconds or so in my timescaledb even if I don't do anything to add to the metrics so a For more context here, I have 2 docker containers responding to requests in my backend app that log metrics. You can see that I temporarily opened up my
|
Promscale just converts the incoming Prometheus data into SQL queries as it receives the data and sends to Timescaledb. Sorry but I don't understand what Promscale will report. |
Do you have any idea what the converted query could be? Or how to replicate that simple promQL query into a correct timescaledb query? At this point the timescale docs https://docs.timescale.com/latest/tutorials/tutorial-grafana-dashboards are not helpful as they don't reflect reality since they always assume |
Sorry for the delay in response. @toymachiner62 you can mention your promql query here and I can write the SQL form of it. We can DM over slack if you want more SQL queries. That will be faster than communicating over GitHub issues. |
Also, @toymachiner62 the docs link you mentioned are not reference for PromQL data. For PromQL, you need to look into docs of Promscale. This might be helpful. https://github.com/timescale/promscale/blob/master/docs/sql_schema.md |
If I follow this is example in your docs https://docs.timescale.com/timescaledb/latest/tutorials/grafana/create-dashboard-and-panel/#visualize-metrics-stored-in-timescaledb with my data which should be this query: select
date_trunc('day', time) AS day,
count(*)
from catalytic_logins_count
group by day
order by day; I get this result, which is obviously not right as I've only logged in once. |
Yes. Prometheus is sending those samples to Promscale and Promscale should ingest them as they are not duplicates. duplicate is one where the series_id and time, both are same. This is not the case here as each sample is different. If your exporter can expose timestamps, then this can be solved by asking prometheus to
Why is that not right? you have 16 different datapoints and hence, 16 is the result. |
In total i've only had one user login so |
@toymachiner62 that is because of different timestamps. Make sure your exporter exposes tinestamp (which it is not doing at this moment) in these cases as your usecase is time dependent. If your exporter does not expose timestamp, Prometheus attaches a tinestamp and treats it as a new sample and hence a new row is right in Prometheus language. You can see the same thing in Prometheus tsdb as well, since both worlds expect timestamp to be attached in this scenario. |
Looks like the default [scrape_config] (https://prometheus.io/docs/prometheus/latest/configuration/configuration/#scrape_config) is I'm just using prom-client to collect my metrics and the docs don't say anything about timestamps in there. |
@toymachiner62 please refer to this PR to know how to add timestamp to Prometheus metric in Prometheus go client lib. |
Hmm well this must be a broader issue than just an issue for me if the prom-client doesn't have an option for adding timestamps. I'm not the owner of prom-client and it's a pretty widely used prometheus client written in node and not go. |
Ah, I didnt pay attention that you are using node. In node, I can see this in the documentation.
|
@toymachiner62 does that answer help? |
No actually it confuses me more. You had mentioned:
but then you also said mentioned to disable timestamps with
|
@toymachiner62, I meant to show you the exact copy. just change that to |
Where did you find that example? There are no docs or examples that I saw that the |
You can find that here: https://www.npmjs.com/package/prom-client/v/11.5.0 Search |
That's an old version. the |
Ah, then that's a tough choice. Try doing something like having a label that is updated in the client when you actually increment value. Then you can use Still, there will be some way to expose timestamps otherwise, that library is not fully Prometheus compatible. |
@toymachiner62 sorry for the very late answer. I think what you were looking for was something like this: select
time_bucket('1 day', time) AS day,
delta(counter_agg(time, value))
from catalytic_logins_count
group by day
order by day; This would return changes in the value on a daily basis and properly handling counter resets. Closing this now but feel free to reopen. |
The timescaledb docs https://docs.timescale.com/latest/tutorials/tutorial-grafana-dashboards on using promscale + grafana all have examples of using
count(*)
which implies that every entry in the prom_metric tables in timescaledb corresponds to a single value being incremented.In the real world this doesn't seem to work because the
value
column of aprom_metric
view can have a value greater than 1 as in this example.I could really use some help on how to write a query to populate a grafana graph where an entry in timescaledb via promscale contains a value that is greater than 1.
The text was updated successfully, but these errors were encountered: