I am trying to find all dashboards that haven’t been viewed in over X amount of time. I don’t have the Enterprise version, so usage insights is out of the question for me.
Is that information accessible in the community edition of Grafana? If so, where please?
You can parse the Grafana server log to see what was accessed when. Depending on your requirements, you could of course write a script to do this in a semi-automated way.
A quick and dirty solution - assuming you have the log saved in a file - could be to just look for the last line in the log that mentions a given dashboard URL you’re interested in (by e.g. doing unix - Getting the last match in a file using grep - Server Fault)
Going to give that a go, thanks! Really appreciate you taking the time to reply.
Do you know where the Grafana server logs are located in Grafana web, or do they need to be accessed via the command line?
Yeah I was going to ask…how are you running Grafana? Is it Grafana Cloud or is it running on your own server? If it’s Grafana Cloud you’re using, then I don’t think you have access to the logs.
Thanks!! I think we nearly have it! We have Grafana running on our own server and I can access the logs via kubectl logs grafana-server-xxx
It only returns the last day worth of logs, and doesn’t seem to include “last viewed” data, or last interacted with from what I can see though. Is the appearance of the dashboard URL the identifier that it was accessed at that point?
Hm just looked into this briefly. I may have misled you - it actually doesn’t seem that dashboard requests are logged by Grafana by default (only if there’s an error). You’d need to enable router_logging for requests to be logged.
To add to that, are you running Grafana behind a reverse proxy by any chance? If so, you could also check the proxy logs for the requests that came through.
router_logging is enabled, so requests are being logged! Is there certain phrasing for what the requests are called? I can see https://graphs.xxxx.net/ within the output of the logs, but not able to identify what the actual text for last viewed/request is called.
Ok that’s good. To be clear, you won’t see log entries along the lines of "dashboard XXX was last viewed at ". But you will see all the times that a given dashboard was viewed, by for example grepping for all log entries that include its URL (e.g. https://graphs.xxxx.net/d/LzINMf9Gk/dashboard-name) and checking the timestamp of the last entry - i.e. the last time it was accessed.
I hope I’m making sense.
All that said, for this to work well you’ll probably want to retain logs for more than a day. Unless you’re only interested in the last access times that are within the last day.