If time picker in Grafana is set to `last 3h` (or something like that), every dasbhoard refresh will change $from and $to values, which makes query non-cachable since it is constantly changing. When macros expands (before sending to postgres) it transforms into something like `dateColumn BETWEEN FROM_UNIXTIME(1494410450) AND FROM_UNIXTIME(1494410983)`, where $from=1494410450 and $to=1494410983. If I'm not mistaken, postgres datasource in Grafana is usually used with `$_timeFilter(dateColumn)` macros, which gets the current $from and $to values from Grafana's time picker. > How do you mean to apply rounding for the time filter? My vision would be to use the PostgreSQL exporter for Prometheus and add our custom queries to it. Sort of what I would put into a Prometheus recording rule. I guess the SQL queries used today return "aggregated" data rather than raw data. But with Prometheus we could just push to Pushgateway what's happened since the last push, sort of. Today for example, every query roughly returns statistics for the last month. Is it a bad idea to attempt "pre-calculation" of heavy queries and store the results in the PostgreSQL database, with the explicit intent of querying the data from Grafana?īeing a very big fan of Prometheus it is my instict to go to it.īut it's difficult to see the full solution up front and understand the good and bad things. Almost nobody here knows PromQL (but given good enough reasons, could of course learn). Many developers, if not all, know SQL and could build a dashboard in Grafana using the PostgreSQL datasoure plugin. I am thinking that using a CronJob, Pushgateway and Prometheus we could execute the heavy queries once, store the results in Prometheus and have blazing fast dashboards in Grafana as a result.īut one could argue we should send the results to the database instead. We have a database cluster specifically for this, so it's not impacting anything else. There is not a huge amount of users but the traffic we do have combined with suboptimal queries creates a not so good user experience. One big downside of this setup is that for every person that opens or refreshes a dashboard many SQL queries are executed against the database. I just started working at a new place where they connect Grafana directly to PostgreSQL for rendering dashboards.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |