Migrating Jaeger Indices from Elasticsearch to OpenSearch: A Comprehensive Guide

4 minute read

Introduction: Seamlessly Transitioning Your Jaeger Backend

Hey There,

Building on our previous discussion about streamlining Jaeger data management in OpenSearch, let’s dive into another critical topic: migrating Jaeger indices from Elasticsearch to OpenSearch. With OpenSearch gaining traction as a robust and open-source alternative, it’s time to explore how to make this transition smooth and efficient.

The Challenge: Migrating Without Downtime

Switching from Elasticsearch to OpenSearch might sound daunting, but with the right approach, you can migrate your Jaeger indices seamlessly. We’ll walk through the process, focusing on minimizing downtime and ensuring data integrity.

Our Goal: A Smooth Migration Path

We aim to transfer Jaeger indices from Elasticsearch to OpenSearch using a Python script that leverages the reindex API. The goal is to convert daily indices into a managed index pattern, using ISM policies to create new indices based on specific conditions. Think of it as carefully moving your belongings from one house to another without losing or breaking anything, and then organizing everything in a more efficient way.

Pre-requisites: Getting Ready

Before starting, ensure you have:

  • A running Jaeger setup with Elasticsearch as the backend.
  • An OpenSearch cluster set up and ready to receive data.
  • Adequate storage and resources for the migration.
  • Administrative access to both Elasticsearch and OpenSearch clusters.

Step 1: Automating the Migration with a Script

Manual migration of indices can be error-prone and time-consuming. To streamline this process, we’ve developed a Python script that automates the migration. Automating this task helps avoid human errors and saves significant time, ensuring a smooth and efficient transition.

Here’s a summary of what the script does:

  1. Loads Configuration: The script loads necessary parameters from a YAML file, including source indices, target indices, and connection details.
  2. Initializes OpenSearch Client: It sets up an OpenSearch client to interact with the target cluster.
  3. Starts Reindexing Tasks: The script initiates reindexing tasks to transfer data from the source Elasticsearch index to the target OpenSearch index, handling remote connections securely.
  4. Checks Task Status: It periodically checks the status of each reindexing task, logging progress and handling any errors.
  5. Orchestrates the Migration: The main function orchestrates the entire process, ensuring all tasks are started and monitored until completion.

For the full script and detailed README, you can access the repository here.

Step 2: Prepare the Configuration File

To run the script, you need a configuration file that includes all the details for the migration. This file defines the source indices, target indices, and connection details for both Elasticsearch and OpenSearch.

Here’s an example configuration file:

 1es_target_config:
 2  hosts: ["http://your-opensearch-cluster:9200"]
 3  http_auth: ["username", "password"]
 4  # use_ssl: False
 5  # verify_certs: False
 6  # ssl_assert_hostname: False
 7  # ssl_show_warn: False
 8
 9es_source_remote:
10  host: "http://your-elasticsearch-cluster:9200"
11  username: "source_username"
12  password: "source_password"
13
14source_indices:
15  - jaeger-span-2024-01-10
16  - jaeger-span-2024-01-11
17  - jaeger-span-2024-01-12
18  - jaeger-span-2024-01-13
19
20target_index: "jaeger-span-00001"

Step 3: Run the Migration

After cloning the script repository and adding your configuration file (config.yaml), it’s time to run the script and start the migration process.

  1. Save the script as migrate_indices.py.
  2. Save the configuration file as config.yaml.
  3. Run the script:
    1python migrate_indices.py --config config.yaml
    

This command will start the migration process, using the parameters defined in your configuration file.

Step 4: Verify the Migration

Once the script has finished running, it’s important to verify that the data has been successfully migrated. Here’s how you can check:

  • Check Jaeger’s UI for traces: Ensure that the traces are available and accessible in the Jaeger UI.
  • Verify indices in OpenSearch: Use the following command to check the indices in OpenSearch:
    1GET /_cat/indices?v
    

Managing New Indices with ISM Policies

Once the migration is complete, it’s essential to set up Index State Management (ISM) policies in OpenSearch to efficiently manage the lifecycle of your new indices. ISM policies help automate index rollover, retention, and deletion, ensuring your data remains organized and manageable.

Why Use ISM Policies?

ISM policies allow you to define specific rules for your indices, such as when to roll over to a new index, when to move indices to a different storage tier, and when to delete old indices. This automation helps maintain optimal performance and storage costs.

Example ISM Policy

Here’s an example of an ISM policy for Jaeger indices:

 1{
 2  "policy": {
 3    "description": "Jaeger index management policy",
 4    "default_state": "hot",
 5    "states": [
 6      {
 7        "name": "hot",
 8        "actions": [
 9          {
10            "rollover": {
11              "min_size": "50gb",
12              "min_index_age": "30d"
13            }
14          }
15        ],
16        "transitions": [
17          {
18            "state_name": "warm",
19            "conditions": {
20              "min_index_age": "30d"
21            }
22          }
23        ]
24      },
25      {
26        "name": "warm",
27        "actions": [],
28        "transitions": [
29          {
30            "state_name": "cold",
31            "conditions": {
32              "min_index_age": "60d"
33            }
34          }
35        ]
36      },
37      {
38        "name": "cold",
39        "actions": [],
40        "transitions": [
41          {
42            "state_name": "delete",
43            "conditions": {
44              "min_index_age": "90d"
45            }
46          }
47        ]
48      },
49      {
50        "name": "delete",
51        "actions": [
52          {
53            "delete": {}
54          }
55        ]
56      }
57    ],
58    "ism_template": [
59      {
60        "index_patterns": [
61          "jaeger-span-*"
62        ],
63        "priority": 30
64      }
65    ]
66  }
67}

For detailed steps on setting up and applying ISM policies, please refer to our previous article on streamlining Jaeger data management in OpenSearch. This article provides a comprehensive guide on implementing ISM policies to ensure your indices are efficiently managed.

Conclusion: Ready for the Next Chapter

Migrating Jaeger indices from Elasticsearch to OpenSearch can be straightforward with the right approach. Using the provided script ensures data integrity and minimal downtime. OpenSearch’s open-source nature and robust features make it a compelling alternative to Elasticsearch.

By following this guide, you’ll ensure a smooth transition, allowing you to continue leveraging Jaeger’s powerful tracing capabilities on a modern and open platform.