Debian 13 trixie

Elastic Stack : Metricbeat インストール2025/10/16

 

CPU やメモリー使用量等のシステム情報のデータ収集機能を提供する Metricbeat をインストールします。

システム情報以外にも、設定により Apache や MySQL のメトリックも収集可能です。詳細は公式サイトを参照ください。
⇒ https://www.elastic.co/guide/en/beats/metricbeat/current/metricbeat-modules.html

[1] Metricbeat をインストールします。 事前に Elasticsearch リポジトリ設定済みであることが前提です。
root@dlp:~#
apt -y install metricbeat
[2] 基本的な設定をして Metricbeat を起動します。
root@dlp:~#
vi /etc/metricbeat/metricbeat.yml
# 67行目 : Kibana を使用する場合はコメント解除して出力先を指定
# Kibana で SSL 有効の場合は証明書に登録したホスト名と合わせる
# [username], [password] は管理ユーザーのユーザー名とパスワード
# 自己署名の証明書を使用している場合は [ssl.verification_mode: none]

setup.kibana:
.....
  host: "https://dlp.srv.world:5601"
  protocol: "https"
  username: "elastic"
  password: "password"
  ssl.enabled: true
  ssl.verification_mode: none

# 99行目 : Elasticsearch の出力先を指定する
# [username], [password] は管理ユーザーのユーザー名とパスワード
# [ssl.certificate_authorities] は Elasticsearch で生成された cacert

output.elasticsearch:
  # Array of hosts to connect to.
  hosts: ["https://dlp.srv.world:9200"]

  protocol: "https"
  username: "elastic"
  password: "password"
  ssl.certificate_authorities: "/etc/elasticsearch/certs/http_ca.crt"

.....
.....

root@dlp:~#
vi /etc/metricbeat/metricbeat.reference.yml
# 61行目 : 収集する項目を設定
# コメントアウト/コメント解除で有効/無効にする

- module: system
  metricsets:
    - cpu             # CPU usage
    - load            # CPU load averages
    - memory          # Memory usage
    - network         # Network IO
    - process         # Per process metrics
    - process_summary # Process summary
    - uptime          # System Uptime
    - socket_summary  # Socket summary
    #- core           # Per CPU core usage
    #- diskio         # Disk IO
    #- filesystem     # File system usage for each mountpoint
    #- fsstat         # File system summary metrics
    #- raid           # Raid
    #- socket         # Sockets and connection info (linux only)
    #- service        # systemd service information
  enabled: true
  period: 10s
  processes: ['.*']

# 3049行目 : Kibana を使用する場合はコメント解除して出力先を指定
# Kibana で SSL 有効の場合は ssl 系設定をコメント解除
# [username], [password] は管理ユーザーのユーザー名とパスワード
# 自己署名の証明書を使用している場合は [ssl.verification_mode: none]

setup.kibana:

  # Kibana Host
  # Scheme and port can be left out and will be set to the default (http and 5601)
  # In case you specify and additional path, the scheme is required: http://localhost:5601/path
  # IPv6 addresses should always be defined as: https://[2001:db8::1]:5601
  host: "https://dlp.srv.world:5601"

   # Optional protocol and basic auth credentials.
  protocol: "https"
  username: "elastic"
  password: "password"

  # Optional HTTP path
  #path: ""

  # Optional Kibana space ID.
  #space.id: ""

  # Use SSL settings for HTTPS.
  ssl.enabled: true
  
.....
.....

  # after very careful consideration. It is primarily intended as a temporary
  # diagnostic mechanism when attempting to resolve TLS errors; its use in
  # production environments is strongly discouraged.
  # The default value is full.
  ssl.verification_mode: none

root@dlp:~#
systemctl enable --now metricbeat
[3] データが取り込まれているか確認しておきます。
# index 一覧

root@dlp:~#
curl -u elastic --cacert /etc/elasticsearch/certs/http_ca.crt https://127.0.0.1:9200/_cat/indices?v

Enter host password for user 'elastic':
health status index                                                              uuid                   pri rep docs.count docs.deleted store.size pri.store.size dataset.size
green  open   .internal.alerts-transform.health.alerts-default-000001            WYIrcziPSB61k_EjlRvNWA   1   0          0            0       249b           249b         249b
yellow open   .ds-metricbeat-9.1.5-2025.10.16-000001                             iFHmlkWqQYuxJeK9LM5nNA   1   1         82            0    437.2kb        437.2kb      437.2kb
green  open   .internal.alerts-observability.logs.alerts-default-000001          AWecw7NwQuGi6NSUH8d5hA   1   0          0            0       249b           249b         249b
green  open   .internal.alerts-observability.uptime.alerts-default-000001        B69GpuDOTteviBM8maoY9w   1   0          0            0       249b           249b         249b
green  open   .internal.alerts-ml.anomaly-detection.alerts-default-000001        kB22vDWkRsiGMn2uwjz7pQ   1   0          0            0       249b           249b         249b
green  open   .internal.alerts-observability.slo.alerts-default-000001           RdloOOlgTq-xz9iaWKTYXw   1   0          0            0       249b           249b         249b
green  open   .internal.alerts-default.alerts-default-000001                     O3rAr2zSQR-cwJcyFUTRBw   1   0          0            0       249b           249b         249b
green  open   .internal.alerts-streams.alerts-default-000001                     TmcpmlgvTACt9RLIO3ewjA   1   0          0            0       249b           249b         249b
green  open   .internal.alerts-observability.apm.alerts-default-000001           Bb2-R3ctRw-DR0UX3ohWgw   1   0          0            0       249b           249b         249b
green  open   .internal.alerts-security.attack.discovery.alerts-default-000001   Zr0KNzeVRLyRyhu4FIsmfg   1   0          0            0       249b           249b         249b
green  open   .internal.alerts-observability.metrics.alerts-default-000001       s9kwcco-SKKkQUElzx0sDw   1   0          0            0       249b           249b         249b
green  open   .internal.alerts-ml.anomaly-detection-health.alerts-default-000001 EtkLfH1fTP2AdYngE3dH8Q   1   0          0            0       249b           249b         249b
green  open   .internal.alerts-observability.threshold.alerts-default-000001     I576fuZFQ-We6AT7DOjrIQ   1   0          0            0       249b           249b         249b
green  open   .internal.alerts-security.alerts-default-000001                    HfszRaZ5TtafW3W9kDH5Ow   1   0          0            0       249b           249b         249b
green  open   .internal.alerts-dataset.quality.alerts-default-000001             9SiuGdcAQnCl6DI-HRLowg   1   0          0            0       249b           249b         249b
yellow open   test_index                                                         9JxiZ5C7QXq2fC1UliIOCA   1   1          1            0      6.7kb          6.7kb        6.7kb
green  open   .internal.alerts-stack.alerts-default-000001                       x0vSiLWjSPSdiKgDj1WEBA   1   0          0            0       249b           249b         249b

# index のドキュメント一覧

root@dlp:~#
curl -u elastic --cacert /etc/elasticsearch/certs/http_ca.crt https://127.0.0.1:9200/.ds-metricbeat-9.1.5-2025.10.16-000001/_search?pretty

Enter host password for user 'elastic'
{
  "took" : 1,
  "timed_out" : false,
  "_shards" : {
    "total" : 1,
    "successful" : 1,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 244,
      "relation" : "eq"
    },
    "max_score" : 1.0,
    "hits" : [
      {
        "_index" : ".ds-metricbeat-9.1.5-2025.10.16-000001",
        "_id" : "vDNg6pkBV9tUpIIAzzju",
        "_score" : 1.0,
        "_source" : {
          "@timestamp" : "2025-10-16T00:17:07.279Z",
          "host" : {
            "containerized" : false,
            "ip" : [
              "10.0.0.30",
              "fe80::5054:ff:fe0a:a7f3"
            ],
            "mac" : [
              "52-54-00-0A-A7-F3",
              "52-54-00-11-E5-5B"
            ],
            "hostname" : "dlp.srv.world",
            "name" : "dlp.srv.world",
            "architecture" : "x86_64",
            "os" : {
              "platform" : "debian",
              "version" : "13 (trixie)",
              "family" : "debian",
              "name" : "Debian GNU/Linux",
              "kernel" : "6.12.48+deb13-amd64",
              "codename" : "trixie",
              "type" : "linux"
            },
            "id" : "1886845de80c4ed7beb96fe6dab65880"
          },
          "agent" : {
            "type" : "metricbeat",
            "version" : "9.1.5",
            "ephemeral_id" : "93a8794c-7f12-4f57-9655-4d392dd1098e",
.....
.....
[4] Kibana を稼働させている場合は、サンプルダッシュボードへのデータインポートが可能です。
root@dlp:~#
metricbeat setup --dashboards

Loading dashboards (Kibana must be running and reachable)
Loaded dashboards

関連コンテンツ