Reduce size of grafana.db

Hi, my grafana.db file has grown to 17GB and im pretty sure its to do with versioning of provisioned dashboards.

if i dont need all the older data is there any safe way to remove anything older than a month?

im aware there may be a bug that is causing the increase but for now id just like to reduce the size of the DB before it fills the drive.

  • What Grafana version and what operating system are you using? 6.3.5

  • What are you trying to achieve? reduce size of grafana db file

  • How are you trying to achieve it? by sqlite3

  • What happened? nothing yet

  • What did you expect to happen? reduce size of db

That does sound large!

There’s a setting that sets the number of dashboards to keep in version control: Configuration | Grafana Labs. You can try reducing that. Not sure if it will proactively delete older versions though.

Where Annotations is saved? It could be another point of reduce space

its only set to 20 and there are 24 dashboards so i wouldn’t have expected it to got to 17GB

a few test ones we dont use them.

sorry correction the default is 20 and it was commented out.

have changed it to 2 but after restarting the service not noticed any change in DB size.

Yeah…sounds like a bug of some sort. Can you “inspect” the database file and see which tables are taking so much space?

dashboard_versions row count was nearly 700k

but i gave up trying to get the size of all the tables when i realised sqlite is horrible to work with after years of oracle and sql server

Well I certainly don’t disagree with SQLite being less than ideal for larger-scale data storage…though I feel like you’ve probably been hit by a bug that may not be specific to SQLite.

I took a quick look at the Github issues page, and it looks like there are a couple of potential culprits - especially in older versions of Grafana. If it’s an option for you, the first thing I’d recommend is upgrading your Grafana version and seeing if that restores normal clean-up functionality. If you’re not in a position to upgrade, then you could do a manual clean of that table (filter on created timestamp and just delete all older rows from the table?)

hi yes i have seen those bugs that why i think it is to do with the versioned table.

my gripe with sqlite wasn’t that this was its fault just the difference in syntax when you used to pl/t-sql

i think i will move the DB file to a bigger partition until im in a position to upgrade as this is the safest option.

Thanks for you help.

1 Like