diff --git a/CHANGELOG.md b/CHANGELOG.md index df6ca45..7f2bc2e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Ability to run multiple GrafanaAgent instances [#157](https://github.com/akoutmos/prom_ex/pull/157) - Support for GrafanaAgent 28 +### Fixed + +- Application crashing on startup from being unable to upload dashboards due to folder UID changing [#177](https://github.com/akoutmos/prom_ex/pull/177) + ## [1.7.1] - 2022-03-02 ### Fixed diff --git a/lib/prom_ex/dashboard_uploader.ex b/lib/prom_ex/dashboard_uploader.ex index add05e3..189b317 100644 --- a/lib/prom_ex/dashboard_uploader.ex +++ b/lib/prom_ex/dashboard_uploader.ex @@ -168,7 +168,8 @@ defmodule PromEx.DashboardUploader do {:ok, folder_details} -> folder_details - {:error, :bad_request} -> + {:error, reason} -> + Logger.error("PromEx.DashboardUploader failed to create folder in Grafana: #{inspect(reason)}.") {:ok, all_folders} = GrafanaClient.get_all_folders(grafana_conn) all_folders diff --git a/lib/prom_ex/grafana_client.ex b/lib/prom_ex/grafana_client.ex index 7f257aa..2a4b5e6 100644 --- a/lib/prom_ex/grafana_client.ex +++ b/lib/prom_ex/grafana_client.ex @@ -18,6 +18,7 @@ defmodule PromEx.GrafanaClient do 401 => :unauthorized, 403 => :forbidden, 404 => :not_found, + 409 => :already_exists, 412 => :already_exists } diff --git a/test/prom_ex/dashboard_uploader_test.exs b/test/prom_ex/dashboard_uploader_test.exs index 3a6ac67..375d579 100644 --- a/test/prom_ex/dashboard_uploader_test.exs +++ b/test/prom_ex/dashboard_uploader_test.exs @@ -366,7 +366,7 @@ defmodule PromEx.DashboardUploaderTest do } """ - Plug.Conn.resp(conn, 400, response_payload) + Plug.Conn.resp(conn, 409, response_payload) end) Bypass.expect_once(bypass, "GET", "/api/folders", fn conn ->