grafana-tools / sdk

Library for using Grafana' structures in Go programs and client for Grafana REST API.
Apache License 2.0
318 stars 187 forks source link

1000+ dashboards #213

Closed davidnewhall closed 1 year ago

davidnewhall commented 2 years ago

Hello,

I wrote some code based on this: https://github.com/grafana-tools/sdk/blob/master/cmd/backup-dashboards/main.go

However, c.SearchDashboards(ctx, "", false) only pulls 1000 dashboards, and we have over 1200. Curious if I'm missing something, and if there's a way to get them all. I did notice this method is deprecated, and wonder if c.Search() will give me better results.

Thanks!

safaci2000 commented 1 year ago

The default pull is 1000 I believe. I fixed this in my importer tool using this pattern.

https://github.com/esnet/gdg/blob/master/api/dashboards.go#L52

Basically you check if the page size is larger than the payload and keep on checking till you retrieved all the dashboards.

If you have 1200 an easier work around is simply to set the upper bound to 5000 which last I checked was the upper bound of what the Grafana API supported.

Basically

davidnewhall commented 1 year ago

Went another direction. Thanks! https://github.com/grafana/grafana-api-golang-client/pull/124