Kibana API Map creation

Hi all!

I would like to create a map in Kibana via REST API.
I must provide JSON body in POST request to do it, but it includes some unclear fields and there are no corresponding explanations in Kibana documentation.
Please explain to me what is:

  1. id of layerListJSON object? should I create this object somehow in advance? what type does this object have?
  2. layerListJSON->sourceDescriptor object and its id ? should I create this object somehow in advance? what type does this object have?

many thanks!

The ids for elasticsearch layers should be a unique string. You will need to define a layerDescriptor with a valid sourceDescriptor.

Layer descriptor is defined at https://github.com/elastic/kibana/blob/master/x-pack/plugins/maps/common/descriptor_types/layer_descriptor_types.ts. Source descriptor is defined at https://github.com/elastic/kibana/blob/master/x-pack/plugins/maps/common/descriptor_types/source_descriptor_types.ts.

You can see some examples layer lists in the sample data maps at https://github.com/elastic/kibana/tree/master/x-pack/plugins/maps/server/sample_data

Another strategy is to build a map with the UI and then use the saved object UI in management to export the saved object and inspect the generated layer list.

Hope that helps

2 Likes

@Nathan_Reese
thank you very much!

I already exported the existing map and trying to analyse it.
When I copied the whole json response and use it to create a new map it works fine. But when I am trying replace ES index id in the reference section I get an empty map.
i tried to remove ids of layerListJSON and sourceDescriptor but it also didn't give result ( resulted map is empty ).

Should I create layerListJSON and sourceDescriptor objects in advance (how can I do it? ) and then input their id into the final request? or can I create all objects as a single request?

Can you describe your usecase? Why are you trying to programmatically create maps?

When I copied the whole json response and use it to create a new map it works fine. But when I am trying replace ES index id in the reference section I get an empty map.

indexPatternId must match the saved object id of a Kibana index pattern saved object. If indexPatternId does not match a saved object id, then it is not possible to generate elasticsearch requests

my case is very simple:
i already automated some data ingestion into ES instance and I would like to automate map creation for this data.
but this data is very different, so that's why i would like to have separate maps for each uploaded data chunk

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.