Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

panel ids in different dashboards have common numbering #235

Open
rifler opened this issue Sep 30, 2023 · 1 comment
Open

panel ids in different dashboards have common numbering #235

rifler opened this issue Sep 30, 2023 · 1 comment

Comments

@rifler
Copy link

rifler commented Sep 30, 2023

Hello!

Current behaviour

builder1 := dashboard.New(
    "dashboard 1",
    dashboard.Row(
        "Prometheus",
        row.WithGraph(
            // some data
        ),
    ),
)
builder2 := dashboard.New(
    "dashboard 2",
    dashboard.Row(
        "Prometheus",
        row.WithGraph(
            // some data
        ),
    ),
)

fmt.Printf("%d\n", builder1.Internal().Rows[0].Panels[0].ID)
// 1
fmt.Printf("%d\n", builder2.Internal().Rows[0].Panels[0].ID)
// 2

Expected behaviour
Numbering is independent:

builder1 := dashboard.New(
    "dashboard 1",
    dashboard.Row(
        "Prometheus",
        row.WithGraph(
            // some data
        ),
    ),
)
builder2 := dashboard.New(
    "dashboard 2",
    dashboard.Row(
        "Prometheus",
        row.WithGraph(
            // some data
        ),
    ),
)

fmt.Printf("%d\n", builder1.Internal().Rows[0].Panels[0].ID)
// 1
fmt.Printf("%d\n", builder2.Internal().Rows[0].Panels[0].ID)
// 1

As far as I understand problem is here - https://github.com/K-Phoen/sdk/blob/master/row.go#L33
Possible solution is to extend MarshalJSON/MarshalIndentJSON and mutate ids there, starting them from 1

@K-Phoen
Copy link
Owner

K-Phoen commented Dec 23, 2023

Does that cause any issue when publishing the dashboards to Grafana?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants