Closed BlaCkinkGJ closed 1 week ago
This really isn't straightforward, and there isn't a right answer. Say someone wants a dashboard delivering to Grafana without a UID - if Grizzly added the metadata/name
as UID, it would then be shipping a different dashboard to the one the user expected, resulting in unexpected behaviour.
Using validation to confirm that metadata/name
and UID both match, and erroring out otherwise is the simplest and cleanest of a bad set of options.
Thank you for looking into this issue.
I would like to point out that setting the UID
value does not seem to work as expected, regardless of the validation routine.
For instance, even when I configure metadata/name
to "hello" and set the UID
to "hello," I still receive the same error message. It appears that the UID
is always empty, causing the validation routine to consistently fail.
Dashboard.hello failed: uid "" and name "hello", don't match.
In summary, the UID
value setting does not appear to be functioning correctly.
can you give me a simple snippet that demonstrates this case?
You can reproduce this issue by using the following dashboard.jsonnet file.
local grafana = import 'grafonnet/grafana.libsonnet';
{
grafanaDashboards:: {
empty_dashboard: grafana.dashboard.new(title="hello", uid="world"),
},
}
Its result:
The commands are as follows:
mkdir simple-dashboard
cd simple-dashboard
jb init
jb install https://github.com/grafana/grafonnet-lib/grafonnet
vi dashboard.jsonnet # put the content above
grr apply dashbaord.jsonnet
Just in case, I updated my grizzly version from v0.4.0 to v0.4.3, but I still got the same error message.
2024/07/17 10:27:36 grr version v0.4.3
I am also facing the same issue.
As pointed out above, the grizzly.jsonnet
seems to set the dashboard uid
to an empty string (https://github.com/grafana/grizzly/blob/main/pkg/grizzly/grizzly.jsonnet#L41-L42) when parsing the jsonnet input file, making the validation logic redundant. The resource.Name()
function then serves as a valid uid
.
If the intention is to always keep the uid
as an empty string, I've created an example PR to remove the validation: https://github.com/grafana/grizzly/pull/466, and it seems to work.
Ahh, thanks, I haven't been looking at grizzly.jsonnet
. I'm AFK until next week. I can take a look then, unless someone beats me to it.
Hi @malcolmholmes, just a friendly reminder, please check this when you get a chance. Thank you! 😄
Grizzly Version
v0.4.0
Expected Behavior
Actual Behavior
Steps to Reproduce
Prepare the Jsonnet File:
test.jsonnet
.{ grafanaDashboardFolder:: 'Test Dashboard Folder', grafanaDashboards:: { ['test_dashboard']: dashboard.new(title="hello", uid="hello"), }, }
Set Configuration Values:
GRAFANA_URL
andGRAFANA_TOKEN
values.Apply the Jsonnet File:
grr apply test.jsonnet
.Note: In my local environment, I was able to resolve this issue by either: