教程集 www.jiaochengji.com
教程集 >  Golang编程  >  golang教程  >  正文 centos7使用基础教程_如何在CentOS 7上使用Metricbeat收集基础结构指标

centos7使用基础教程_如何在CentOS 7上使用Metricbeat收集基础结构指标

发布时间:2022-03-10   编辑:jiaochengji.com
教程集为您提供centos7使用基础教程,如何在CentOS 7上使用Metricbeat收集基础结构指标等资源,欢迎您收藏本站,我们将为您提供最新的centos7使用基础教程,如何在CentOS 7上使用Metricbeat收集基础结构指标资源

centos7使用基础教程

<em>The author selected the Computer History Museum to receive a donation as part of the Write for DOnations program.</em>

<em>作者选择“ 计算机历史博物馆”作为“ Write for DOnations”计划的一部分接受捐赠。</em>

<h3 id="introduction"> 介绍 <span style="font-weight: bold;">(</span>Introduction<span style="font-weight: bold;">)</span></h3>

Metricbeat, which is one of several Beats that helps send various types of server data to an Elastic Stack server, is a lightweight data shipper that, once installed on your servers, periodically collects system-wide and per-process CPU and memory statistics and sends the data directly to your Elasticsearch deployment. This shipper replaced the earlier Topbeat in version 5.0 of the Elastic Stack.

Metricbeat是帮助将各种类型的服务器数据发送到Elastic Stack服务器的多个Beats之一,它是一种轻量级的数据发送程序,一旦安装在服务器上,便会定期收集系统范围以及每个进程的CPU和内存统计信息并发送数据直接发送到您的Elasticsearch部署。 该托运人替换了Elastic Stack 5.0版中的早期Topbeat 。

Other Beats currently available from Elastic are:

Elastic可用的其他节拍有:

<ul><li>

Filebeat: collects and ships log files.

Filebeat :收集并发送日志文件。

</li><li>

Packetbeat: collects and analyzes network data.

Packetbeat :收集和分析网络数据。

</li><li>

Winlogbeat: collects Windows event logs.

Winlogbeat :收集Windows事件日志。

</li><li>

Auditbeat: collects Linux audit framework data and monitors file integrity.

Auditbeat :收集Linux审核框架数据并监视文件完整性。

</li><li>

Heartbeat: monitors services for their availability with active probing.

心跳 :通过主动探测监视服务的可用性。

</li></ul>

In this tutorial, you will use Metricbeat to forward local system metrics like CPU/memory/disk usage and network utilization from a CentOS 7 server to another server of the same kind with the Elastic Stack installed. With this shipper, you will gather the basic metrics that you need to get the current state of your server.

在本教程中,您将使用Metricbeat将本地系统指标(例如CPU /内存/磁盘使用率和网络利用率)从CentOS 7服务器转发到另一台安装了Elastic Stack的同类服务器。 使用此托运人,您将收集获取服务器当前状态所需的基本指标。

<h2 id="prerequisites"> 先决条件 <span style="font-weight: bold;">(</span>Prerequisites<span style="font-weight: bold;">)</span></h2>

To follow this tutorial, you will need:

要遵循本教程,您将需要:

<ul><li>

Two CentOS 7 servers set up by following the Initial Server Setup with CentOS 7 guide, including a non-root user with sudo privileges and a firewall set up with <code>firewalld</code>. To set up <code>firewalld</code>, follow the “Configuring a Basic Firewall” section of the Additional Recommended Steps for New CentOS 7 Servers tutorial. On one server, you will download the Elastic Stack; this tutorial will refer to this as the “Elastic Stack server.” The Elastic Stack server, which in this tutorial will have 4GB of RAM and 2 CPUs, will monitor your second server. This second server will be referred to as the “second CentOS server.”

通过遵循“ 使用CentOS 7进行初始服务器设置”指南来设置两台CentOS 7服务器,其中包括具有sudo特权的非root用户和使用firewalld设置的<code>firewalld</code> 。 要设置<code>firewalld</code> ,请遵循“ 针对新CentOS 7服务器的其他推荐步骤”教程的“配置基本防火墙”部分。 在一台服务器上,您将下载Elastic Stack; 本教程将其称为“弹性堆栈服务器”。 在本教程中将具有4GB RAM和2个CPU的Elastic Stack服务器将监视您的第二台服务器。 该第二台服务器将被称为“第二台CentOS服务器”。

</li><li>

The Elastic Stack installed on the Elastic Stack server by following the tutorial How To Install Elasticsearch, Logstash, and Kibana (Elastic Stack) on CentOS 7.

通过遵循如何在CentOS 7上安装Elasticsearch,Logstash和Kibana(Elastic Stack)教程,将Elastic Stack安装在Elastic Stack服务器上 。

</li></ul>

Note: When installing the Elastic Stack, you must use the same version across the entire stack. In this tutorial, you will use the latest versions of the entire stack, which are, at the time of this writing, Elasticsearch 6.7.0, Kibana 6.7.0, Logstash 6.7.0, and Metricbeat 6.7.0.

注意 :安装弹性堆栈时,必须在整个堆栈中使用相同的版本。 在本教程中,您将使用整个堆栈的最新版本,在撰写本文时,它们是Elasticsearch 6.7.0,Kibana 6.7.0,Logstash 6.7.0和Metricbeat 6.7.0。

<h2 id="step-1-—-configuring-elasticsearch-to-listen-for-traffic-on-an-external-ip"> 步骤1 —配置Elasticsearch以侦听外部IP上的流量 <span style="font-weight: bold;">(</span>Step 1 — Configuring Elasticsearch to Listen for Traffic on an External IP<span style="font-weight: bold;">)</span></h2>

The tutorial How To Install Elasticsearch, Logstash, and Kibana (Elastic Stack) on CentOS 7 restricted Elasticsearch access to the <code>localhost</code> only. In practice, this is rare, since you will often need to monitor many hosts. In this step, you will configure the Elastic Stack components to interact with the external IP address.

本教程如何在CentOS 7上安装Elasticsearch,Logstash和Kibana(弹性堆栈)限制了Elasticsearch仅对<code>localhost</code>访问。 实际上,这种情况很少见,因为您经常需要监视许多主机。 在此步骤中,您将配置Elastic Stack组件以与外部IP地址交互。

Log in to your Elastic Stack server as your non-root user:

以非root用户身份登录到Elastic Stack服务器:

<ul><li>

ssh sammy@Elastic_Stack_server_ip

ssh sammy @ Elastic_Stack_server_ip

</li></ul>

Use your preferred text editor to edit Elasticsearch’s main configuration file, <code>elasticsearch.yml</code>. This tutorial will use <code>vi</code>:

使用您喜欢的文本编辑器来编辑Elasticsearch的主要配置文件<code>elasticsearch.yml</code> 。 本教程将使用<code>vi</code> :

<ul><li class="line">sudo vi /etc/elasticsearch/elasticsearch.yml

须藤vi /etc/elasticsearch/elasticsearch.yml </li></ul>

Find the following section and modify it so that Elasticsearch listens on all interfaces. Enter insert mode by pressing <code>i</code>, then add the following highlighted item:

找到以下部分并进行修改,以使Elasticsearch侦听所有接口。 按下<code>i</code>进入插入模式,然后添加以下突出显示的项目:

/etc/elasticsearch/elasticsearch.yml
/etc/elasticsearch/elasticsearch.yml
<pre class="has"><code>... network.host: 0.0.0.0 ...</code></pre>

The address <code>0.0.0.0</code> is assigned specific meanings in a number of contexts. In this case, <code>0.0.0.0</code> means “any IPv4 address at all.”

在许多上下文中,地址<code>0.0.0.0</code>被分配了特定的含义。 在这种情况下, <code>0.0.0.0</code>表示“根本没有任何IPv4地址”。

When you’re finished, press <code>ESC</code> to leave insert mode, then <code>:wq</code> and <code>ENTER</code> to save and exit the file. To learn more about the text editor vi and its successor Vim, check out our Installing and Using the Vim Text Editor on a Cloud Server tutorial. After you have saved and exited the file, restart the Elasticsearch service with <code>systemctl</code> to apply the new settings:

完成后,按<code>ESC</code>退出插入模式,然后按<code>:wq</code>和<code>ENTER</code>保存并退出文件。 要了解有关文本编辑器vi及其后续版本Vim的更多信息,请查看Cloud Server教程中的“ 安装和使用Vim文本编辑器” 。 保存并退出文件后,使用<code>systemctl</code>重新启动Elasticsearch服务以应用新设置:

<ul><li class="line">sudo systemctl restart elasticsearch

sudo systemctl重新启动elasticsearch </li></ul>

Now, allow access to the Elasticsearch port from your second CentOS server. In order to configure access coming from specific IP addresses or subnets, use the <em>rich rule</em> functionality of <code>firewalld</code>:

现在,允许从第二台CentOS服务器访问Elasticsearch端口。 为了配置来自特定IP地址或子网的访问,请使用<code>firewalld</code>的<em>丰富规则</em>功能:

<ul><li>

sudo firewall-cmd --permanent --zone=public --add-rich-rule='rule family="ipv4" source address="second_centos_server_ip/32" port protocol="tcp" port="9200" accept'

sudo firewall-cmd-永久--zone = public --add-rich-rule ='规则族=“ ipv4”源地址=“ second_centos_server_ip / 32”端口协议=“ tcp”端口=“ 9200”接受“

</li></ul>

Rich rules allow you to create more complex and customizable <code>firewalld</code> rules to gain greater control over your firewall. In this command, you are adding a rule that accepts <code>ipv4</code> traffic from the <code>source</code>, which you have set as the IP address of the second CentOS server, to <code>port</code> <code>9200</code> of your Elastic Stack server.

丰富的规则允许您创建更复杂和可自定义的<code>firewalld</code>规则,以更好地控制防火墙。 在此命令中,您将添加一条规则,该规则接受来自<code>source</code> <code>ipv4</code>流量(已设置为第二个CentOS服务器的IP地址)到您的Elastic Stack服务器的<code>port</code> <code>9200</code> 。

Next, reload <code>firewalld</code> to activate the new rule:

接下来,重新加载<code>firewalld</code>以激活新规则:

<ul><li class="line">sudo firewall-cmd --reload

sudo firewall-cmd-重新加载 </li></ul>

Repeat these commands for each of your servers if you have more than two. If your servers are on the same network, you can allow access using one rule for all hosts on the network. To do this, you need to replace the <code>/32</code> after the IP address with a lower value, for example <code>/24</code>.

如果您有两个以上的服务器,请对每个服务器重复这些命令。 如果您的服务器位于同一网络上 ,则可以使用一个规则允许对网络上的所有主机进行访问。 为此,您需要将IP地址后面的<code>/32</code>替换为一个较小的值,例如<code>/24</code> 。

Next, test the connection. Log in to your second CentOS server as your non-root user:

接下来,测试连接。 以非root用户身份登录到第二台CentOS服务器:

<ul><li>

ssh sammy@second_centos_server_ip

ssh sammy @ second_centos_server_ip

</li></ul>

Use the <code>curl</code> command to test the connection to the Elastic Stack server:

使用<code>curl</code>命令测试与Elastic Stack服务器的连接:

<ul><li>

curl Elastic_Stack_server_ip:9200

curl Elastic_Stack_server_ip :9200

</li></ul>

You’ll receive output similar to the following:

您将收到类似于以下内容的输出:

<pre class="has"><code>
Output
{ "name" : "tl5Is5f", "cluster_name" : "elasticsearch", "cluster_uuid" : "W9AcSNWHQ3mYs2uE8odklA", "version" : { "number" : "6.7.0", "build_flavor" : "default", "build_type" : "rpm", "build_hash" : "3bd3e59", "build_date" : "2019-03-06T15:16:26.864148Z", "build_snapshot" : false, "lucene_version" : "7.6.0", "minimum_wire_compatibility_version" : "5.6.0", "minimum_index_compatibility_version" : "5.0.0" }, "tagline" : "You Know, for Search" } </code></pre>

Now that you know the connection works, you are ready to send metrics to your Elastic Stack server.

既然您知道连接的工作原理,就可以将指标发送到您的Elastic Stack服务器。

<h2 id="step-2-—-installing-and-configuring-metricbeat-on-the-elastic-stack-server"> 步骤2 —在Elastic Stack Server上安装和配置Metricbeat <span style="font-weight: bold;">(</span>Step 2 — Installing and Configuring Metricbeat on the Elastic Stack Server<span style="font-weight: bold;">)</span></h2>

In the next two steps, you will first install Metricbeat on the Elastic Stack server and import all the needed data, then install and configure the client on the second CentOS server.

在接下来的两个步骤中,您将首先在Elastic Stack服务器上安装Metricbeat并导入所有需要的数据,然后在第二台CentOS服务器上安装并配置客户端。

Log into your Elastic Stack server as your non-root user:

以非root用户身份登录到Elastic Stack服务器:

<ul><li>

ssh sammy@Elastic_Stack_server_ip

ssh sammy @ Elastic_Stack_server_ip

</li></ul>

Since you previously set up the Elasticsearch repositories in the prerequisite, you only need to install Metricbeat:

由于您之前已在前提条件中设置了Elasticsearch存储库,因此只需要安装Metricbeat:

<ul><li class="line">sudo yum install metricbeat

sudo yum安装metricbeat </li></ul>

Once the installation is complete, load the index template into Elasticsearch. An <em>Elasticsearch index</em> is a collection of documents that have similar characteristics. Specific names identify each index, which Elasticsearch will use to refer to the indexes when performing various operations. Your Elasticsearch server will automatically apply the index template when you create a new index.

安装完成后,将索引模板加载到Elasticsearch中。 <em>Elasticsearch索引</em>是具有相似特征的文档的集合。 特定名称标识每个索引,Elasticsearch在执行各种操作时将使用它们来引用这些索引。 创建新索引时,您的Elasticsearch服务器将自动应用索引模板。

To load the template, use the following command:

要加载模板,请使用以下命令:

<ul><li class="line">sudo metricbeat setup --template -E 'output.elasticsearch.hosts=["localhost:9200"]'

sudo metricbeat设置--template -E'output.elasticsearch.hosts = [“ localhost:9200”]' </li></ul>

You will see the following output:

您将看到以下输出:

<pre class="has"><code>
Output
Loaded index template </code></pre>

Metricbeat comes packaged with example Kibana dashboards, visualizations, and searches for visualizing Metricbeat data in Kibana. Before you can use the dashboards, you need to create the index pattern and load the dashboards into Kibana.

Metricbeat随附了示例Kibana仪表板,可视化文件,并在Kibana中搜索以可视化Metricbeat数据。 在使用仪表盘之前,您需要创建索引模式并将仪表盘加载到Kibana中。

To load the templates, use the following command:

要加载模板,请使用以下命令:

<ul><li class="line">sudo metricbeat setup -e -E output.elasticsearch.hosts=['localhost:9200'] -E setup.kibana.host=localhost:5601

sudo metricbeat设置-e -E output.elasticsearch.hosts = ['localhost:9200'] -E setup.kibana.host = localhost:5601 </li></ul>

You will see output that looks like this:

您将看到如下所示的输出:

<pre class="has"><code>
Output
... 2019-03-20T09:51:32.096Z INFO instance/beat.go:281 Setup Beat: metricbeat; Version: 6.7.0 2019-03-20T09:51:32.136Z INFO add_cloud_metadata/add_cloud_metadata.go:323 add_cloud_metadata: hosting provider type detected as digitalocean, metadata={"instance_id":"133130541","provider":"digitalocean","region":"fra1"} 2019-03-20T09:51:32.137Z INFO elasticsearch/client.go:165 Elasticsearch url: http://localhost:9200 2019-03-20T09:51:32.137Z INFO [publisher] pipeline/module.go:110 Beat name: elastic 2019-03-20T09:51:32.138Z INFO elasticsearch/client.go:165 Elasticsearch url: http://localhost:9200 2019-03-20T09:51:32.140Z INFO elasticsearch/client.go:721 Connected to Elasticsearch version 6.7.0 2019-03-20T09:51:32.148Z INFO template/load.go:130 Template already exists and will not be overwritten. 2019-03-20T09:51:32.148Z INFO instance/beat.go:894 Template successfully loaded. Loaded index template Loading dashboards (Kibana must be running and reachable) 2019-03-20T09:51:32.149Z INFO elasticsearch/client.go:165 Elasticsearch url: http://localhost:9200 2019-03-20T09:51:32.150Z INFO elasticsearch/client.go:721 Connected to Elasticsearch version 6.7.0 2019-03-20T09:51:32.151Z INFO kibana/client.go:118 Kibana url: http://localhost:5601 2019-03-20T09:51:56.209Z INFO instance/beat.go:741 Kibana dashboards successfully loaded. Loaded dashboards </code></pre>

Now you can start Metricbeat:

现在您可以启动Metricbeat:

<ul><li class="line">sudo systemctl start metricbeat

sudo systemctl启动metricbeat </li></ul>

To make Metricbeat start automatically at boot from now on, use the <code>enable</code> command:

要使Metricbeat从现在开始在启动时自动启动,请使用<code>enable</code>命令:

<ul><li class="line">sudo systemctl enable metricbeat

sudo systemctl启用metricbeat </li></ul>

Metricbeat will begin shipping your system stats into Elasticsearch.

Metricbeat将开始将您的系统统计信息传送到Elasticsearch。

To verify that Elasticsearch is indeed receiving this data, query the Metricbeat index with this command:

要验证Elasticsearch确实在接收此数据,请使用以下命令查询Metricbeat索引:

<ul><li class="line">curl -XGET 'http://localhost:9200/metricbeat-*/_search?pretty'

curl -XGET'http:// localhost:9200 / metricbeat-* / _ search?pretty' </li></ul>

You will see an output that looks similar to this:

您将看到类似于以下内容的输出:

<pre class="has"><code>
Output
... { "took" : 3, "timed_out" : false, "_shards" : { "total" : 1, "successful" : 1, "skipped" : 0, "failed" : 0 }, "hits" : { "total" : 108, "max_score" : 1.0, "hits" : [ { "_index" : "metricbeat-6.7.0-2019.03.20", "_type" : "doc", "_id" : "A4mU8GgBKrpxEYMLjJZt", "_score" : 1.0, "_source" : { "@timestamp" : "2019-03-20T09:54:52.481Z", "metricset" : { "name" : "network", "module" : "system", "rtt" : 125 }, "event" : { "dataset" : "system.network", "duration" : 125260 }, "system" : { "network" : { "in" : { "packets" : 59728, "errors" : 0, "dropped" : 0, "bytes" : 736491211 }, "out" : { "dropped" : 0, "packets" : 31630, "bytes" : 8283069, "errors" : 0 }, "name" : "eth0" } }, "beat" : { "version" : "6.7.0", "name" : "elastic", "hostname" : "elastic" }, ... </code></pre>

The line <code>"total" : 108,</code> indicates that Metricbeat has found 108 search results for this specific metric. Any number of search results indicates that Metricbeat is working; if your output shows 0 total hits, you will need to review your setup for errors. If you received the expected output, continue to the next step, in which you will install Metricbeat on the second CentOS server.

线<code>"total" : 108 ,</code>表示Metricbeat已找到该特定指标的108个搜索结果。 任何数量的搜索结果表明Metricbeat正在运行; 如果您的输出显示总点击数为0,则需要检查设置是否存在错误。 如果收到预期的输出,请继续执行下一步,在该步骤中,将Metricbeat安装在第二台CentOS服务器上。

<h2 id="step-3-—-installing-and-configuring-metricbeat-on-the-second-centos-server"> 步骤3 —在第二台CentOS服务器上安装和配置Metricbeat <span style="font-weight: bold;">(</span>Step 3 — Installing and Configuring Metricbeat on the Second CentOS Server<span style="font-weight: bold;">)</span></h2>

Perform this step on all CentOS servers from which you want to send metrics to your Elastic Stack server. If you also have Ubuntu servers, you can install Metricbeat by following Step 3 of How To Gather Infrastructure Metrics with Metricbeat on Ubuntu 18.04.

在要从其将指标发送到Elastic Stack服务器的所有CentOS服务器上执行此步骤。 如果您还具有Ubuntu服务器,则可以按照在Ubuntu 18.04上如何通过Metricbeat收集基础结构度量标准中的步骤3来安装Metricbeat。

Log into your second CentOS server as your non-root user:

以非root用户身份登录第二台CentOS服务器:

<ul><li>

ssh sammy@second_centos_server_ip

ssh sammy @ second_centos_server_ip

</li></ul>

The Elastic Stack components are not available through the yum package manager by default, but you can install them by adding Elastic’s package repository.

默认情况下,yum软件包管理器无法使用Elastic Stack组件,但是您可以通过添加Elastic的软件包存储库来安装它们。

All of the Elastic Stack’s packages are signed with the Elasticsearch signing key in order to protect your system from package spoofing. Your package manager will trust packages that have been authenticated using the key. In this step, you will import the Elasticsearch public GPG key and add the Elastic package source list in order to install Metricbeat.

所有Elastic Stack的软件包都使用Elasticsearch签名密钥签名,以保护您的系统免受软件包欺骗的侵害。 您的软件包管理员将信任已使用密钥进行身份验证的软件包。 在此步骤中,您将导入Elasticsearch公共GPG密钥并添加Elastic软件包源列表以安装Metricbeat。

To begin, run the following command to download and install the Elasticsearch public signing key:

首先,运行以下命令以下载并安装Elasticsearch公共签名密钥:

<ul><li class="line">sudo rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch

sudo rpm-导入https://artifacts.elastic.co/GPG-KEY-elasticsearch </li></ul>

Next, add the Elastic repository. Use your preferred text editor to create the file <code>elasticsearch.repo</code> in the <code>/etc/yum.repos.d/</code> directory:

接下来,添加Elastic存储库。 使用您喜欢的文本编辑器在<code>/etc/yum.repos.d/</code>目录中创建文件<code>elasticsearch.repo</code> :

<ul><li class="line">sudo vi /etc/yum.repos.d/elasticsearch.repo

须藤vi /etc/yum.repos.d/elasticsearch.repo </li></ul>

To provide yum with the information it needs to download and install the components of the Elastic Stack, enter insert mode by pressing <code>i</code> and add the following lines to the file:

要为yum提供下载和安装Elastic Stack组件所需的信息,请按<code>i</code>进入插入模式,并将以下行添加到文件中:

/etc/yum.repos.d/elasticsearch.repo
/etc/yum.repos.d/elasticsearch.repo
<pre class="has"><code>[elasticsearch-6.x] name=Elasticsearch repository for 6.x packages baseurl=https://artifacts.elastic.co/packages/6.x/yum gpgcheck=1 gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch enabled=1 autorefresh=1 type=rpm-md</code></pre>

When you’re finished, save and close the file.

完成后,保存并关闭文件。

Next, install Metricbeat with this command:

接下来,使用以下命令安装Metricbeat:

<ul><li class="line">sudo yum install metricbeat

sudo yum安装metricbeat </li></ul>

Once Metricbeat is finished installing, configure it to connect to Elasticsearch. Open its configuration file, <code>metricbeat.yml</code>:

Metricbeat安装完成后,对其进行配置以连接到Elasticsearch。 打开其配置文件<code>metricbeat.yml</code> :

<ul><li class="line">sudo vi /etc/metricbeat/metricbeat.yml

须藤vi /etc/metricbeat/metricbeat.yml </li></ul>

Note: Metricbeat’s configuration file is in YAML format, which means that indentation is very important! Be sure that you do not add any extra spaces as you edit this file.

注意: Metricbeat的配置文件为YAML格式,这意味着缩进非常重要! 确保在编辑此文件时不要添加任何多余的空格。

Metricbeat supports numerous outputs, but you’ll usually only send events directly to Elasticsearch or to Logstash for additional processing. Find the following section and update the IP address:

Metricbeat支持大量输出,但通常只将事件直接发送到Elasticsearch或Logstash进行其他处理。 查找以下部分并更新IP地址:

/etc/metricbeat/metricbeat.yml
/etc/metricbeat/metricbeat.yml
<pre class="has"><code class="code-highlight language-yaml">#-------------------------- Elasticsearch output ------------------------------ output.elasticsearch: # Array of hosts to connect to. hosts: ["Elastic_Stack_server_ip:9200"] ...</code></pre>

Save and close the file.

保存并关闭文件。

You can extend the functionality of Metricbeat with modules. In this tutorial, you will use the <code>system</code> module, which allows you to monitor your server’s stats like CPU/memory/disk usage and network utilization.

您可以使用modules扩展Metricbeat的功能。 在本教程中,您将使用<code>system</code>模块,该模块允许您监视服务器的统计信息,例如CPU /内存/磁盘使用率和网络使用率。

In this case, the <code>system</code> module is enabled by default. You can see a list of enabled and disabled modules by running:

在这种情况下, <code>system</code>模块默认为启用。 您可以通过运行以下命令查看已启用和已禁用模块的列表:

<ul><li class="line">sudo metricbeat modules list

sudo metricbeat模块列表 </li></ul>

You will see a list similar to the following:

您将看到类似于以下内容的列表:

<pre class="has"><code>
Output
Enabled: system Disabled: aerospike apache ceph couchbase docker dropwizard elasticsearch envoyproxy etcd golang graphite haproxy http jolokia kafka kibana kubernetes kvm logstash memcached mongodb munin mysql nginx php_fpm postgresql prometheus rabbitmq redis traefik uwsgi vsphere windows zookeeper </code></pre>

You can see the parameters of the module in the <code>/etc/metricbeat/modules.d/system.yml</code> configuration file. In the case of this tutorial, you do not need to change anything in the configuration. The default metricsets are <code>cpu</code>, <code>load</code>, <code>memory</code>, <code>network</code>, <code>process</code>, and <code>process_summary</code>. Each module has one or more metricset. A metricset is the part of the module that fetches and structures the data. Rather than collecting each metric as a separate event, metricsets retrieve a list of multiple related metrics in a single request to the remote system.

您可以在<code>/etc/metricbeat/modules.d/system.yml</code>配置文件中查看模块的参数。 在本教程中,您无需更改配置。 默认指标集是<code>cpu</code> , <code>load</code> , <code>memory</code> , <code>network</code> , <code>process</code>和<code>process_summary</code> 。 每个模块都有一个或多个度量标准集。 度量集是模块的一部分,用于获取和构建数据。 度量标准集不是将每个度量标准收集为单独的事件,而是在对远程系统的单个请求中检索多个相关度量标准的列表。

Now you can start and enable Metricbeat:

现在,您可以启动并启用Metricbeat:

<ul><li class="line">sudo systemctl start metricbeat

sudo systemctl启动metricbeat </li><li class="line">sudo systemctl enable metricbeat

sudo systemctl启用metricbeat </li></ul>

Repeat this step on all servers where you want to collect metrics. After that, you can proceed to the next step in which you will see how to navigate through some of Kibana’s dashboards.

在要收集指标的所有服务器上重复此步骤。 之后,您可以继续执行下一步,在该步骤中,您将了解如何浏览Kibana的某些仪表板。

<h2 id="step-4-—-exploring-kibana-dashboards"> 第4步-探索Kibana仪表盘 <span style="font-weight: bold;">(</span>Step 4 — Exploring Kibana Dashboards<span style="font-weight: bold;">)</span></h2>

In this step, you will take a look at Kibana, the web interface that you installed in the Prerequisites section.

在此步骤中,您将了解在先决条件部分中安装的Web界面Kibana。

In a web browser, go to the FQDN or public IP address of your Elastic Stack server. After entering the login credentials you defined in Step 2 of the Elastic Stack tutorial, you will see the Kibana homepage:

在Web浏览器中,转到Elastic Stack服务器的FQDN或公共IP地址。 输入您在Elastic Stack教程的步骤2中定义的登录凭证后,您将看到Kibana主页:

Click the Discover link in the left-hand navigation bar. On the Discover page, select the predefined meticbeat-* index pattern to see Metricbeat data. By default, this will show you all of the log data over the last 15 minutes. You will find a histogram and some metric details:

单击左侧导航栏中的“ 发现”链接。 在“ 发现”页面上,选择预定义的meticbeat- *索引模式以查看Metricbeat数据。 默认情况下,它将显示过去15分钟内的所有日志数据。 您会发现直方图和一些指标详细信息:

Here, you can search and browse through your metrics and also customize your dashboard. At this point, though, there won’t be much in there because you are only gathering system stats from your servers.

在这里,您可以搜索和浏览指标,还可以自定义仪表板。 但是,此时并没有太多,因为您只从服务器中收集系统统计信息。

Use the left-hand panel to navigate to the Dashboard page and search for the Metricbeat System dashboard. Once there, you can search for the sample dashboards that come with Metricbeat’s <code>system</code> module.

使用左侧面板导航到“ 仪表板”页面并搜索“ Metricbeat系统”仪表板。 到达那里后,您可以搜索Metricbeat的<code>system</code>模块随附的示例仪表板。

For example, you can view brief information about all your hosts:

例如,您可以查看有关所有主机的简要信息:

You can also click on the host name and view more detailed information:

您还可以单击主机名并查看更多详细信息:

Kibana has many other features, such as graphing and filtering, so feel free to explore.

Kibana还具有许多其他功能,例如绘图和过滤,因此请随时进行探索。

<h2 id="conclusion"> 结论 <span style="font-weight: bold;">(</span>Conclusion<span style="font-weight: bold;">)</span></h2>

In this tutorial, you’ve installed Metricbeat and configured the Elastic Stack to collect and analyze system metrics. Metricbeat comes with internal modules that collect metrics from services like Apache, Nginx, Docker, MySQL, PostgreSQL, and more. Now you can collect and analyze the metrics of your applications by simply turning on the modules you need.

在本教程中,您已经安装了Metricbeat并配置了Elastic Stack以收集和分析系统指标。 Metricbeat带有内部模块 ,这些模块从Apache,Nginx,Docker,MySQL,PostgreSQL等服务中收集指标。 现在,您只需打开所需的模块即可收集和分析应用程序的指标。

If you want to understand more about server monitoring, check out An Introduction to Metrics, Monitoring, and Alerting and Putting Monitoring and Alerting into Practice.

如果您想了解有关服务器监控的更多信息,请查看《 度量,监控和警报简介》并将“ 监控和警报”付诸实践 。

<blockquote>

翻译自: https://www.digitalocean.com/community/tutorials/how-to-gather-infrastructure-metrics-with-metricbeat-on-centos-7

</blockquote>

centos7使用基础教程

到此这篇关于“centos7使用基础教程_如何在CentOS 7上使用Metricbeat收集基础结构指标”的文章就介绍到这了,更多文章或继续浏览下面的相关文章,希望大家以后多多支持JQ教程网!

您可能感兴趣的文章:
centos7使用基础教程_如何在CentOS 7上使用Metricbeat收集基础结构指标
golang基础教程
python安装路径怎么找
零基础学习HTML5
基础教程介绍——什么是SOA
photoshop基础图层与蒙版使用技巧心得
Docker基础及其原理(一)
零基础学python需要多久
python数据分析需要什么基础
《Python2爬虫入门教程指南》(系列教程)

[关闭]
~ ~