ja:documentation:03_monitoring:09_log_monitoring

差分

このページの2つのバージョン間の差分を表示します。

この比較画面へのリンク

ja:documentation:03_monitoring:09_log_monitoring [2022/06/11 07:51] – [Elasticsearch システムへのマイグレーション] junichija:documentation:03_monitoring:09_log_monitoring [Unknown date] (現在) – 削除 - 外部編集 (Unknown date) 127.0.0.1
行 1: 行 1:
-====== ログの監視と収集 ====== 
- 
-{{indexmenu_n>9}}  
- 
-[[ja:documentation:start|Pandora FMS ドキュメント一覧に戻る]] 
- 
-===== 概要 ===== 
- 
-{{  :wiki:pfms-log-collection-monitoring.png  }} 
- 
-{{:wiki:icono-modulo-enterprise.png  |Versión Enterprise.}}Log monitoring in Pandora FMS is approached in two different ways: 
- 
-{{:wiki:icono-modulo-enterprise.png  |Enterprise 版}}Pandora FMS におけるログ監視には、以下の 2つの異なる手法があります。 
- 
-  - **モジュールベース**: 非同期監視としの Pandora でログを表現します。ユーザにより事前設定された条件を満たすデータを検出した場合にアラートを関連付けることができます。 ログのモジュール表現では、以下を行うことができます: 
-    - ログの中で正規表現にマッチする数を数えるモジュールの作成 
-    - ログメッセージの行および内容を取得 
-  - **複合表示ベース**: キャプチャしたい複数の発生元のログからすべての情報を 1つのコンソールで表示し、ログが処理されたタイムスタンプを使用して情報を順番に整理できます。 
- 
-バージョン 7.0NG 712 からは、Pandora FMS に、ログ情報を保存するための **ElasticSearch** が組み込まれているため、パフォーマンスが大幅に向上しています。 
- 
-===== 動作の仕組み ===== 
-処理は単純です。 
- 
-{{  :wiki:logsesquema.png?650  }} 
- 
-  * The logs analyzed by the [[:en:documentation:01_understanding:03_glossary#software_agent|software agents]] (**eventlog**  or text files) are forwarded to Pandora Server in RAW form within the [[:en:documentation:01_understanding:03_glossary#data_files_:data_xml|XML]] reporting agent: 
-  * Pandora FMS data server receives the XML agent, which contains information about both monitoring and logs. 
-  * When the DataServer processes XML data, it identifies log information, keeping in the primary database the references about the agent that was reported and the source of the log, automatically sending information to ElasticSearch in order to be stored. 
-  * Pandora FMS stores the data in Elasticsearch indexes generating a daily index for each Pandora FMS instance. 
-  * Pandora FMS server has a maintenance task that deletes indexes in the interval defined by the system admin (90 days by default). 
- 
-  * [[:ja:documentation:01_understanding:03_glossary#ソフトウエアエージェント|ソフトウエアエージェント]]で分析されたログ (**eventlog** またはテキストファイル) は、Pandora サーバへ転送されます。エージェントから送信される [[:ja:documentation:01_understanding:03_glossary#データファイルxml_データ|XML]] に (RAW) データとして含まれます。 
-  * Pandora FMS データサーバは、エージェントから XML を受け取ります。そこには、監視とログの両方の情報が含まれています。 
-  * データサーバが XML データを処理する時に、ログ情報を識別し、報告されたエージェントに関する情報やログのソースをプライマリデータベースに保存し、ログの保存には情報を自動的に ElasticSearch に送信します。 
-  * Pandora FMS はデータを Elasticsearch インデックスに保存し、各 Pandora FMS インスタンスの日次インデックスを生成します。 
-  * Pandora FMS サーバには、システム管理者が定義した間隔(デフォルトでは90日)でインデックスを削除するメンテナンスタスクがあります。 
- 
-===== サーバの必要条件 ===== 
- 
-It is recommended to distribute Pandora, FMS Server and Elasticsearch in independent servers. 
- 
-Pandora FMS サーバと Elasticsearch は別々のサーバに展開することをお勧めします。 
- 
-  * Rocky Linux 8 or RHEL 8. 
-  * At least 4 GB of RAM, although 6 GB of RAM are recommended for each Elasticsearch instance. 
-  * Disable SWAP on the node(s) where Elasticsearch is located. 
-  * At least 2 CPU cores. 
-  * At least 20 GB of disk space for the system. 
-  * At least 50GB of disk space for Elasticsearch data (the amount can be different depending on the amount of data to be stored). Elasticsearch disk usage is very intensive, so the faster the read and write speed, **the better the performance of the environment**. 
-  * Connectivity from Pandora FMS server to Elasticsearch API (port 9200/TCP by default). 
- 
-  * Rocky Linux 8 または RHEL 8。 
-  * 最低 4GB のメモリ、ただし ElasticSearch インスタンスでは、6GB のメモリを推奨します。 
-  * Elastic が動作するサーバでの SWAP の無効化。 
-  * 最低 2 CPUコア。 
-  * 最低 20GB のシステムディスク空き領域。 
-  * 最低 50GB の ElasticSearch データディスク空き領域(保存されるデータの量に応じて、異なる場合があります)。 Elasticsearch のディスク使用量は非常に多いため、読み取りと書き込みの速度が速いほど、**環境のパフォーマンスが向上します**。 
-  * Pandora FMS サーバから、Elasticsearch API (デフォルトポートは 9200/TCP) への接続性。 
- 
-With a single node environment with these characteristics, up to 1 GB of data can be stored daily and stored for the default time of 8 days. 
- 
-上記の最低条件のシングルノード環境では、毎日最大 1 GB のデータを保存し、デフォルトで 8日間保存できます。 
- 
-In the case of requiring greater data resilience and fault tolerance, it will be necessary to configure an Elasticsearch cluster (minimum 3 nodes to guarantee data integrity). When moving to a cluster environment it is also possible to distribute the load among the nodes, doubling (in the case of 3 nodes) the processing capacity of the environment. **A load balancing system will be necessary**  if you want to attack with the //different nodes simultaneously//. 
- 
-より高いデータ復元力とフォールトトレランスが必要な場合は、Elasticsearch クラスターを構成する必要があります(データの整合性を保証するために最低 3つのノード)。 クラスタ環境に移行する場合、ノード間で負荷を分散し、環境の処理能力を 2倍(3ノードの場合)にすることもできます。 //異なるノード//で同時に処理したい場合は**負荷分散システムが必要になります**。 
- 
-===== Elasticsearch のインストールと設定 ===== 
- 
-Elasticsearch official documentation: 
- 
-Elasticsearch の公式ドキュメントは以下にあります。 
- 
-  * [[https://www.elastic.co/guide/en/elasticsearch/reference/current/install-elasticsearch.html|https://www.elastic.co/guide/en/elasticsearch/reference/current/install-elasticsearch.html]] 
- 
-==== インストール ==== 
- 
-For Rocky Linux 8 it is recommended to install using the RPM package, it is a single package that contains everything needed to install the Elasticsearch database. 
- 
-Rocky Linux 8 の場合、RPM パッケージを使用してインストールすることをお勧めします。これは、Elasticsearch データベースのインストールに必要なものすべてを含んだ単一のパッケージです。 
- 
-For download go to [[https://www.elastic.co/downloads/elasticsearch|https://www.elastic.co/downloads/elasticsearch]] and select ''Linux x86_64'' ( AMD® or Intel® 64 bits processors). 
- 
-ダウンロードには、[[https://www.elastic.co/downloads/elasticsearch|https://www.elastic.co/downloads/elasticsearch]] へ行き、''Linux x86_64'' ( AMD® または Intel® 64 ビットプロセッサ) を選択します。 
- 
-Once you have downloaded the package, you must upload it to the server where you will install Eleasticsearch, go to that directory and run with sufficient rights: 
- 
-パッケージをダウンロードしたら、Eleasticsearch をインストールするサーバにアップロードし、そのディレクトリに移動して、必要な権限を持ったユーザで次のように実行します。 
- 
-<code> 
- 
-dnf install ./downloaded_packet.rpm 
- 
-</code> 
- 
-You will get an output similar to: 
- 
-次のような出力が表示されます。 
- 
-{{  :wiki:pfms-rmp_-i_elasticsearch-8.2.0-x86_64.rmp.png  }} 
- 
-To verify that the service was installed correctly you can run the command: 
- 
-サービスが正しくインストールされたことを確認するには、次のコマンドを実行します。 
- 
-<code> 
-systemctl status elasticsearch.service 
- 
-</code> 
- 
-You will get an output similar to: 
- 
-次のような出力が表示されます。 
- 
-{{  :wiki:pfms-systemctl_status_elasticsearch.service-dead.png  }} 
- 
-Note that the Elasticsearch service is inactive. 
- 
-Elasticsearch サービスが無効になっていることに注意してください。 
- 
-==== ノードの設定 ==== 
- 
-<WRAP center round important 60%>\\ 
-You must first edit the configuration file\\ 
-''/etc/elasticsearch/elasticsearch.yml'' \\ 
-**and then start the Elasticsearch service.** \\ 
-</WRAP> 
- 
-<WRAP center round important 60%>\\ 
-最初に、設定ファイル ''/etc/elasticsearch/elasticsearch.yml'' を編集し、**Elasticsearch サービスを起動**する必要があります。 
-</WRAP> 
- 
-This file contains the configuration of all the parameters of the Elasticsearch service, see the official documentation for more information: 
- 
-このファイルには、Elasticsearch サービスのすべてのパラメータ設定が含まれています。詳細については、公式ドキュメントを参照してください。 
- 
-  * [[https://www.elastic.co/guide/en/elasticsearch/reference/current/settings.html|https://www.elastic.co/guide/en/elasticsearch/reference/current/settings.html]] 
- 
-Next, the minimum configurations required to start the service and its use with Pandora FMS will be described. 
- 
-次に、サービスを開始するために必要最小限の設定と、Pandora FMS での使用について説明します。 
- 
-  * Set the port number, data location and location of the event log file: 
- 
-  * ポート番号、データの場所、イベントログファイルの場所を設定します: 
-<code> 
- 
- # ---------------------------------- Network ----------------------------------- 
- # Set a custom port for HTTP: 
- http.port: 9200 
- # ----------------------------------- Paths ------------------------------------ 
- # Path to directory where to store the data (separate multiple locations by a comma): 
- path.data: /var/lib/elastic 
- # Path to log files: 
- path.logs: /var/log/elastic 
- 
-</code> 
- 
-  * Configure ''xpack'': 
- 
-  * ''xpack'' を設定します: 
-<code> 
-xpack.security.enabled: false 
-xpack.security.enrollment.enabled: false 
- 
-</code> 
- 
-{{  :wiki:pfms-eleasctisearch-xpack.security.enabled_false-xpack.security.enrollment.enabled_false.png  }} 
- 
-  * //[[:en:documentation:01_understanding:03_glossary#commenting_out_or_uncommenting_a_parameter|Comment]]// this lines: 
- 
-  * この行を[[:ja:documentation:01_understanding:03_glossary#commenting_out_or_uncommenting_a_parameter|コメントアウト]]します。 
-<code> 
- 
-#http.host: [_local_] 
-#transport.host: [_local_] 
- 
-</code> 
- 
-It will also be necessary //uncomment//  and define the following lines: 
- 
-また、以下の行の //コメントを外し//、次のように定義する必要があります。 
- 
-<code> 
-cluster.name: pandorafms 
-node.name: ${HOSTNAME} 
-network.host: 0.0.0.0 
- 
-</code> 
- 
-**cluster.name** 
- 
-This will be the name of the group or cluster. 
- 
-これは、グループまたはクラスタの名前です。 
- 
-**node.name** 
- 
-To name the node using the ''${HOSTNAME}''  system variable, it will automatically take the name of the host. 
- 
-システムの環境変数 ''${HOSTNAME}'' を使っているので、ホスト名が自動的に利用されます。 
- 
-**network.host** 
- 
-For ''network.host''  value ''0.0.0.0''  let Elasticsearch "hear" in all Network Interface Card (NIC), //set a specific value for use a specifis //NIC//.// 
- 
-''network.host'' に ''0.0.0.0'' を指定すると Elasticsearch は全ネットワークインタフェース(NIC)で待ち受けます。//特定の NIC を指定する場合は、特定の値を指定します。// 
- 
-In case of working with a cluster you need to complete the ''discovery.seed_hosts''  (see "[[:es:quickguides:elasticsearch_cluster|Configuring a cluster of Elasticsearch servers]]" for more information): 
- 
-クラスターを使用する場合は、''discovery.seed_hosts'' を設定する必要があります(詳細については、[[:ja:quickguides:elasticsearch_cluster| Elasticsearch サーバのクラスターの構成]] を参照してください): 
- 
-<code> 
- 
-discover.seed_hosts : ["ip:port", "ip", "ip"] 
- 
-</code> 
- 
-Or (format example): 
- 
-または(フォーマット例): 
- 
-<code> 
- discovery.seed_hosts: 
-  - 192.168.1.10:9300 
-  - 192.168.1.11 
-  - seeds.mydomain.com 
- 
-</code> 
- 
-<WRAP center round info 60%> \\ In the most recent versions of Elasticsearch the memory management of the Java® virtual machine is done automatically and it is recommended to let it be managed this way in production environments, **so it is unnecessary**  to modify the values of the Elasticsearch JVM. \\ </WRAP> 
- 
-<WRAP center round info 60%> \\ Elasticsearch の最新バージョンでは、Java® 仮想マシンのメモリ管理は自動的に行われるため、本番環境ではこれを利用することをお勧めします。したがって、Elasticsearch の JVM の値を変更する**必要はありません**。</WRAP> 
- 
-Once finished, it will be necessary to execute: 
- 
-完了したら、以下を実行します: 
- 
-<code> 
-systemctl start elasticsearch.service 
- 
-</code> 
- 
-Wait a few moments while Elasticsearch starts, be patient. The command to query the status is: 
- 
-Elasticsearch が起動するまでしばらくお待ちください。ステータスを照会するコマンドは次のとおりです。 
- 
-<code> 
-systemctl status elasticsearch.service 
- 
-</code> 
- 
-You will see something similar to this: 
- 
-次のような出力が見られます。 
- 
-{{  :wiki:pfms-systemctl_status_elasticsearch.service.png  }} 
- 
-<WRAP center round tip 60%> If the service fails to start, check the logs located in ''/var/log/elastic/''  (in this case the file ''pandorafms.log''  //or the name given to the node//).</WRAP> 
- 
-<WRAP center round tip 60%> サービスの開始に失敗した場合は、''/var/log/elastic/'' にあるログ(この場合はファイル ''pandorafms.log'' //またはノードに付けられた名前//)を確認してください。</WRAP> 
- 
-To test the installation of Elasticsearch run the following command in a terminal window: 
- 
-Elasticsearch のインストールをテストするには、ターミナルウィンドウで次のコマンドを実行します。 
- 
-<code> 
-curl -q http://{IP}:9200/ 
- 
-</code> 
- 
-Replace ''{IP}''  with the IP address or URL of the installed Elasticsearch. 
- 
-''{IP}'' をインストールされている Elasticsearch の IP アドレスまたは URL に置き換えます。 
- 
-You will receive a response similar to the following: 
- 
-次のような応答が得られます。 
- 
-<code> 
-{ 
-  "name" : "3743885b95f9", 
-  "cluster_name" : "docker-cluster", 
-  "cluster_uuid" : "7oJV9hXqRwOIZVPBRbWIYw", 
-  "version" : { 
-    "number" : "7.6.2", 
-    "build_flavor" : "default", 
-    "build_type" : "docker", 
-    "build_hash" : "ef48eb35cf30adf4db14086e8aabd07ef6fb113f", 
-    "build_date" : "2020-03-26T06:34:37.794943Z", 
-    "build_snapshot" : false, 
-    "lucene_version" : "8.4.0", 
-    "minimum_wire_compatibility_version" : "6.8.0", 
-    "minimum_index_compatibility_version" : "6.0.0-beta1" 
-  }, 
-  "tagline" : "You Know, for Search" 
-} 
- 
-</code> 
- 
-It is recommended to visit the Elasticsearch best practices link for production environments: 
- 
-本番環境に向けては、Elasticsearch のベストプラクティスを参照することをお勧めします。 
- 
-  * [[https://www.elastic.co/guide/en/elasticsearch/reference/current/system-config.html#dev-vs-prod|https://www.elastic.co/guide/en/elasticsearch/reference/current/system-config.html#dev-vs-prod]] 
- 
-=== Elasticsearch クラスタ設定 === 
-  * The minimum size of an Elasticsearch cluster is 3 nodes and it must always grow in odd numbers in order to make use of the //quorum//  system and guarantee data integrity. 
-  * Ensure that you have connectivity between all 3 nodes and that ports 9200 and 9300 are accessible between each and every node. 
- 
-  * Elasticsearch クラスターの最小サイズは 3ノードであり、//quorum// システムを利用してデータの整合性を保証するには、常に奇数で増やす必要があります。 
-  * 3つのノードすべての間で通信が可能であり、各ノード間でポート 9200 および 9300 へアクセスできることを確認してください。 
- 
-<WRAP center round tip 60%>Remember to configure the firewall of each node to allow connection through these port numbers.</WRAP> 
- 
-<WRAP center round tip 60%>これらのポート番号を介した接続を許可するように、各ノードのファイアウォールの設定を忘れないでください。</WRAP> 
- 
-Stop the Elasticsearch service on each and every node: 
- 
-全ノードの Elasticsearch サービスを停止します。 
- 
-<code> 
- 
-systemctl stop elasticsearch.service 
- 
-</code> 
- 
-Modify the following lines in the configuration file ''/etc/elasticsearch/elasticsearch.yml''  : 
- 
-設定ファイル ''/etc/elasticsearch/elasticsearch.yml'' の以下の行を編集します。 
- 
-<code> 
-#discovery.seed_hosts: ["host1", "host2"] 
-#cluster.initial_master_nodes: ["host1", "host2"] 
- 
-</code> 
- 
-//[[:en:documentation:01_understanding:03_glossary#commenting_out_or_uncommenting_a_parameter|Uncomment]]//the lines and add the IP addresses or URLs of each node: 
- 
-該当行を //[[:ja:documentation:01_understanding:03_glossary#パラメータのコメントアウトとアンコメント|コメントアウト]]// し、各ノードの IP アドレスまたは URL を追加します。 
- 
-<code> 
- 
-discovery.seed_hosts: ["host1", "host2", "host3"] 
-cluster.initial_master_nodes: ["host1", "host2", "host3"] 
- 
-</code> 
- 
-Example with IP addresses: 
- 
-IP アドレスでの例: 
- 
-<code> 
-discovery.seed_hosts: ["172.42.42.101", "172.42.42.102", "172.42.42.103"] 
-cluster.initial_master_nodes: ["172.42.42.101", "172.42.42.102", "172.42.42.103"] 
- 
-</code> 
- 
-<WRAP center round important 60%>Make sure that the line ''cluster.initial_master_nodes''  is defined only once in the configuration file, **in some cases the same line appears in two different blocks of the same file.**</WRAP> 
- 
-<WRAP center round important 60%>''cluster.initial_master_nodes'' の行は設定ファイル内で 1回のみ定義されていることを確認してください。**場合によっては、同じ行が同じファイルの異なる 2つの場所に表示されます。**</WRAP> 
- 
-Before starting the service, because the nodes were started for the first time on their own (standalone), the contents of the data folder (by default ''/var/lib/elasticsearch/'') must be deleted in order to start the cluster for the first time. Do this with the command: 
- 
-ノードは初回に単独で(スタンドアロンで)開始されたため、サービスを開始する前にデータフォルダーの内容(デフォルトでは ''/var/lib/elasticsearch/'')を削除する必要があります。 次のコマンドを実行します。 
- 
-<code> 
-rm -rf /var/lib/elasticsearch/* 
- 
-</code> 
- 
-Now it is time to start the services on each and every node. Start and check that they are running with the commands: 
- 
-次に、すべてのノードでサービスを開始します。 次のコマンドで開始し、実行されていることを確認します。 
- 
-<code> 
-systemctl start elasticsearch.service && systemctl status elasticsearch.service 
- 
-</code> 
- 
-You should get an output similar to: 
- 
-次のような出力を得られます。 
- 
-{{  :wiki:pfms-systemctl_status_elasticsearch.service.png  }} 
- 
-Once the services have been started, you must confirm that the 3 nodes are joined to the cluster correctly, so when executing the following command on any of the nodes, the same response should be given: 
- 
-サービスが開始されたら、3つのノードがクラスターに正しく参加していることを確認する必要があります。任意のノードで次のコマンドを実行すると、同じ応答が返されます。 
- 
-<code> 
-curl -XGET http://127.0.0.1:9200/_cat/nodes 
- 
-</code> 
- 
-{{  :wiki:pfms-elasticsearch-curl-x-get-_cat-nodes.png  }} 
- 
-Check again the firewall configuration always taking into account that the nodes should communicate through ports ''9200''  and ''9300''  and that from the PFMS server and the PFMS Web Console should be able to access port ''9200''  as well. With these steps you will have already installed and configured the Elasticsearch cluster to be used as Pandora FMS log storage engine. 
- 
-ノードがポート ''9200'' および ''9300'' を介して通信する必要があることに加えて、Pandora FMS サーバおよび Pandora FMS Web コンソールからポート ''9200'' へアクセスできる必要があることを常に考慮してファイアウォールの設定を再度確認してください。ここまでの設定により、Pandora FMS ログストレージエンジンとして使用される Elasticsearch クラスターの準備が完了です。 
- 
-===== データモデルとテンプレート ===== 
- 
-Before putting into production an environment, either a single node or a data cluster, it is recommended to apply the corresponding configurations to this node or cluster according to its use. In the case of the indexes generated by **Pandora FMS**, the most effective way to do it is defining a template to define the configuration of the fields and the stored data. 
- 
-本番環境に導入する前に、用途に応じて、単一ノードまたはデータクラスターのいずれかの環境に応じて対応する設定をあらかじめ実施することをお勧めします。 **Pandora FMS** によって生成されるインデックスの場合、それを行う最も簡単な方法は、フィールドと保存するデータの設定を定義するためのテンプレートを定義することです。 
- 
-<WRAP center round important 60%> 
-テンプレートは、インデックス作成時にのみ適用される設定です。テンプレートを変更しても、既存のインデックスには影響しません。 
-</WRAP> 
- 
-**基本テンプレート** を作成するには、フィールドを定義するだけです。 
- 
-<code> 
- { 
-  "index_patterns": ["pandorafms*"], 
-  "settings": { 
-    "number_of_shards": 1, 
-    "auto_expand_replicas" : "0-1", 
-    "number_of_replicas" : "0" 
-  }, 
- "mappings" : { 
-      "properties" : { 
-        "agent_id" : { 
-          "type" : "long", 
-          "fields" : { 
-            "keyword" : { 
-              "type" : "keyword", 
-              "ignore_above" : 256 
-            } 
-          } 
-        }, 
-        "group_id" : { 
-          "type" : "long", 
-          "fields" : { 
-            "keyword" : { 
-              "type" : "keyword", 
-              "ignore_above" : 256 
-            } 
-          } 
-        }, 
-        "group_name" : { 
-          "type" : "text", 
-          "fields" : { 
-            "keyword" : { 
-              "type" : "keyword", 
-              "ignore_above" : 256 
-            } 
-          } 
-        }, 
-        "logcontent" : { 
-          "type" : "text", 
-          "fields" : { 
-            "keyword" : { 
-              "type" : "keyword", 
-              "ignore_above" : 256 
-            } 
-          } 
-        }, 
-        "source_id" : { 
-          "type" : "text", 
-          "fields" : { 
-            "keyword" : { 
-              "type" : "keyword", 
-              "ignore_above" : 256 
-            } 
-          } 
-        }, 
-        "suid" : { 
-          "type" : "text", 
-          "fields" : { 
-            "keyword" : { 
-              "type" : "keyword", 
-              "ignore_above" : 256 
-            } 
-          } 
-        }, 
-        "type" : { 
-          "type" : "text", 
-          "fields" : { 
-            "keyword" : { 
-              "type" : "keyword", 
-              "ignore_above" : 256 
-            } 
-          } 
-        }, 
-        "utimestamp" : { 
-          "type" : "long" 
-        } 
-      } 
-    } 
-  } 
- } 
-</code> 
- 
-Through the Elasticsearch interface in Pandora FMS (**Admin tools** → **Elasticsearch Interface**) and using the native Elasticsearch command you can upload such template. 
- 
-Pandora FMS の Elasticsearch インターフェース(**管理ツール(Admin tools)** → ** Elasticsearch インターフェース(Elasticsearch Interface)**)を介して、ネイティブの Elasticsearch コマンドを使用し、テンプレートをアップロードできます。 
- 
-We can perform these operations through the Elastic Search interface in Pandora FMS using the native Elastics Search commands. 
- 
-これらの操作は、ネイティブの ElasticsSearch コマンドを使用してPandora FMS の ElasticSearch インターフェイスから実行できます。 
- 
-  * **PUT _template/<template_name>**: for this example ''PUT _template/pandorafms''  . 
- 
-  * **PUT _template/<template_name>**: この例では ''PUT _template/pandorafms'' 
-{{  :wiki:pfms-elasticsearch_interface_put_template.png  }} 
- 
-You will also be able to consult the templates through the same Pandora FMS interface: 
- 
-同じ Pandora FMS インターフェースを介してテンプレートを参照することもできます。 
- 
-  * **GET _template/<template_name>**: for this example ''GET _template/pandorafms''  . 
- 
-  * **GET _template/<template_name>**: この例では ''GET _template/pandorafms'' 
- 
-{{  :wiki:getinterface.png  }} 
- 
-==== マルチノードテンプレート ==== 
- 
-To define a **multinode template**  you must take into account the following information: 
- 
-**マルチノードテンプレート**を定義するには、考慮しなければならないことがいくつかあります。 
- 
-  * When configuring the template (JSON format), **you need to configure as many searches as you have nodes**, however to correctly configure the replicas **you must subtract 1 from the number of nodes in the environment.** 
- 
-  * テンプレート(JSON)の設定を行うときは、**ノードと同じ数の検索を設定する** ことを考慮に入れる必要がありますが、正しく設定するには、環境に実際に存在する **レプリカの数から 1を引く** 必要があります。 
- 
-For example, in a Pandora FMS environment with Elasticsearch with 3 configured nodes, when you modify the ''number_of_search''  and ''number_of_replicas''  fields it should look like this: 
- 
-例えば、3つのノードを設定した Elasticsearch を Pandora FMS 環境で使用する場合、''number_of_search'' および ''number_of_replicas'' フィールドを次のように変更します。 
- 
-<code> 
-{ 
- "index_patterns": ["pandorafms*"], 
- "settings": { 
-   "number_of_shards": 3, 
-   "auto_expand_replicas" : "0-1", 
-   "number_of_replicas" : "2" 
- }, 
- 
-</code> 
- 
-<WRAP center round info 75%> \\ This is a very basic definition, in order to correctly define the sizing of the Elasticsearch environment it is advisable to take into account the factors described in this article:</WRAP> 
- 
-<WRAP center round info 75%> \\ これは非常に基本的な定義です。Elasticsearch 環境のサイズを正しく定義するには、以下で説明されている要素を考慮に入れることをお勧めします。</WRAP> 
- 
-  * [[https://www.elastic.co/blog/how-many-shards-should-i-have-in-my-elasticsearch-cluster|https://www.elastic.co/blog/how-many-shards-should-i-have-in-my-elasticsearch-cluster]] 
- 
-From the command line you can list the templates of the environment by executing: 
- 
-コマンドラインから以下を実行して環境のテンプレートを一覧表示できます。 
- 
-<code> 
- 
-curl -X GET "localhost:9200/_cat/templates/*?v=true&s=name&pretty" 
- 
-</code> 
- 
-You can also view the details of a template, for example the one we have created for pandorafms by running it: 
- 
-テンプレートの詳細を表示することもできます。たとえば、以下を実行すると pandorafms 用に作成したテンプレートを表示できます。 
- 
-<code> 
-curl -X GET "localhost:9200/_template/pandorafms*?pretty" 
- 
-</code> 
- 
-which will return in JSON format the configuration you have defined. 
- 
-定義した設定を JSON 形式で返します。 
- 
-You can perform these operations through the Elasticsearch interface in Pandora FMS using the native Elasticsearch commands. 
- 
-これらの操作は、ネイティブの Elasticsearch コマンドを使用して、Pandora FMS の Elasticsearch インターフェースから実行できます。 
- 
-  * **PUT _template/<template_name> {json_data}**: allows you to enter the data of the template to be created. 
-  * **GET _template/><template_name>**: allows you to display the created template. 
- 
-  * **PUT _template/<template_name> {json_data}**: 作成するテンプレートのデータを入力できます。 
-  * **GET _template/<template_name>**: 作成したテンプレートを表示できます。 
- 
-{{  :wiki:getinterface.png  }} 
- 
-===== 推奨事項 ===== 
- 
-**Elasticsearch のログローテーション** 
- 
-**重要:** Elasticsearch のログが肥大化しないように、/etc/logrotate.d でログローテーションのエントリーを作成することをお勧めします。 
- 
-<code> 
- cat > /etc/logrotate.d/elastic <<EOF 
- /var/log/elastic/elaticsearch.log { 
-        weekly 
-        missingok 
-        size 300000 
-        rotate 3 
-        maxage 90 
-        compress 
-        notifempty 
-        copytruncate 
- } 
- EOF 
-</code> 
- 
-**インデックスの削除** 
- 
-You may check at any time the [[https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-indices.html|list of indexes]] and their size by launching a **cURL** petition against its ElasticSearch server: 
- 
-ElasticSearch サーバに対して curl でアクセスすることにより、いつでも[[https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-indices.html|インデックスの一覧]]と大きさを確認することができます。 
- 
-<code> 
- 
-curl -q http://elastic:9200/_cat/indices? 
- 
-</code> 
- 
-ここで、''elastic'' はサーバの IP です。 
- 
-インデックスを削除するには、DELETE コマンドを実行します。 
- 
-<code> 
-curl -q -XDELETE http://elastic:9200/{index-name} 
- 
-</code> 
- 
-ここで ''elastic'' はサーバの IP で、"{index-name}" は上のコマンドの出力ファイルです。これにより、削除されたインデックスによって使用されていたスペースが解放されます。 
- 
-===== Pandora FMS Syslog サーバ ===== 
-<WRAP center round tip 60%> 
-{{wiki:icono-modulo-enterprise.png |Enterprise 版}}バージョン NG 717 以上 
-</WRAP> 
- 
-このコンポーネントにより、Pandora はマシンの [[wp>Syslog|syslog]] を分析できます。Syslog のコンテンツを分析し、ElasticSearch サーバに格納することができます。 
- 
-SyslogServer の主な利点としては、ログの統合を補完することにあります。Linux および UNIX 環境の SYSLOG 出力をもとにして、SyslogServer では、1つの共通ポイント(Pandora FMS コンソールのログビューア)で、発信元ごとに個別のログを参照したり、検索したりすることができます。 
- 
-Syslog のインストールは、クライアントとサーバの両方に次のコマンドで行います。 
- 
-  yum install rsyslog 
- 
-対象のコンピューターに Syslog をインストールしたら、設定ファイル ''/etc/rsyslog.conf'' を編集して TCP および UDP 接続を有効にする必要があることに注意してください。 
- 
-<code> 
- (...) 
-  
- # Provides UDP syslog reception 
- $ModLoad imudp 
- $UDPServerRun 514 
-  
- # Provides TCP syslog reception 
- $ModLoad imtcp 
- $InputTCPServerRun 514 
-  
- (...) 
-</code> 
- 
-調整を行ったら、rsyslog サービスを再起動します。 
- 
-サービスが再起動したら、ポート 514 が開いているか確認します。 
- 
-  netstat -ltnp 
- 
-rsyslog 設定に関する詳細は、[[https://www.rsyslog.com/|公式サイト]] を参照してください。 
- 
-Syslog サーバにログを送信するようにクライアントを設定します。そのためには、''/etc/rsyslog.conf'' にあるクライアント rsyslog 設定ファイルにて、リモートホストの設定をする行を見つけて有効にします。  
-<code> 
-.* @@remote-host:514 
-</code> 
-<WRAP center round tip 60%> 
-ログ送信により、クライアント名を持つコンテナエージェントが生成されるため、エージェントの重複を回避するために、クライアントのホスト名と一致する "別名" を持つエージェントを作成することをお勧めします。 
-</WRAP> 
- 
-この機能を有効化するには、''pandora_server.conf'' で以下の設定を有効にするだけです。 
- 
-<code> 
- # Enable (1) or disable (0) the Pandora FMS Syslog Server 
- #  (PANDORA FMS ENTERPRISE ONLY). 
- syslogserver 1 
-  
- # Full path to syslog's output file (PANDORA FMS ENTERPRISE ONLY). 
- syslog_file /var/log/messages 
-  
- # Number of threads for the Syslog Server 
- #  (PANDORA FMS ENTERPRISE ONLY). 
- syslog_threads 2 
-  
- # Maximum number of lines queued by the Syslog Server' 
- #   producer on each run (PANDORA FMS ENTERPRISE ONLY). 
- syslog_max 65535 
-</code> 
- 
- 
-**syslogserver** 
- 
-ローカルの SYSLOG 分析エンジンの有効化(1)または無効化(0)を設定します。 
- 
-**syslog_file** 
- 
-SYSLOG ファイルの場所です。 
- 
-**syslog_threads** 
- 
-SyslogServer のデータ処理に使う最大スレッド数です。 
- 
-**syslog_max** 
- 
-SyslogServer が処理する最大ウインドウサイズです。一度の実行で処理する最大の SYSLOG エントリー数です。 
- 
-It is the maximum processing window for SyslogServer, it will be the maximum number of SYSLOG entries that will be processed in each iteration. 
- 
-これは SyslogServer の最大処理ウィンドウであり、一度に処理される SYSLOG エントリの最大数になります。 
- 
-<WRAP center round important 60%>You will need an ElasticSearch server enabled and configured; please review the preceding points for how to work with it.</WRAP> 
- 
-<WRAP center round important 60%>ElasticSearch サーバを有効化し設定する必要があります。使用方法については、前述の内容を確認してください。</WRAP> 
- 
-<WRAP center round tip 60%>Remember: It is necessary to modify the configuration of your device so that logs are sent to Pandora FMS server. </WRAP> 
- 
-<WRAP center round tip 60%>ログが Pandora FMS サーバに送信されるように、デバイスの設定を変更する必要があります。</WRAP> 
- 
-===== Elasticsearch システムへのマイグレーション ===== 
- 
-<WRAP center round info 60%> \\ Version 712 or earlier. You will then need to upgrade to the current version, see "[[:en:documentation:02_installation:02_anexo_upgrade|PFMS Upgrade]]" for more information. \\ 
-</WRAP> 
- 
-<WRAP center round info 60%> \\ バージョン 712 またはそれ以前。最新のバージョンにアップグレードする必要があります。詳細については、[[:ja:documentation:02_installation:02_anexo_upgrade|Pandora FMS アップグレード]] を参照してください。 
-</WRAP> 
- 
-ログの新たなストレージシステムを設定後、以前から Pandora に保存されているデータを新たなシステムへマイグレートできます。 
- 
-新たなシステムへマイグレートするには、/usr/share/pandora_server/util/ 以下にある次のスクリプトを実行します。 
- 
-<code> 
- # 7.0NG 712 より前のログデータを、7.0NG 712 以降にマイグレート 
- /usr/share/pandora_server/util/pandora_migrate_logs.pl /etc/pandora/pandora_server.conf 
-</code> 
- 
-===== コンソールの設定 ===== 
- 
-To enable the log system display, enable the following configuration  (**Setup** → **Setup** → **Enterprise**): 
- 
-ログの表示を有効化するには、次の設定を有効化する必要があります。(**セットアップ(Setup)** → **セットアップ(Setup)** → **Enterprise**) 
- 
-{{  :wiki:pfms-setup-setup-enterprise-activate_log_collector.png  }} 
- 
- 
-**設定(Configuration)** > **ログ収集(Log Collector)** タブで、ログビューワの動作を設定できます。 
- 
-{{  :wiki:pfms-setup-setup-log_collector.png  }} 
- 
-この画面では以下の設定ができます。 
- 
-  * Elasticsearch サーバの IP または FQDN アドレス 
- 
-  * Elasticsearch サービスのポート 
- 
-  * **表示されるログの数(Number of logs being shown)**:コンソール応答の高速化のため、レコードの動的読み込みが追加されています。これを利用するには、ページの一番下へスクロールします。すると、次のレコードが読み込まれます。これらのグループのサイズは、グループあたりのレコード数としてこのフィールドに設定できます。 
- 
-  * **削除する日数(Days to purge)**: システムのサイズを保持するために、ログ情報を保存する最大日数を定義できます。それを超えると、Pandora FMS のクリーニング処理により自動的に削除されます。 
- 
-===== Elasticsearch インタフェース ===== 
-<WRAP center round tip 60%> 
-{{wiki:icono-modulo-enterprise.png |Enterprise 版}}バージョン NG 747 以上 
-</WRAP> 
- 
-{{  :wiki:es_interface.png?800  }} 
- 
-デフォルトの設定では、Pandora は 1日あたりのインデックスを生成します。これは、何かを検索する際のフラグメント化の役割を持ちます。検索時に Elastic がフラグメントの場所を認識できるようにします。 
- 
-この検索をデフォルトで最適化するには、Elastics が検索ごとにインデックスを生成し、**Elastics ノードと同じ数の検索を環境内で設定する必要があります**。 
- 
-これらの検索とレプリカは、Pandora が自動的に生成するインデックスの作成時に設定されるため、この設定を変更するには、テンプレートを使用する必要があります。 
- 
- 
- 
-===== 表示と検索 ===== 
-ログ収集のツールに関して、私たちは主に 2つのことに興味があります。日時やデータソース、キーワードによるフィルタリングをしての情報の検索と、時間単位ごとに発生する情報の参照です。この例では、直近 1時間のすべてのデータソースからのログメッセージを見てみます。**Search**, **Start date** および **End date** を見てください。 
- 
-{{  :wiki:logsvistanew.png?700 |拡大するにはクリックしてください}} 
-//時間経過による発生表示// 
- 
-最も重要で便利なフィールドは、**検索** テキストボックスに入力する検索文字列と、使用可能な 3つの **検索モード** です。  
- 
-**完全一致**  
-文字検索で、//log// は完全マッチします。 
- 
-{{  :wiki:logsvistanew2.png?700  ||拡大するにはクリックしてください}} 
- 
-**全単語**  
-単一の //ログ// の行の順序に関係なく、指定された単語(各単語はスペースで区切られることに注意してください)を //すべて// 含むかを検索します 
- 
-{{  :wiki:logsvistanew4.png?700  |拡大するにはクリックしてください}} 
- 
-**任意の単語**  
-順番は関係なく、指定した単語の //いくつか// が含んでいるかを検索します。 
- 
-{{  :wiki:logsvistanew5.png?800x1052  }} 
- 
-フィルタされたコンテンツのコンテキストを表示するオプションがチェックされている場合、結果は、検索に関連する他のログ行に関する情報を含む状況の概要になります。 
- 
-==== 表示と高度な検索 ==== 
-<WRAP center round tip 60%> 
-{{wiki:icono-modulo-enterprise.png |Enterprise 版}}バージョン NG 727 以上 
-</WRAP> 
- 
-この機能により、ログエントリをグラフに変換し、 **データキャプチャテンプレート** に従って情報を整理できます。 
- 
-これらのデータキャプチャテンプレートは基本的に正規表現と識別子であり、データソースを分析してグラフとして表示できます。 
- 
-高度なオプションへアクセスするには、//高度なオプション(Advanced options)// をクリックします。表示形式を選択できるフォームが表示されます。 
- 
-  * ログエントリーの表示 (プレーンテキスト) 
-  * ロググラフの表示 
- 
-{{  :wiki:graph_log.png?800  }} 
- 
- 
-//ロググラフ表示// オプションでは、キャプチャテンプレートを選択できます。 
- 
-//Apache log model// テンプレートは、デフォルトで、標準形式の Apache ログ ([[https://httpd.apache.org/docs/2.4/en/logs.html#access-log|access_log]]) をパースし、時間応答比較グラフの取得、訪問サイトと応答コードによるソートができます。 
- 
-{{  :wiki:graph_log2.png?800  }} 
- 
- 
-編集ボタン{{wiki:edit_icon.png}}を押すと、選択したキャプチャテンプレートを編集できます。作成ボタン{{wiki:new_icon.png}}では、新たなキャプチャテンプレートを追加できます。 
- 
-{{  :wiki:graph_log3.png  }} 
- 
- 
- 
- 
-このフォームでは、以下を選択できます。 
- 
-**キャプチャ正規表現(Capture regexp)** 
- 
- データをキャプチャするための正規表現です。取得する各フィールドは、カッコでくくります。 //(キャプチャする内容)// 
-**フィールド(Fields)** 
- 
-正規表現を介してキャプチャされる順番です。 結果は、アンダースコアの間に書かれていない名前のキーフィールドの連結によってソートされます。  
- 
-<code> 
- 
-key, _value_ 
- 
-</code> 
- 
- 
-<code> 
-key,key2,_value_ 
- 
-</code> 
- 
- 
-<code> 
-key1,_value_,key2 
- 
-</code> 
- 
- 
-//注意:// value フィールドが指定されていない場合、自動的に一致する正規表現の数になります。 
- 
-//注意 2:// 1つだけ //value// カラムが指定されている場合は、累積値(デフォルトではパフォーマンス)を表すか、チェックボックスをオンにして平均を表すかを選択できます。 
- 
-//例// 
- 
-以下のフォーマットのログからエントリを取得するとします。 
- 
-<code> 
- Sep 19 12:05:01 nova systemd: Starting Session 6132 of user root. 
- Sep 19 12:05:01 nova systemd: Starting Session 6131 of user root. 
- 
-</code> 
- 
- 
-ユーザのログイン数をカウントするには、次のようにします。 
- 
-正規表現: 
- 
-<code> 
-Starting Session \d+ of user (.*?)\. 
- 
-</code> 
- 
- 
-フィールド: 
- 
-<code> 
-username 
- 
-</code> 
- 
- 
-このキャプチャテンプレートは、選択した時間間隔におけるユーザのログイン数を返します。 
- 
-{{  :wiki:graph_log4.png  }} 
- 
- 
-===== エージェント設定 ===== 
-ログ収集は、Windows および Unux (LInux®, MacOS X®, Solaris®, HP-UX®, AIX®, BSD® など) エージェント双方で実行されます。Windows エージェントの場合、イベントビューワモジュールで同様のフィルタを用いることにより、Windows イベントビューワから情報を取得することもできます。 
- 
-Windows と Unix でのログ情報収集の例をみてみます。 
- 
-==== Windows の場合 ==== 
-バージョン 750 以降、このアクションは、詳細オプションを有効化することにより、エージェントプラグインを介して実行できます。 
- 
-以下に示すタイプの処理を実行できるようになります。 
- 
-**Logchannel module** 
- 
-<code> 
- module_begin 
- module_name MyEvent 
- module_type log 
- module_logchannel 
- module_source <logChannel> 
- module_eventtype <event_type/level> 
- module_eventcode <event_id> 
- module_pattern <text substring to match> 
- module_description <description> 
- module_end 
-</code> 
- 
-**Logevent module** 
- 
-<code> 
- module_begin 
- module_name Eventlog_System 
- module_type log 
- module_logevent 
- module_source System 
- module_end  
-</code> 
- 
-**Regexp module** 
- 
-<code> 
- module_begin 
- module_name PandoraAgent_log 
- module_type log 
- module_regexp C:\archivos de programa\pandora_agent\pandora_agent.log 
- module_description This module will return all lines from the specified logfile 
- module_pattern .* 
- module_end 
-</code> 
- 
-ログタイプモジュールの詳細説明については、次の章で確認できます。[[ja:documentation:02_installation:05_configuration_agents|特定のディレクティブ]] 
- 
-  module_type log  
- 
-この種のタグ module_type logを 定義すると、データベースには保存されませんが、ログコレクターに送信されていることを示します。このタイプのデータを持つモジュールは、有効になっている場合はコレクターに送信され、有効になっていない場合は情報が破棄されます。 
- 
-**注意**: この書式は、バージョン 5.0 以上で有効です。Enterprise 版をアップデートした状態にしているか確認してください。 
- 
-==== Unix システム ==== 
-エージェントバージョン 5.0 では、次の書式を使います。 
- 
-<code> 
-module_plugin grep_log_module /var/log/messages Syslog \.\* 
- 
-</code> 
- 
-ログパースプラグイン(grep_log)と同じように、grep_log_module プラグインは、処理した情報をログファイルのソースとして "syslog" という名前でログ収集に送信します。どういったパターンの行を送信するかまたはしないかは、\.\* といった正規表現を利用します(この例では全て)。 
- 
-===== エージェント表示でのログソース ===== 
- 
-From Pandora FMS version 749 onwards, a box called **Log sources status**  has been added to the Agent View, where the date of the last log update by that agent will appear. By clicking on the **Review**  magnifying glass icon, you will be redirected to the **Log Viewer**  view filtered by that log. 
- 
-Pandora FMS バージョン 749 以降、**ログソース状態** と呼ばれるボックスがエージェント表示に追加され、そのエージェントによる最後のログ更新の日付が表示されます。虫眼鏡のアイコンをクリックすると、そのログにフィルタした**ログビューアー**表示にリダイレクトされます。 
- 
-{{  :wiki:agent_view_log.png?800  }} 
- 
-[[ja:documentation:start|Pandora FMS ドキュメント一覧に戻る]] 
- 
  
  • ja/documentation/03_monitoring/09_log_monitoring.1654933890.txt.gz
  • 最終更新: 2022/06/11 07:51
  • by junichi