Skip to content

Exporting and importing dashboards with index pattern IDs #10117

@cwurm

Description

@cwurm

At some point, Kibana changed how it exports dashboards (see comments here and here). Where previously, the export would contain a searchSourceJSON like this:

"searchSourceJSON": {
    "filter": [],
    "index": "packetbeat-*",
    "query": {
        "query_string": {
        "analyze_wildcard": true,
        "query": "*"
        }
    }
}

It is now (7.0 at least):

"searchSourceJSON": {
    "filter": [],
    "index": "dfce2b60-18c7-11e9-9094-c50574723088",
    "query": {
        "language": "kuery",
        "query": ""
    }
}

index is the ID of the Kibana index pattern object, so different for each instance.

This presents us with a problem when distributing dashboards with our Beats. Where previously we could just rely on e.g. the packetbeat-* index pattern to be present already when importing a dashboard and used automatically, with IDs this does not work anymore. We don't know the existing IDs, and we don't want to import a new index pattern every time we import a dashboard.

Some options:

  1. Since Kibana still seems to accept the old format, we could modify our dashboard exporter to overwrite the index field with the pattern. I'm not sure how long that would work though, I assume at some point Kibana might want to deprecate/remove specifying the search pattern in that field.
  2. We could modify our dashboard importer to query first for the presence and ID of the specific index pattern (e.g. packetbeat-*) and then overwrite the index field with that. To find the index pattern ID we could probably use GET /api/saved_objects/_find.

I like 2 because it's a longer term solution, but I did want to see if there are other opinions, and maybe if somebody from the Kibana team can confirm if this is the way to go.

/cc @sayden @ruflin @jsoriano - since you hit this as well in #10076
/cc @elastic/kibana-platform - I see you're working on some improvements to the APIs in elastic/kibana#27203, but from what I see it has more to do with automatically including and resolving dependencies and wouldn't help here. In any case, I'd be curious on your opinion of how we should handle this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions