Migrate Kibana dashboards

更新时间:
复制 MD 格式

This topic describes how to migrate your dashboards from an existing Kibana instance to one connected to Simple Log Service (SLS) after your data migration is complete.

Solution overview

image
  1. Export the dashboard as an export.ndjson file from your source Kibana instance.

  2. In the export.ndjson file, replace the old index pattern ID with the new Kibana index pattern ID.

  3. After you update the ID, import the modified export.ndjson file into your new Kibana instance.

Procedure

1. Export the dashboard from Elasticsearch

  1. Write the following data to your source Elasticsearch instance.

    POST people/_bulk
    { "index": {} }
    { "name": "Alice", "age": 30 }
    { "index": {} }
    { "name": "Bob", "age": 25 }
    { "index": {} }
    { "name": "Charlie", "age": 35 }
  2. Create two dashboards in Kibana based on people, named People Dashboard and People Names.

  3. In the People Dashboard, create a chart.

    For example, create a horizontal bar chart that shows the Median of age, which is approximately 30.

  4. Navigate to Stack Management > Saved Objects. On the Saved Objects page, select the dashboard that you want to export. Clear the Include related objects checkbox and export the file. Kibana exports the dashboard to a file named export.ndjson.

    In the search bar, enter type:(dashboard) to filter the list to show only dashboards.

2. Prepare the SLS-connected Kibana instance

  1. Log on to the Simple Log Service console.

  2. In the Projects section, click the one you want.

    image

  3. Write the same log data into your Logstore. Ensure that all field names are identical to the source.

    Note

    Field names in Elasticsearch must exactly match those in Simple Log Service. Mismatches can cause errors after migration, such as a "field not found" error when you open the dashboard.

    After writing the data, verify it by querying the raw logs in your test-logstore. Confirm that the log entries contain the age and name fields with the correct values, for example: age: 30, name: Alice, age: 25, name: Bob, and age: 35, name: Charlie.

  4. Deploy a new Kibana instance and connect it to SLS. For instructions, see Connect to Kibana.

    Note

    Ensure that the versions of your new Elasticsearch and Kibana instances are the same as those in the source environment.

  5. When you connect to SLS using Docker Compose or Helm Chart, Kibana automatically creates the required index pattern.

    In the Kibana navigation pane, go to Stack Management > Index Patterns. You can see the automatically created index pattern, such as etl.people.

3. Perform the migration

  1. Find the ID of the index pattern in your source Elasticsearch environment. The kibana_config_1.json file contains the connection details for your source Kibana instance:

    {
        "url" : "http://xxx:5601",
        "user" : "elastic",
        "password" : "",
        "space" :  "default"
    }

    Run the following command with the ptn_list.py script to find the index pattern ID:

    ➜  python ptn_list.py kibana_config_1.json
    f06fc2b0-****-****-****-15adf26175c7    people

    The output f06fc2b0-****-****-****-15adf26175c7 is the ID of the source people index pattern. This ID is referenced multiple times in the exported export.ndjson file.

    {"id":"f06fc2b0-b82d-11ef-88c6-15adf26175c7", ...}

    The file contains multiple references to this ID, which indicates the dashboard's dependency on the index pattern.

  2. Find the ID of the new index pattern in the Kibana instance connected to SLS.

    Use the ptn_list.py script again, this time with the configuration file for your new Kibana instance, to find the new index pattern ID.

    # Prepare kibana_config_2.json
    
    ➜  python ptn_list.py kibana_config_2.json
    ef710470-****-****-****-ad198b7b763d	etl.people

    Use the sed command to replace all instances of the old ID with the new one in the export.ndjson file.

    sed -i 's/f06fc2b0-****-****-****-15adf26175c7/ef710470-****-****-****-ad198b7b763d/' export.ndjson
  3. Navigate to Stack Management > Saved Objects in your new Kibana instance. On the Saved Objects page, click Import and select the modified export.ndjson file.

    The Import saved objects dialog box shows 2 objects imported and 2 new. It lists two imported objects: People Dashboard and People Names. A green check icon appears to the right of each item. Click Done to complete the operation.

  4. Open the new dashboard to verify the result.

    After the import is complete, the People Dashboard page displays the imported visualization, such as the Median of age horizontal bar chart. This confirms that the migration was successful.