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

change the cache time does't work #93

Open
felixglow opened this issue Apr 13, 2021 · 15 comments
Open

change the cache time does't work #93

felixglow opened this issue Apr 13, 2021 · 15 comments
Labels
type/bug Unexpected behavior or a feature is broken

Comments

@felixglow
Copy link

image
I change the cache time from 5m to 0s, it does't work. use v1.0.1
can you fix it? thx

@henley-regatta
Copy link

At the risk of ME-TOO'ing this I'm seeing the same issue. Not only that but according to my webserver logs, Grafana isn't even querying the source after 5 minutes. Even restarting the Grafana server doesn't guarantee a refresh. (plugin v1.0.1 Grafana versions 7.5.2 and 7.5.3)

@felixglow
Copy link
Author

@henley-regatta I have a temporary solution,

  1. clone code
  2. modify ’cacheDurationSeconds‘ and 'defaultCacheDuration', 300 -> 0
    image
  3. npm install && npm run build
  4. use dist install, you can see document (https://marcus.se.net/grafana-json-datasource/installation)
  5. it's work
    image

but still hope Author fix the bug, this plugin is very useful.

@marcusolsson
Copy link
Contributor

Hi @felixglow and @henley-regatta,

I'd like to fix this as soon as possible, but I'm having some trouble replicating this. Just to clarify, you change the cache from 5m 0s, but no request is made? Is this only when creating variable queries, or does it apply in the dashboard query as well?

Honestly I'm debating whether it's time to remove the cache altogether. It's the cause of most issues reported, and I'm not even sure how many are actually using it.

@marcusolsson marcusolsson added triage/needs-investigation type/bug Unexpected behavior or a feature is broken labels Apr 14, 2021
@henley-regatta
Copy link

henley-regatta commented Apr 14, 2021

Thanks for looking at this, @marcusolsson

I can confirm having just tested it that using the JSON-API plugin in a (Chart) Query also doesn't respect the cache setting.
The nginx access logs show Grafana going back to the source file once, and then never again within the testing window, despite me both changing the cache to 0 and force-reloading the page.

EDIT TO ADD: Even using Query Inspector and the "Refresh" option doesn't cause Grafana to go out to the source data with Cache set to 0s

@felixglow
Copy link
Author

@marcusolsson thanks,in my opinion,this cache function is not important for me。

@henley-regatta
Copy link

@henley-regatta I have a temporary solution,

  1. clone code
  2. modify ’cacheDurationSeconds‘ and 'defaultCacheDuration', 300 -> 0
  3. npm install && npm run build

note for anyone else trying this: I had to use npm install --legacy-peer-deps to avoid errors on incompatible/unresolvable dependencies.

  1. use dist install, you can see document (https://marcus.se.net/grafana-json-datasource/installation)
  2. it's work

Ah now here's a thing - it's not working for me. I'm not seeing requests to the server's access log based on this change. I've set cache to zero (knowing it's now dummied-out), I've restarted the Grafana server, I've used Query-Inspector -> Refresh, I've force-reloaded the page... I'm still not seeing requests to the (web) source. I'm still seeing the data but the Query Inspector shows the source as url:"api/datasources/proxy/3 (although I'll note that any "Query Strings" I add to the source URL - the old trick to force a webserver to not present a cached response - are added to that re-written URL too, without getting a call back to the source).

I don't know how this works internally and what that datasources proxy represents but.... is it possible that this is internal to Grafana and not the plugin?

@felixglow
Copy link
Author

felixglow commented Apr 15, 2021

@henley-regatta I forgot to tell you,the old page does't work, you must add a new variable, then the cache time will set 0s default.
image

@marcusolsson
Copy link
Contributor

While digging in this I found an issue that could be the reason for this (and several other reported issues). I've fixed it, but I'm working on a few other features that I'd like for to make it to the next release. I'll let you know when I've published it.

@felixglow
Copy link
Author

While digging in this I found an issue that could be the reason for this (and several other reported issues). I've fixed it, but I'm working on a few other features that I'd like for to make it to the next release. I'll let you know when I've published it.

OK,thank you very much~

@henley-regatta
Copy link

@henley-regatta I forgot to tell you,the old page does't work, you must add a new variable, then the cache time will set 0s default.
image

Thanks, @felixglow . That's worth knowing. However, I've tried deleting and re-creating the Variable, the panel that's using the query, the whole dashboard and even the Datasource itself and I'm not seeing re-requests to the source data. Given the progress being made on resolving the core issues I'm not sure it's worth pursuing this line of inquiry..

@marcusolsson thank you very much for your work on this. I look forward to the next release of the plugin with great interest!

@marcusolsson
Copy link
Contributor

I've just published v1.1.0 to the marketplace. While I haven't worked on this specifically. I've fixed a couple of related issues. Would you mind letting me know if this issue is still there in 1.1.0?

@henley-regatta
Copy link

I've just tested v1.1.0 on 2 servers (Grafana 7.4.1 and 7.5.4) and I'm still not seeing any change to refresh behaviour.:Once Grafana's done a query that's gotten results, I'm not seeing any further queries from Grafana to the data source (my nginx-hosted JSON), it's all coming from the proxy url I previously listed. And that's after deleting & recreating the dashboard, variables and datasource

(and also, because I'm paranoid, forcing debug log on the nginx process to make sure it's reporting all hits even cached ones).

@marcusolsson
Copy link
Contributor

Thank you for confirming. I'll give another go at reproducing this.

@RedStylzZ
Copy link

RedStylzZ commented Jul 4, 2022

Is there any fix? I right now have the same problem when I changed key x to y in a JSON file. It still only shows key x and doesn't update. When I create a new Datasource it works and shows key y.

I am on version 1.3.0

@bijwaard
Copy link

bijwaard commented Sep 8, 2023

Hi,
At 5s cache time, the refresh seems to work for me (grafana-v9.3.2, marcusolsson-json-datasource @ 1.3.6) in the dashboard with a golang webserver hosting JSON-encoded measurements (last 3s). The auto-refresh does not work in Edit mode, only by pressing refresh manually.

The cache-time list seems to be fixed, I cannot give other values than in the list (e.g. 1s or 15s), else the value becomes NaNh and the plugin indicates Error: "Cache timeout needs to be positive number". Would it be possible to use custom cache times and add them to the list like the refresh timeout does?

Kind regards,
Dennis

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/bug Unexpected behavior or a feature is broken
Projects
Status: Backlog
Development

No branches or pull requests

6 participants