Skip to content

panel ids in different dashboards have common numbering #235

Description

@rifler

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions