Kibana URL template with relative path

One possible workaround might be:

  1. Get the index-pattern using its title or the ID
# Search by index-pattern title
GET .kibana/_search
{
  "query": {
    "bool": {
      "filter": [
        {
          "term": {
            "type": {
              "value": "index-pattern"
            }
          }
        },
        {
          "term": {
            "index-pattern.title": {
              "value": "kibana_sample_data_logs"
            }
          }
        }
      ]
    }
  }
}
# Or if you know the ID
GET .kibana/_doc/index-pattern:90943e30-9a47-11e8-b64d-95841ca0b247
  1. Get the content of the field fieldFormatMap.
    E.g.

    "fieldFormatMap": """{"url.keyword":{"id":"url","params":{"parsedUrl":{"origin":"https://localhost:9243","pathname":"/app/kibana","basePath":""},"urlTemplate":"/some/pathname/asset.png"}},"url":{"id":"url","params":{"parsedUrl":{"origin":"https://localhost:9243","pathname":"/app/kibana","basePath":""},"urlTemplate":"/some/pathname/asset.png"}}}"""
    
  2. Get the _id of the index-pattern.
    E.g. index-pattern:90943e30-9a47-11e8-b64d-95841ca0b247

  3. Modify the content of the fieldFormatMap to replace the URL of your local environment with the correct one

  4. Execute a partial update.
    E.g.

POST .kibana/_update/index-pattern:90943e30-9a47-11e8-b64d-95841ca0b247
{
  "doc": {
    "index-pattern": {
      "fieldFormatMap": """{"url.keyword":{"id":"url","params":{"parsedUrl":{"origin":"https://yourdevenv:5601","pathname":"/app/kibana","basePath":""},"urlTemplate":"/some/pathname/asset.png"}},"url":{"id":"url","params":{"parsedUrl":{"origin":"yourdevenv:5601","pathname":"/app/kibana","basePath":""},"urlTemplate":"/some/pathname/asset.png"}}}"""
    }
  }
}

All those requests can be done using bash, curl and sed and automated in a script.

I've opened the following for reference:

2 Likes