Tool to help you manage your Grafana dashboards using Git.

dashboards.go 693B

12345678910111213141516171819202122232425262728293031323334
  1. package grafana
  2. import (
  3. "encoding/json"
  4. )
  5. type dbSearchResponse struct {
  6. ID int `json:"id"`
  7. Title string `json:"title"`
  8. URI string `json:"uri"`
  9. Type string `json:"type"`
  10. Tags []string `json:"tags"`
  11. Starred bool `json:"isStarred"`
  12. }
  13. func (c *Client) GetDashboardsURIs() (URIs []string, err error) {
  14. resp, err := c.request("GET", "search", nil)
  15. var respBody []dbSearchResponse
  16. if err = json.Unmarshal(resp, &respBody); err != nil {
  17. return
  18. }
  19. URIs = make([]string, 0)
  20. for _, db := range respBody {
  21. URIs = append(URIs, db.URI)
  22. }
  23. return
  24. }
  25. func (c *Client) GetDashboardJSON(URI string) ([]byte, error) {
  26. return c.request("GET", URI, nil)
  27. }