0Pricing
Elasticsearch & Full Text Search Systems · レッスン

時系列データの管理

データストリーム、ILM(Index Lifecycle Management)、hot-warm-coldアーキテクチャなど、時系列データ向けにElasticsearchを最適化する方法を学びます。

「時系列データの管理」はCoddyKit上の無料Elasticsearch & Full Text Search Systemsレッスンです。 これはレッスン2/4です。 下記で完全なレッスンを無料で読むことができます。その後、ブラウザ内の組み込みコードエディタと24時間対応のAIチューターでハンズオン演習できます。 これはElasticsearch & Full Text Search Systems学習パスの一部であり、ウェブとCoddyKitアプリ全体で進捗が同期されます。 Elasticsearch & Full Text Search Systemsコースには全4レッスンが含まれています。

このレッスンの一部はまだ翻訳されておらず、英語で表示されています。

What is Time-Series Data?

Time-series data is information collected over a period of time, often at regular intervals. Think of it as a sequence of data points indexed by time.

Examples include:

  • System logs: Events happening on a server.
  • IoT sensor readings: Temperature, humidity from devices.
  • Financial data: Stock prices over days or hours.

This data is typically append-only and usually immutable once recorded.

Why Elasticsearch for Time-Series?

Elasticsearch is an excellent choice for managing time-series data due to its:

  • Scalability: Handles massive volumes of data.
  • Speed: Fast indexing and search capabilities.
  • Analytics: Powerful aggregations for insights.
  • Flexibility: Can store structured and unstructured data.

It's particularly strong for use cases like log analytics, metric monitoring, and security event management.

Introducing Data Streams

Data streams are a core feature in Elasticsearch designed specifically for time-series data. They simplify management by automatically rolling over to new indices as needed.

When you index data into a data stream, it always writes to the current write index. Queries, however, search across all backing indices transparently. This makes managing large, continuously growing datasets much easier.

Creating Your First Data Stream

To create a data stream, you first need an index template that defines its structure and points to a data stream.

Then, simply indexing a document into the stream's name will create it automatically based on the template:

PUT _index_template/my-data-stream-template
{
  "index_patterns": ["my-data-stream-*"],
  "data_stream": {},
  "priority": 200,
  "template": {
    "settings": {
      "number_of_shards": 1
    },
    "mappings": {
      "properties": {
        "@timestamp": {
          "type": "date",
          "format": "strict_date_optional_time||epoch_millis"
        },
        "message": { "type": "text" }
      }
    }
  }
}

// Indexing a document creates the stream
POST my-data-stream/_doc
{
  "@timestamp": "2023-10-27T10:00:00Z",
  "message": "Sensor reading: 25.5C"
}

Automating with ILM

Index Lifecycle Management (ILM) is a powerful feature that automates the management of your indices through various phases of their life.

For time-series data, ILM helps you:

  • Automatically roll over indices when they reach a certain size or age.
  • Move older, less frequently accessed data to cheaper storage.
  • Delete data that is no longer needed.

The Four ILM Phases

ILM policies define actions for indices across four main phases:

  • Hot: Indices are actively being written to and frequently queried. Requires fast storage.
  • Warm: Indices are no longer being written to, but are still queried. Can be read-only and potentially on slower storage.
  • Cold: Indices are rarely queried and often stored on very cheap, slow storage.
  • Delete: Indices are no longer needed and are safely removed from the cluster.

Crafting an ILM Policy

Here's an example of an ILM policy that defines rollover, forcemerge (for warm phase), and deletion stages for time-series data:

PUT _ilm/policy/my-ts-policy
{
  "policy": {
    "phases": {
      "hot": {
        "actions": {
          "rollover": {
            "max_age": "7d",
            "max_docs": 10000000,
            "max_size": "50gb"
          }
        }
      },
      "warm": {
        "min_age": "30d",
        "actions": {
          "forcemerge": {
            "max_num_segments": 1
          },
          "shrink": {
            "number_of_shards": 1
          }
        }
      },
      "cold": {
        "min_age": "90d",
        "actions": {
          "freeze": {}
        }
      },
      "delete": {
        "min_age": "180d",
        "actions": {
          "delete": {}
        }
      }
    }
  }
}

Hot-Warm-Cold Architecture

A Hot-Warm-Cold architecture optimizes resource utilization and cost for time-series data by using different types of nodes for different ILM phases.

  • Hot nodes: Use fast CPUs, SSDs for high indexing and query throughput.
  • Warm nodes: Use less powerful CPUs, HDDs (or slower SSDs) for older, read-only data.
  • Cold nodes: Use very cheap, high-capacity storage, potentially even object storage, for rarely accessed data.

Assigning Node Roles

You can configure nodes to serve specific roles (hot, warm, cold) by setting node.attr in their elasticsearch.yml configuration file.

ILM policies then use these attributes to automatically move indices to the appropriate node types as they transition through phases.

# For a hot node
node.roles: [ data ]
node.attr.data: hot

# For a warm node
node.roles: [ data ]
node.attr.data: warm

# For a cold node
node.roles: [ data ]
node.attr.data: cold

ILM & Data Stream Check

Which of the following statements about Elasticsearch's time-series features are TRUE?

Time-Series Recap

Great job! You've explored how Elasticsearch is optimized for time-series data.

We covered:

  • Data Streams: Simplifying index management and rollovers.
  • ILM (Index Lifecycle Management): Automating index transitions through hot, warm, cold, and delete phases.
  • Hot-Warm-Cold Architectures: Optimizing cluster resources and costs by assigning different node types to specific ILM phases.

These features are essential for building scalable and cost-effective time-series solutions with Elasticsearch.

よくある質問

「時系列データの管理」レッスンは無料ですか?

はい。「時系列データの管理」の完全なテキストはこのウェブで無料で読めます。インタラクティブに演習し(組み込みコードエディタと24時間対応のAIチューター)、Elasticsearch & Full Text Search Systemsコースの残りをアンロックするには、CoddyKit PROにアップグレードしてください。 Elasticsearch & Full Text Search Systemsコースには全4レッスンが含まれています。

「時系列データの管理」で何を学びますか?

データストリーム、ILM(Index Lifecycle Management)、hot-warm-coldアーキテクチャなど、時系列データ向けにElasticsearchを最適化する方法を学びます。 ブラウザで直接実行するハンズオンコードでElasticsearch & Full Text Search Systemsを演習し、24時間対応のAIチューターがレッスンを進める中での質問に答えます。

Elasticsearch & Full Text Search Systemsを始めるのに経験は必要ですか?

事前経験は必要ありません。CoddyKitのElasticsearch & Full Text Search Systemsは初級者から上級者向けに構成されているため、ここから始めるか最初から始めて、自分のペースで進むことができます。 これはレッスン2/4です。

「時系列データの管理」レッスンにはどのくらい時間がかかりますか?

ほとんどのCoddyKitレッスンは約5~10分かかります。各レッスンはコンパクトでインタラクティブなので、着実に進歩し、ウェブとアプリ全体で正確に前回の場所から再開できます。

このElasticsearch & Full Text Search Systemsレッスンでコードを書いて実行できますか?

はい。すべてのElasticsearch & Full Text Search Systemsレッスンに組み込みコードエディタが含まれているため、ブラウザでリアルコードを書いて実行し、即座のAIフィードバックを取得できます。ローカル設定は不要です。

このコースのすべてのレッスン

  1. 地理空間検索の機能
  2. 時系列データの管理
  3. 本番環境へのデプロイ戦略
  4. インデックスライフサイクル管理
← Elasticsearch & Full Text Search Systemsに戻る