API for creating scripted fields


#1

Hi,

I created a couple of scripted fields using Kibana GUI and used them to create visualizations.
I am now looking for a way to automate the creation of scripted fields and import dashboards. Is there an API available for doing the same? If not what is the easiest way to achieve this programmatically?

Regards.
Sindhura


(Nathan Reese) #2

The UI is updating the index-pattern saved object with the new scripted field data. You could perform these steps programmatically. You can open the developer tools in your browser and add a scripted field to an index-pattern. The network tab will capture the interactions with the server so you can see how the UI is using Kibana's saved object API.

Use the saved object GET API to retrieve the index-pattern saved object

Add your scripted field to attributes. fields. Fields is just a JSON array that has been serialized into a string for storage. Convert the string into JSON, add your scripted field to the array and then serialize back to a string.

Use the saved object update API to update the index-pattern saved object.


#3

Hi Nathan,

I am using kibana 6.3.0 and my index patterns is 'ece'.
From the Dev Tools tab in Kibana I tried

GET /api/saved_objects/index-pattern/ece

This returned

    {  "error": "no handler found for uri [/api/saved_objects/index-pattern/*ece*] and method [GET]"
    }

Do I need to use any different id instead of ece? In Management tab > Index Patterns, i have the name ece


(Nathan Reese) #4

The Kibana dev tools can only be used for Elasticsearch APIs, meaning, it is a playground for interacting with Elasticsearch. Anything under /api is a Kibana API hosted by Kibana's web server.

The reason you are getting the error is that the GET request is getting passed to Elasticsearch which does not have a /api/saved_objects endpoint.

I would recommend using someting like CURL for interacting with Kibana's APIs.


(system) #5

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