12. コンテンツにスキップ

12. トラブルシューティング

ElasticSearch連携がうまく動作しない場合の確認方法を記載します。

12.1 データを再収集する

Kibanaを利用している方は本手順を実施する前にバックアップとして

別紙Kibana連携機能ガイドの「インポート手順」を実施してください。

注意

データの再収集時の手順を誤った際にKibanaで作成したグラフ等が削除されてしまう可能性があります。

12.1.1 Linux版 Elasticsearchの場合

Senju Service ManagerからElasticsearchへのデータ連携のためのアプリケーションとしてLogstachを利用していますが、Logstashの動作が不正になった場合に、一度ElasticSearchに 保存されているデータをリセットしたうえで、再収集する必要がある場合があります。

Info

本手順を実施すると再収集が完了するまで、全文検索、類似検索が利用できない状態となります。

データのリセットおよび再収集の手順は以下の通りとなります。

  1. Logstashサービスを停止します。

    以下のコマンドを実行し、サービスを停止します。

    • コマンド
      systemctl stop logstash
      

    以下のコマンドを実行し、サービスの状態を確認します。

    • コマンド
      systemctl status logstash
      

    出力内容中に以下の内容が表示されることを確認します。

    Active: inactive (dead) 
    
  2. Logstashの取り込み履歴を削除します。

    以下のコマンドを実行し、Logstashの取り込み履歴ファイル格納ディレクトリに移動します。

    • コマンド
      cd /opt/logstash/conf
      

    ※上記パスはデフォルト設定先になります。履歴ファイルの格納場所は、以下ファイル内の\"last_run_metadata_path =>\"の設定値をご確認ください。

    • <ディレクトリ>  /etc/logstash/conf.d

      ファイル名 説明
      logstash-postgresql.conf 設定ファイル(プロセス管理)
      logstash-postgresql_ci.conf 設定ファイル(構成管理)
      logstash-postgresql-faq.conf 設定ファイル(FAQ)
      logstash-postgresql-filelibrary.conf 設定ファイル(ファイルライブラリ)

      以下のコマンドを実行し、履歴ファイルを削除します。

      • コマンド
        rm -f .logstash_postresql_*_last_run
        

    以下のコマンドを実行し、Logstashのキューファイル格納ディレクトリに移動します。

    • コマンド
      cd /var/lib/logstash/
      

    以下のコマンドを実行し、ファイルの情報を確認します。

    • コマンド
      ls
      

    以下の内容が出力されることを確認します。

    queue  uuid
    

    以下のコマンドを実行し、キューファイルを削除します。

    • コマンド
      rm -rf queue
      rm -rf uuid
      
  3. ElasticSearchのインデックス情報を削除します。

    • Elasticsearch認証の設定が未実施の場合:

      以下のコマンドを実行し、現在のインデックス情報を確認します。

      • コマンド
        curl -XGET "[protocol]://[hostname]:[portnumber]/_aliases?pretty"
        

      例)Elasticsearch への接続情報でプロトコル[protocol]:http、ホスト名[hostname]:eshost、ポート番号[portnumber]:9200とした場合は、以下のコマンドを実行します。

      • コマンド
        curl -XGET "http://eshost:9200/_aliases?pretty"
        

      以下の内容が出力されることを確認します。

      {
          "ssm" : {
              "aliases" : { }
          },
          "ssm_ci" : {
              "aliases" : { }
          },
          "ssm_faq" : {
              "aliases" : { }
          },
          "ssm_filelibrary" : {
              "aliases" : { }
          }
      }
      

      以下のコマンドを実行し、インデックス情報を削除します。

      • コマンド
        curl -XDELETE "[protocol]://[hostname]:[portnumber]/ssm?pretty"
        curl -XDELETE "[protocol]://[hostname]:[portnumber]/ssm_ci?pretty"
        curl -XDELETE "[protocol]://[hostname]:[portnumber]/ssm_faq?pretty"
        curl -XDELETE "[protocol]://[hostname]:[portnumber]/ssm_filelibrary?pretty"
        

      例)Elasticsearch への接続情報でプロトコル[protocol] → http、ホスト名[hostname] → eshost、ポート番号[portnumber] → 9200とした場合は、以下のコマンドを実行します。

      • コマンド
        curl -XDELETE "http://eshost:9200/ssm?pretty"
        curl -XDELETE "http://eshost:9200/ssm_ci?pretty"
        curl -XDELETE "http://eshost:9200/ssm_faq?pretty"
        curl -XDELETE "http://eshost:9200/ssm_filelibrary?pretty"
        

      以下の内容が出力されることを確認します。

      {
          "acknowledged" : true
      }
      
    • Elasticsearch認証の設定が実施済の場合:

      以下のコマンドを実行し、現在のインデックス情報を確認します。

      • コマンド
        curl -XGET "[protocol]://[hostname]:[portnumber]/_aliases?pretty" -u [elasticuser]:[elasticpassword]
        

      例)Elasticsearch への接続情報でプロトコル[protocol]:http、ホスト名[hostname]:eshost、ポート番号[portnumber]:9200、認証ユーザー名[elasticuser]:elastic、認証パスワード[elastipassword]:elapwdとした場合は、以下のコマンドを実行します。

      • コマンド
        curl -XGET "http://eshost:9200/_aliases?pretty" –u elastic:elapwd
        

      以下の内容が出力されることを確認します。

      {
          "ssm" : {
              "aliases" : { }
          },
          "ssm_ci" : {
              "aliases" : { }
          },
          "ssm_faq" : {
              "aliases" : { }
          },
          "ssm_filelibrary" : {
              "aliases" : { }
          }
      }
      

      以下のコマンドを実行し、インデックス情報を削除します。

      • コマンド
        curl -XDELETE "[protocol]://[hostname]:[portnumber]/ssm?pretty" -u [elasticuser]:[elasticpassword]
        curl -XDELETE "[protocol]://[hostname]:[portnumber]/ssm_ci?pretty" -u [elasticuser]:[elasticpassword]
        curl -XDELETE "[protocol]://[hostname]:[portnumber]/ssm_faq?pretty" -u [elasticuser]:[elasticpassword]
        curl -XDELETE "[protocol]://[hostname]:[portnumber]/ssm_filelibrary?pretty" -u [elasticuser]:[elasticpassword]
        

      例)Elasticsearch への接続情報でプロトコル[protocol]:http、ホスト名[hostname]:eshost、ポート番号[portnumber]:9200、認証ユーザー名[elasticuser]:elastic、認証パスワード[elastipassword]:elapwdとした場合は、以下のコマンドを実行します。

      • コマンド
        curl -XDELETE "http://eshost:9200/ssm?pretty" –u elastic:elapwd
        curl -XDELETE "http://eshost:9200/ssm_ci?pretty" –u elastic:elapwd
        curl -XDELETE "http://eshost:9200/ssm_faq?pretty" –u elastic:elapwd
        curl -XDELETE "http://eshost:9200/ssm_filelibrary?pretty" –u elastic:elapwd
        

      以下の内容が出力されることを確認します。

      {
          "acknowledged" : true
      }
      

    注意

    削除コマンドの対象のインデックスには必ず以下を指定してください。
    ・ssm
    ・ssm_ci
    ・ssm_faq
    ・ssm_filelibrary
    「*」を指定した場合、Elasticsearchに関するインデックスも削除されてしまいます。
    関係ないインデックスを削除してしまった際にはElasticsearch認証の設定を再度実施してください。
    また、Kibanaを利用している方は別紙Kibana連携機能ガイドの「エクスポート手順
    」を実施することで作成したグラフ等を復元することができます。

    補足

    Elasticsearch認証した状態でcurlコマンドを実施する際には-uオプションでユーザー名とパスワードを追加してください。

  4. インデックスを再作成します。

    本手順は、手順「4.1.2.6 インデックスの作成」を実施してください。

  5. Logstashサービスを起動します。

    以下のコマンドを実行し、サービスを起動します。

    • コマンド
      systemctl start logstash
      

    以下のコマンドを実行し、サービスの状態を確認します。

    • コマンド
      systemctl status logstash
      

    出力内容中に以下の内容が表示されることを確認します。

    Active: active (running) 
    
  6. Logstashのログ情報を確認します。

    以下のログファイルの内容を確認し、Logstashサービス起動後の時間帯にエラー出力がないことを確認します。

    <確認ファイルパス>

    /var/log/logstash/logstash-plain.log

12.1.2 Windows版Elasticsearchの場合

データのリセットおよび再収集の手順は以下の通りとなります。

  1. 以下のコマンドを実行し、Logstash サービスを停止します。

    • コマンド
      cd %nssm_home%\win64
      nssm stop Logstashサービス名
      

    以下のコマンドを実行し、サービスの状態を確認します。

    • コマンド
      cd %nssm_home%\win64
      nssm status Logstashサービス名
      

    以下のような出力結果があることを確認します。

    SERVICE_STOPPED
    
  2. Logstashの取り込み履歴を削除します。

    以下のコマンドを実行し、Logstashの取り込み履歴ファイル格納ディレクトリに移動します。

    • コマンド
      cd C:\temp\logstash-8.17.2\logstash\conf
      

    ※上記パスはデフォルト設定先になります。履歴ファイルの格納場所は、以下ファイル内の\"last_run_metadata_path =>\"の設定値をご確認ください。

    • <ディレクトリ>  C:\temp\logstash-8.17.2\logstash-definitions

      ファイル名 説明
      logstash-postgresql.conf 設定ファイル(プロセス管理)
      logstash-postgresql_ci.conf 設定ファイル(構成管理)
      logstash-postgresql-faq.conf 設定ファイル(FAQ)
      logstash-postgresql-filelibrary.conf 設定ファイル(ファイルライブラリ)

      以下のコマンドを実行し、履歴ファイルを削除します。

      • コマンド
        del /Q .logstash_postgresql_*_last_run
        

    以下のコマンドを実行し、Logstashのキューファイル格納ディレクトリに移動します。

    • コマンド
      cd C:\temp\logstash-8.17.2\data
      

    以下のコマンドを実行し、ファイルの情報を確認します。

    • コマンド
      dir
      

    以下の内容が出力されることを確認します。

    例:

    2021/02/09 20:13    <DIR>          dead_letter_queue
    2021/02/09 20:13                36 uuid
    

    キューファイル「dead_letter_queue」とキューファイル「uuid」を削除します。

  3. 以下のコマンドを実行し、現在のインデックス情報を確認します

    • Elasticsearch認証の設定が未実施の場合:

      • コマンド
        curl -XGET "[protocol]://[hostname]:[portnumber]/_aliases?pretty”"
        

      例)Elasticsearch への接続情報でプロトコル[protocol]:http、ホスト名[hostname]:eshost、ポート番号[portnumber]:9200とした場合は、以下のコマンドを実行します。

      • コマンド
        curl -XGET "http://eshost:9200/_aliases?pretty"
        
    • Elasticsearch認証の設定が実施済の場合:

      • コマンド
        curl -XGET "[protocol]://[hostname]:[portnumber]/_aliases?pretty"
        -u [elasticuser]:[elasticpassword]
        

      例)Elasticsearch への接続情報でプロトコル[protocol]:http、ホスト名[hostname]:eshost、ポート番号[portnumber]:9200、認証ユーザー名[elasticuser]:elastic、認証パスワード[elastipassword]:elapwdとした場合は、以下のコマンドを実行します。

      • コマンド
        curl -XGET "http://eshost:9200/_aliases?pretty" –u elastic:elapwd
        

    以下の内容が出力されることを確認します。

    {
        "ssm" : {
            "aliases" : { }
        },
        "ssm_ci" : {
            "aliases" : { }
        },
        "ssm_faq" : {
            "aliases" : { }
        },
        "ssm_filelibrary" : {
            "aliases" : { }
        }
    }
    

    以下のコマンドを実行し、インデックス情報を削除します。

    • Elasticsearch認証の設定が未実施の場合:

      • コマンド
        curl -XDELETE "[protocol]://[hostname]:[portnumber]/ssm?pretty"
        curl -XDELETE "[protocol]://[hostname]:[portnumber]/ssm_ci?pretty"
        curl -XDELETE "[protocol]://[hostname]:[portnumber]/ssm_faq?pretty"
        curl -XDELETE "[protocol]://[hostname]:[portnumber]/ssm_filelibrary?pretty"
        

      例)Elasticsearch への接続情報でプロトコル[protocol] → http、ホスト名[hostname] → eshost、ポート番号[portnumber] → 9200とした場合は、以下のコマンドを実行します。

      • コマンド
        curl -XDELETE "http://eshost:9200/ssm?pretty"
        curl -XDELETE "http://eshost:9200/ssm_ci?pretty"
        curl -XDELETE "http://eshost:9200/ssm_faq?pretty"
        curl -XDELETE "http://eshost:9200/ssm_filelibrary?pretty"
        
    • Elasticsearch認証の設定が実施済の場合:

      • コマンド
        curl -XDELETE "[protocol]://[hostname]:[portnumber]/ssm?pretty" -u [elasticuser]:[elasticpassword]
        curl -XDELETE "[protocol]://[hostname]:[portnumber]/ssm_ci?pretty" -u [elasticuser]:[elasticpassword]
        curl -XDELETE "[protocol]://[hostname]:[portnumber]/ssm_faq?pretty" -u [elasticuser]:[elasticpassword]
        curl -XDELETE "[protocol]://[hostname]:[portnumber]/ssm_filelibrary?pretty" -u [elasticuser]:[elasticpassword]
        

      例)Elasticsearch への接続情報でプロトコル[protocol]:http、ホスト名[hostname]:eshost、ポート番号[portnumber]:9200、認証ユーザー名[elasticuser]:elastic、認証パスワード[elastipassword]:elapwdとした場合は、以下のコマンドを実行します。

      • コマンド
        curl -XDELETE "http://eshost:9200/ssm?pretty"  –u elastic:elapwd
        curl -XDELETE "http://eshost:9200/ssm_ci?pretty"  –u elastic:elapwd
        curl -XDELETE "http://eshost:9200/ssm_faq?pretty"  –u elastic:elapwd
        curl -XDELETE "http://eshost:9200/ssm_filelibrary?pretty"  –u elastic:elapwd
        

    以下の内容が出力されることを確認します。

    {
        "acknowledged" : true
    }
    
  4. インデックスを再作成します

    本手順は、手順「5.2.5 インデックスの作成」を実施してください。

  5. Logstashサービスを起動します。

    以下のコマンドを実行し、サービスを起動します。

    • コマンド
      cd %nssm_home%\win64
      nssm start Logstashサービス名
      

    以下のコマンドを実行し、サービスの状態を確認します。

    • コマンド
      cd %nssm_home%\win64
      nssm status Logstashサービス名
      

    以下のような出力結果があることを確認します。

    SERVICE_RUNNING
    
  6. Logstashのログ情報を確認します。

    以下のログファイルの内容を確認し、Logstashサービス起動後の時間帯にエラー出力がないことを確認します。

    <確認ファイルパス>
    C:\temp\logstash-8.17.2\logs\logstash-plain.log