Kibana APIedit

In addition to the APM specific API endpoints, Kibana provides its own REST API which you can use to automate certain aspects of configuring and deploying Kibana. An example is below.

Customize the APM index patternedit

As an alternative to updating apm_oss.indexPattern in your kibana.yml configuration file, you can use Kibana’s update object API to update the default APM index pattern on the fly.

The following example sets the default APM app index pattern to some-other-pattern-*:

curl -X PUT "localhost:5601/api/saved_objects/index-pattern/apm_static_index_pattern_id" \ 
-H 'Content-Type: application/json' \
-H 'kbn-xsrf: true' \
-H 'Authorization: Basic ${YOUR_AUTH_TOKEN}' \
-d' {
      "attributes": {
        "title": "some-other-pattern-*", 
      }
    }'

apm_static_index_pattern_id is the internal, hard-coded ID of the APM index pattern. This value should not be changed

Your custom index pattern matcher.

The API returns the following:

{
   "id":"apm_static_index_pattern_id",
   "type":"index-pattern",
   "updated_at":"2020-07-06T22:55:59.555Z",
   "version":"WzYsMV0=",
   "attributes":{
      "title":"some-other-pattern-*"
   }
}

To view the new APM app index pattern, use the GET object API:

curl -X GET "localhost:5601/api/saved_objects/index-pattern/apm_static_index_pattern_id" \ 
-H 'kbn-xsrf: true' \
-H 'Authorization: Basic ${YOUR_AUTH_TOKEN}'

apm_static_index_pattern_id is the internal, hard-coded ID of the APM index pattern.

The API returns the following:

{
  "id":"apm_static_index_pattern_id",
  "type":"index-pattern",
  "updated_at":"2020-07-06T22:55:59.555Z",
  "version":"WzYsMV0=",
  "attributes":{...}
    "fieldFormatMap":"{...}
    "fields":"[{...},{...},...]
    "sourceFilters":"[{\"value\":\"sourcemap.sourcemap\"}]",
    "timeFieldName":"@timestamp",
    "title":"some-other-pattern-*"
   },
   ...
}

More information on Kibana’s API is available in REST API.