Files
doc-exports/docs/css/umn/css_01_0048.html
zhengxiu 93d856d5c5 css umn 25.6.0 version
Reviewed-by: Pruthi, Vineet <vineet.pruthi@t-systems.com>
Co-authored-by: zhengxiu <zhengxiu@huawei.com>
Co-committed-by: zhengxiu <zhengxiu@huawei.com>
2025-11-25 11:34:43 +00:00

186 lines
42 KiB
HTML

<a name="EN-US_TOPIC_0000001938218520"></a><a name="EN-US_TOPIC_0000001938218520"></a>
<h1 class="topictitle1">Using In-house Built Logstash to Import Data to Elasticsearch</h1>
<div id="body1526032894587"><p id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_p6252043134616">With <span id="EN-US_TOPIC_0000001938218520__text577810239192">CSS</span>, you can use in-house developed Logstash to ingest data into Elasticsearch for efficient search and exploration. Data files can be in the JSON or CSV format.</p>
<p id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_p2714111201213">Logstash is an open-source, server-side data processing pipeline that ingests data from multiple sources simultaneously, processes and transforms the data, and then sends it to Elasticsearch. For details about Logstash, visit the following website: <a href="https://www.elastic.co/guide/en/logstash/current/getting-started-with-logstash.html" target="_blank" rel="noopener noreferrer">https://www.elastic.co/guide/en/logstash/current/getting-started-with-logstash.html</a></p>
<p id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_p651723317178">The following two scenarios are involved depending on the Logstash deployment:</p>
<ul id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_ul11548165271713"><li id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_li16548852101714"><a href="#EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_section072813417814">Importing Data When Logstash Is Deployed on the External Network</a></li><li id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_li0548652141717"><a href="#EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_section1098217174335">Importing Data When Logstash Is Deployed on an ECS</a></li></ul>
<div class="section" id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_section371994174412"><h4 class="sectiontitle">Prerequisites</h4><ul id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_ul15513934114514"><li id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_li851317349456">To facilitate operations, you are advised to deploy Logstash on a host that runs the Linux operating system (OS).</li><li id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_li105075367453">Logstash must use an OSS version that is consistent with that of the CSS cluster. To download Logstash, visit the following website: <a href="https://www.elastic.co/downloads/logstash-oss" target="_blank" rel="noopener noreferrer">https://www.elastic.co/downloads/logstash-oss</a></li><li id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_li9641131917016">The JDK must be installed before Logstash is installed. In Linux OS, you can run the <strong id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_b20393185013114">yum -y install java-1.8.0</strong> command to install JDK 1.8.0. In Windows OS, you can download the required JDK version from the <a href="https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html" target="_blank" rel="noopener noreferrer">official website of JDK</a>, and install it by following the installation guide.</li><li id="EN-US_TOPIC_0000001938218520__li165290425171">After installing Logstash, perform the following steps to import data. For details about how to install Logstash, visit the following website: <a href="https://www.elastic.co/guide/en/logstash/current/installing-logstash.html" target="_blank" rel="noopener noreferrer">https://www.elastic.co/guide/en/logstash/current/installing-logstash.html</a></li><li id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_li1995041711115">In the <a href="#EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_section1098217174335">Importing Data When Logstash Is Deployed on an ECS</a> scenario, ensure that the ECS and the Elasticsearch cluster to which data is imported reside in the same VPC.</li></ul>
</div>
<div class="section" id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_section072813417814"><a name="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_section072813417814"></a><a name="en-us_topic_0000001223914344_section072813417814"></a><h4 class="sectiontitle">Importing Data When Logstash Is Deployed on the External Network</h4><p id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_p4281513171111"><a href="#EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_fig471717481106">Figure 1</a> illustrates how data is imported when Logstash is deployed on an external network.</p>
<div class="fignone" id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_fig471717481106"><a name="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_fig471717481106"></a><a name="en-us_topic_0000001223914344_fig471717481106"></a><span class="figcap"><b>Figure 1 </b>Importing data when Logstash is deployed on an external network</span><br><span><img class="eddx" id="EN-US_TOPIC_0000001938218520__image1539410379715" src="figure/en-us_image_0000002232289778.png"></span></div>
<ol id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_ol20180835132314"><li id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_li1648853125014"><a name="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_li1648853125014"></a><a name="en-us_topic_0000001223914344_li1648853125014"></a>Create a jump host and configure it as follows:<ul id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_ul2807152315574"><li id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_li18807132310572">The jump host is an ECS running the Linux OS and has been bound with an EIP.</li><li id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_li1692633435810">The jump host resides in the same VPC as the CSS cluster.</li><li id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_li129110535017">SSH local port forwarding is configured for the jump host to forward requests from a chosen local port to port <strong id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_b181343814612">9200</strong> on one node of the CSS cluster.</li><li id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_li1277830155915">Refer to <a href="https://man.openbsd.org/ssh.1#L" target="_blank" rel="noopener noreferrer">SSH documentation</a> for the local port forwarding configuration.</li></ul>
</li><li id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_li19164183513237">Use PuTTY to log in to the created jump host with the EIP.</li><li id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_li1316473511236">Run the following command to configure port mapping to forward requests sent to the opened port on the jump host to the destination cluster:<pre class="screen" id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_screen716453518231">ssh -g -L <em id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_i31643353232">&lt;Local port of the jump host</em>:<em id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_i716443572314">Private network address and port number of a node&gt;</em> -N -f root@<em id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_i216416353238">&lt;Private IP address of the jump host</em>&gt;</pre>
<ul id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_ul3164163513237"><li id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_li1216415353237">In the preceding command, <em id="EN-US_TOPIC_0000001938218520__i18488164492114">&lt;<em id="EN-US_TOPIC_0000001938218520__i648844414218">Local port of the jump host</em>&gt;</em> refers to the port obtained in <a href="#EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_li1648853125014">1</a>.</li><li id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_li516410352234">In the preceding command, <em id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_i142757577509">&lt;Private network address and port number of a node&gt;</em> refers to the private network address and port number of a node in the cluster. If the node is faulty, the command execution will fail. If the cluster contains multiple nodes, you can replace the value of <strong id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_b249125891317">&lt;private network address and port number of a node&gt;</strong> with the private network address and port number of any available node in the cluster. If the cluster contains only one node, restore the node and execute the command again.</li><li id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_li91643359239">Replace &lt;<em id="EN-US_TOPIC_0000001938218520__i1383904163118">Private IP address of the jump host</em>&gt; in the preceding command with the IP address (with <span class="parmvalue" id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_parmvalue31641635122313"><b>Private IP</b></span>) of the created jump host in the <span class="parmname" id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_parmname8164735202318"><b>IP Address</b></span> column in the ECS list on the ECS management console.</li></ul>
<p id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_p1416483562310">For example, port <strong id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_b6116104104118">9200</strong> on the jump host is assigned external network access permissions, the private network address and port number of the node are <strong id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_b11808313212">192.168.0.81</strong> and <strong id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_b172891341022">9200</strong>, respectively, and the private IP address of the jump host is <strong id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_b185281761121">192.168.0.227</strong>. You need to run the following command to perform port mapping:</p>
<pre class="screen" id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_screen7164123516239">ssh -g -L 9200:192.168.0.81:9200 -N -f root@192.168.0.227</pre>
</li><li id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_li5164153542312"><a name="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_li5164153542312"></a><a name="en-us_topic_0000001223914344_li5164153542312"></a>Log in to the server where Logstash is deployed and store the data files to be imported on the server.<p id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_p9164235142316"><a name="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_li5164153542312"></a><a name="en-us_topic_0000001223914344_li5164153542312"></a>For example, data file <span class="filepath" id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_filepath142871815163915"><b>access_20181029_log</b></span> needs to be imported, the file storage path is <span class="filepath" id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_filepath1428781583910"><b>/tmp/access_log/</b></span> (create the access_log folder if it does not already exist), and the data file includes the following data:</p>
<pre class="screen" id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_screen916412354232">| All | Heap used for segments | | 18.6403 | MB |
| All | Heap used for doc values | | 0.119289 | MB |
| All | Heap used for terms | | 17.4095 | MB |
| All | Heap used for norms | | 0.0767822 | MB |
| All | Heap used for points | | 0.225246 | MB |
| All | Heap used for stored fields | | 0.809448 | MB |
| All | Segment count | | 101 | |
| All | Min Throughput | index-append | 66232.6 | docs/s |
| All | Median Throughput | index-append | 66735.3 | docs/s |
| All | Max Throughput | index-append | 67745.6 | docs/s |
| All | 50th percentile latency | index-append | 510.261 | ms |</pre>
</li><li id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_li416420352232">On the server where Logstash is deployed, run the following command to create configuration file <span class="filepath" id="EN-US_TOPIC_0000001938218520__filepath460716541600"><b>logstash-simple.conf</b></span> in the Logstash installation directory:<pre class="screen" id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_screen8164235182310">cd /<em id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_i1317714259514">&lt;Logstash installation directory&gt;</em>/
vi logstash-simple.conf</pre>
</li><li id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_li416415355230">Enter the following content in <span class="filepath" id="EN-US_TOPIC_0000001938218520__filepath4407131716334"><b>logstash-simple.conf</b></span>:<pre class="screen" id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_screen151641235102317">input {
<em id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_i1594111511224">Location of data</em>
}
filter {
<em id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_i10594815152216">Related data processing</em>
}
output {
elasticsearch {
hosts =&gt; "&lt;EIP of the <em id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_i3542420651"><em id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_i2541152016516">jump host</em></em>&gt;:<em id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_i11542620659">&lt;Number of the port assigned external network access permissions on the jump host&gt;</em>"
(Optional) If communication encryption has been enabled for the cluster, you need to add the following configuration:
ssl =&gt; true
ssl_certificate_verification =&gt; false
}
}</pre>
<ul id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_ul1416414353230"><li id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_li1216411359233">The <strong id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_b071245572520">input</strong> parameter indicates the data source. Set this parameter based on the actual conditions. For details about the <strong id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_b11998827110">input</strong> parameter and parameter usage, visit the following website: <a href="https://www.elastic.co/guide/en/logstash/current/input-plugins.html" target="_blank" rel="noopener noreferrer">https://www.elastic.co/guide/en/logstash/current/input-plugins.html</a></li><li id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_li9164735172310">The <strong id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_b16659135673710">filter</strong> parameter specifies the mode in which data is processed. For example, extract and process logs to convert unstructured information into structured information. For details about the <strong id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_b3326196113">filter</strong> parameter and parameter usage, visit the following website: <a href="https://www.elastic.co/guide/en/logstash/current/filter-plugins.html" target="_blank" rel="noopener noreferrer">https://www.elastic.co/guide/en/logstash/current/filter-plugins.html</a></li><li id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_li121641735122315">The <strong id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_b8423527062042">output</strong> parameter indicates the destination address of the data. For details about the <strong id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_b15520928389">output</strong> parameter and parameter usage, visit <a href="https://www.elastic.co/guide/en/logstash/current/output-plugins.html" target="_blank" rel="noopener noreferrer">https://www.elastic.co/guide/en/logstash/current/output-plugins.html</a>. Replace &lt;<em id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_i1628913582507">EIP address of the <em id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_i192892589504">jump host</em></em>&gt; with the IP address (with <span class="parmvalue" id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_parmvalue1516493516235"><b>EIP</b></span>) of the created jump host in the <span class="parmname" id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_parmname19290105814503"><b>IP Address</b></span> column in the ECS list on the ECS management console. <em id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_i1749321524419">&lt;Number of the port assigned external network access permissions on the jump host&gt;</em> is the number of the port obtained in <a href="#EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_li1648853125014">1</a>, for example, <strong id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_b1049461554418">9200</strong>.</li></ul>
<p id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_p1164143513237">Consider the data files in the <span class="filepath" id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_filepath78321133133818"><b>/tmp/access_log/</b></span> path mentioned in <a href="#EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_li5164153542312">4</a> as an example. Assume that data import starts from data in the first row of the data file, the filtering condition is left unspecified (indicating no data processing operations are performed), the public IP address and port number of the jump host are <span class="parmvalue" id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_parmvalue1482182212512"><b>192.168.0.227</b></span> and <span class="parmvalue" id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_parmvalue10483622950"><b>9200</b></span>, respectively, and the name of the target index is <span class="parmvalue" id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_parmvalue1637077173915"><b>myindex</b></span>. Edit the configuration file as follows, and enter <span class="parmvalue" id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_parmvalue1495317521114"><b>:wq</b></span> to save the configuration file and exit.</p>
<pre class="screen" id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_screen816443562316">input {
file{
path =&gt; "/tmp/access_log/*"
start_position =&gt; "beginning"
}
}
filter {
}
output {
elasticsearch {
hosts =&gt; "192.168.0.227:9200"
index =&gt; "myindex"
}
}</pre>
<div class="note" id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_note29452405213"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_p12945184092114">If a license error is reported, set <strong id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_b199511958194712">ilm_enabled</strong> to <strong id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_b17967105964711">false</strong> to try and rectify the error.</p>
</div></div>
<p id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_p154751181388">If the cluster has the security mode enabled, you need to download a certificate first.</p>
<ol type="a" id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_ol45911713483"><li id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001268314505_li07251912434"><a href="#EN-US_TOPIC_0000001938218520__section697213217486">Obtaining the Security Certificate</a>.</li><li id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_li107224618910">Store the downloaded certificate to the server where Logstash is deployed.</li><li id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_li84281357121313">Modify the <span class="filepath" id="EN-US_TOPIC_0000001938218520__filepath19226153517280"><b>logstash-simple.conf</b></span> configuration file.<div class="p" id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_p14897136193">Consider the data files in the <span class="filepath" id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_filepath376984121915"><b>/tmp/access_log/</b></span> path mentioned in <a href="#EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_li5164153542312">4</a> as an example. Assume that data import starts from data in the first row of the data file, the filtering condition is left unspecified (indicating no data processing operations are performed), and the public IP address and port number of the jump host are <span class="parmvalue" id="EN-US_TOPIC_0000001938218520__parmvalue578738471"><b>192.168.0.227</b></span> and <span class="parmvalue" id="EN-US_TOPIC_0000001938218520__parmvalue1921400666"><b>9200</b></span>, respectively. The name of the index for importing data is <strong id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_b104220143134">myindex</strong>, and the certificate is stored in <strong id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_b177982020111311">/logstash/config/CloudSearchService.cer</strong>. Edit the configuration file as follows, and enter <span class="parmvalue" id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_parmvalue197616546346"><b>:wq</b></span> to save the configuration file and exit.<pre class="screen" id="EN-US_TOPIC_0000001938218520__screen12598143419580">input{
file {
path =&gt; "/tmp/access_log/*"
start_position =&gt; "beginning"
}
}
filter {
}
output{
elasticsearch{
hosts =&gt; ["https://192.168.0.227:9200"]
index =&gt; "myindex"
user =&gt; "admin" # Username for accessing the security-mode cluster
password =&gt; "******" # Password for accessing the security-mode cluster
cacert =&gt; "/logstash/config/CloudSearchService.cer"
manager_template =&gt; false
ilm_enabled =&gt; false
ssl =&gt; true
ssl_certificate_verification =&gt; false
}
}</pre>
</div>
</li></ol>
</li><li id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_li14164163582313">Run the following command to import the data collected by Logstash to the cluster:<pre class="screen" id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_screen121641135152312">./bin/logstash -f logstash-simple.conf</pre>
<p id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_p3258910205713">This command must be executed in the directory where the <span class="filepath" id="EN-US_TOPIC_0000001938218520__filepath15601554516"><b>logstash-simple.conf</b></span> file is located. For example, if the <span class="filepath" id="EN-US_TOPIC_0000001938218520__filepath3181535218"><b>logstash-simple.conf</b></span> file is stored in <span class="filepath" id="EN-US_TOPIC_0000001938218520__filepath51547712214"><b>/root/logstash-7.1.1/</b></span>, navigate to this directory before executing the command.</p>
</li><li id="EN-US_TOPIC_0000001938218520__en-us_topic_0000002271391393_en-us_topic_0000001268594549_li5509181942419"><span id="EN-US_TOPIC_0000001938218520__ph152259618315">Log in to the CSS management console.</span></li><li id="EN-US_TOPIC_0000001938218520__en-us_topic_0000002271391393_li4250043448">In the navigation pane on the left, choose <span class="uicontrol" id="EN-US_TOPIC_0000001938218520__uicontrol116057844585121"><b>Clusters &gt; Elasticsearch</b></span>.</li><li id="EN-US_TOPIC_0000001938218520__en-us_topic_0000002271391393_en-us_topic_0000001268154521_li6012554340">In the cluster list, find the target cluster, and click <strong id="EN-US_TOPIC_0000001938218520__b100090973785736">Kibana</strong> in the <strong id="EN-US_TOPIC_0000001938218520__b1337136385736">Operation</strong> column to log in to the Kibana console.</li><li id="EN-US_TOPIC_0000001938218520__en-us_topic_0000002271391393_li270075935613">In the left navigation pane, choose <span class="uicontrol" id="EN-US_TOPIC_0000001938218520__uicontrol172324812618"><b>Dev Tools</b></span>.</li><li id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_li418033592313">On the Kibana console, search for the ingested data.<p id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_p118053518234"><a name="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_li418033592313"></a><a name="en-us_topic_0000001223914344_li418033592313"></a>Run the following command to search for data. View the search results. If the searched data is consistent with the imported data, the data has been imported successfully.</p>
<pre class="screen" id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_screen1718063513237">GET myindex/_search</pre>
</li></ol>
</div>
<div class="section" id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_section1098217174335"><a name="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_section1098217174335"></a><a name="en-us_topic_0000001223914344_section1098217174335"></a><h4 class="sectiontitle">Importing Data When Logstash Is Deployed on an ECS</h4><p id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_p110725613115"><a href="#EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_fig124034434127">Figure 2</a> illustrates how data is imported when Logstash is deployed on an ECS that resides in the same VPC as the cluster to which data is to be imported.</p>
<div class="fignone" id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_fig124034434127"><a name="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_fig124034434127"></a><a name="en-us_topic_0000001223914344_fig124034434127"></a><span class="figcap"><b>Figure 2 </b>Importing data when Logstash is deployed on an ECS</span><br><span><img class="eddx" id="EN-US_TOPIC_0000001938218520__image149477361988" src="figure/en-us_image_0000002232292634.png"></span></div>
<ol id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_ol3524114322310"><li id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_li1852474313235">Ensure that the ECS where Logstash is deployed and the cluster to which data is to be imported reside in the same VPC, port <strong id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_b694015623710">9200</strong> of the ECS security group has been assigned external network access permissions, and an EIP has been bound to the ECS.<ul id="EN-US_TOPIC_0000001938218520__ul8341199611"><li id="EN-US_TOPIC_0000001938218520__li1134598620">If there are multiple servers in a VPC, you only need to associate an EIP with one of these servers. Switch to the node where Logstash is deployed from the node with which the EIP is associated.</li><li id="EN-US_TOPIC_0000001938218520__li5344913618">If a private line or VPN is available, there is no need for an EIP.</li></ul>
</li><li id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_li1652411439236"><a name="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_li1652411439236"></a><a name="en-us_topic_0000001223914344_li1652411439236"></a>Use PuTTY to log in to the ECS.<div class="p" id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_p12524643162314"><a name="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_li1652411439236"></a><a name="en-us_topic_0000001223914344_li1652411439236"></a>For example, data file <span class="filepath" id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_filepath1388819169466"><b>access_20181029_log</b></span> is stored in the <span class="filepath" id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_filepath138891516164613"><b>/tmp/access_log/</b></span> path of the ECS, and the data file includes the following data:<pre class="screen" id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_screen19524243192319">| All | Heap used for segments | | 18.6403 | MB |
| All | Heap used for doc values | | 0.119289 | MB |
| All | Heap used for terms | | 17.4095 | MB |
| All | Heap used for norms | | 0.0767822 | MB |
| All | Heap used for points | | 0.225246 | MB |
| All | Heap used for stored fields | | 0.809448 | MB |
| All | Segment count | | 101 | |
| All | Min Throughput | index-append | 66232.6 | docs/s |
| All | Median Throughput | index-append | 66735.3 | docs/s |
| All | Max Throughput | index-append | 67745.6 | docs/s |
| All | 50th percentile latency | index-append | 510.261 | ms |</pre>
</div>
</li><li id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_li9524143172314">Run the following command to create configuration file <span class="filepath" id="EN-US_TOPIC_0000001938218520__filepath19179361168"><b>logstash-simple.conf</b></span> in the Logstash installation directory:<pre class="screen" id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_screen2524104318230">cd /<em id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_i42791750123716">&lt;Logstash installation directory&gt;</em>/
vi logstash-simple.conf</pre>
<div class="p" id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_p15241243162314">Enter the following content in <span class="filepath" id="EN-US_TOPIC_0000001938218520__filepath59849351258"><b>logstash-simple.conf</b></span>:<pre class="screen" id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_screen652484313231">input {
<em id="EN-US_TOPIC_0000001938218520__i1976383457">Location of data</em>
}
filter {
<em id="EN-US_TOPIC_0000001938218520__i862412706">Related data processing</em>
}
output {
elasticsearch{
hosts =&gt; "<em id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_i132814017518">&lt;Private network address and port number of the node</em>&gt;"}
(Optional) If communication encryption has been enabled for the cluster, you need to add the following configuration:
ssl =&gt; true
ssl_certificate_verification =&gt; false
}</pre>
<ul id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_ul165241743132318"><li id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_li952444318236">The <strong id="EN-US_TOPIC_0000001938218520__b63571338175812">input</strong> parameter indicates the data source. Set this parameter based on the actual conditions. For details about the <strong id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_b584918558518">input</strong> parameter and parameter usage, visit the following website: <a href="https://www.elastic.co/guide/en/logstash/current/input-plugins.html" target="_blank" rel="noopener noreferrer">https://www.elastic.co/guide/en/logstash/current/input-plugins.html</a></li><li id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_li1524194372320">The <strong id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_b186751957731">filter</strong> parameter specifies the mode in which data is processed. For example, extract and process logs to convert unstructured information into structured information. For details about the <strong id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_b14934557951">filter</strong> parameter and parameter usage, visit the following website: <a href="https://www.elastic.co/guide/en/logstash/current/filter-plugins.html" target="_blank" rel="noopener noreferrer">https://www.elastic.co/guide/en/logstash/current/filter-plugins.html</a></li><li id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_li552418439238">The <strong id="EN-US_TOPIC_0000001938218520__b2225540155816">output</strong> parameter indicates the destination address of the data. For details about the <strong id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_b1936214520613">output</strong> parameter and parameter usage, visit <a href="https://www.elastic.co/guide/en/logstash/current/output-plugins.html" target="_blank" rel="noopener noreferrer">https://www.elastic.co/guide/en/logstash/current/output-plugins.html</a>. <em id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_i10768174713615">&lt;private network address and port number of a node&gt;</em> refers to the private network address and port number of a node in the cluster.<p id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_p18524164317236">If the cluster contains multiple nodes, you are advised to replace the value of <em id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_i1853041431119">&lt;Private network address and port number of a node&gt;</em> with the private network addresses and port numbers of all nodes in the cluster to prevent node faults. Use commas (,) to separate the nodes' private network addresses and port numbers. The following is an example:</p>
<pre class="screen" id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_screen175241043182316">hosts =&gt; ["192.168.0.81:9200","192.168.0.24:9200"]</pre>
<p id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_p452413433238">If the cluster contains only one node, the format is as follows:</p>
<pre class="screen" id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_screen1352474320237">hosts =&gt; "192.168.0.81:9200"</pre>
</li></ul>
</div>
<p id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_p3524043192311">Consider the data files in the <span class="filepath" id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_filepath6760171019395"><b>/tmp/access_log/</b></span> path mentioned in <a href="#EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_li1652411439236">2</a> as an example. Assume that data import starts from data in the first row of the data file, the filtering condition is left unspecified (indicating no data processing operations are performed), the private network address and port number of the node in the cluster where data is to be imported are <span class="parmvalue" id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_parmvalue4202195195517"><b>192.168.0.81</b></span> and <span class="parmvalue" id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_parmvalue1262163213480"><b>9200</b></span>, respectively, and the name of the target index is <span class="parmvalue" id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_parmvalue8869139144819"><b>myindex</b></span>. Edit the configuration file as follows, and enter <span class="parmvalue" id="EN-US_TOPIC_0000001938218520__parmvalue1089132043"><b>:wq</b></span> to save the configuration file and exit.</p>
<pre class="screen" id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_screen952414316233">input {
file{
path =&gt; "/tmp/access_log/*"
start_position =&gt; "beginning"
}
}
filter {
}
output {
elasticsearch {
hosts =&gt; "192.168.0.81:9200"
index =&gt; "myindex"
}
}</pre>
<div class="p" id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_p0370830125513">If the cluster has the security mode enabled, you need to download a certificate first.<ol type="a" id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_ol1817087143812"><li id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_en-us_topic_0111222977_li45915135814"><a href="#EN-US_TOPIC_0000001938218520__section697213217486">Obtaining the Security Certificate</a>.</li><li id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_en-us_topic_0111222977_li107224618910">Store the downloaded certificate to the server where Logstash is deployed.</li><li id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_en-us_topic_0111222977_li84281357121313">Modify the <span class="filepath" id="EN-US_TOPIC_0000001938218520__filepath71001455105110"><b>logstash-simple.conf</b></span> configuration file.<p id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_en-us_topic_0111222977_p14897136193">Consider the data files in the <span class="filepath" id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_filepath16776174361415"><b>/tmp/access_log/</b></span> path mentioned in step <a href="#EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_li1652411439236">2</a> as an example. Assume that data import starts from data in the first row of the data file, the filtering condition is left unspecified (indicating no data processing operations are performed), the public IP address and port number of the jump host are <span class="parmvalue" id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_parmvalue102421758201415"><b>192.168.0.227</b></span> and <span class="parmvalue" id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_parmvalue42431758131415"><b>9200</b></span>, respectively. The name of the index for importing data is <strong id="EN-US_TOPIC_0000001938218520__b1217818256620">myindex</strong>, and the certificate is stored in <strong id="EN-US_TOPIC_0000001938218520__b21785252611">/logstash/config/CloudSearchService.cer</strong>. Edit the configuration file as follows, and enter <span class="parmvalue" id="EN-US_TOPIC_0000001938218520__parmvalue356274819"><b>:wq</b></span> to save the configuration file and exit.</p>
<pre class="screen" id="EN-US_TOPIC_0000001938218520__screen11621184016579">input{
file {
path =&gt; "/tmp/access_log/*"
start_position =&gt; "beginning"
}
}
filter {
}
output{
elasticsearch{
hosts =&gt; ["https://192.168.0.227:9200"]
index =&gt; "myindex"
user =&gt; "admin" # Username for accessing the security-mode cluster
password =&gt; "******" # Password for accessing the security-mode cluster
cacert =&gt; "/logstash/config/CloudSearchService.cer"
manager_template =&gt; false
ilm_enabled =&gt; false
ssl =&gt; true
ssl_certificate_verification =&gt; false
}
}</pre>
</li></ol>
</div>
</li><li id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_li115241243142312">Run the following command to import the ECS data collected by Logstash to the cluster:<pre class="screen" id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_screen3524143132312">./bin/logstash -f logstash-simple.conf</pre>
</li><li id="EN-US_TOPIC_0000001938218520__li9597192517411"><span id="EN-US_TOPIC_0000001938218520__ph45978258410">Log in to the CSS management console.</span></li><li id="EN-US_TOPIC_0000001938218520__li185989254410">In the navigation pane on the left, choose <span class="uicontrol" id="EN-US_TOPIC_0000001938218520__uicontrol91320735985121"><b>Clusters &gt; Elasticsearch</b></span>.</li><li id="EN-US_TOPIC_0000001938218520__li2598192511413">In the cluster list, find the target cluster, and click <strong id="EN-US_TOPIC_0000001938218520__b152443663385736">Kibana</strong> in the <strong id="EN-US_TOPIC_0000001938218520__b198766327785736">Operation</strong> column to log in to the Kibana console.</li><li id="EN-US_TOPIC_0000001938218520__li85989251548">In the left navigation pane, choose <span class="uicontrol" id="EN-US_TOPIC_0000001938218520__uicontrol135983257416"><b>Dev Tools</b></span>.</li><li id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_li1252410433236">On the Kibana console, search for the ingested data.<p id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_p115241343172312"><a name="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_li1252410433236"></a><a name="en-us_topic_0000001223914344_li1252410433236"></a>Run the following command to search for data. View the search results. If the searched data is consistent with the imported data, the data has been imported successfully.</p>
<pre class="screen" id="EN-US_TOPIC_0000001938218520__en-us_topic_0000001223914344_screen75241543182320">GET myindex/_search</pre>
</li></ol>
</div>
<div class="section" id="EN-US_TOPIC_0000001938218520__section697213217486"><a name="EN-US_TOPIC_0000001938218520__section697213217486"></a><a name="section697213217486"></a><h4 class="sectiontitle">Obtaining the Security Certificate</h4><p id="EN-US_TOPIC_0000001938218520__en-us_topic_0000002338102386_p1421640114818">To access a security-mode Elasticsearch cluster that uses HTTPS, a security certificate must be loaded. To obtain this security certificate (CloudSearchService.cer), follow these steps:</p>
<ol id="EN-US_TOPIC_0000001938218520__en-us_topic_0000002338102386_ol6848111364811"><li id="EN-US_TOPIC_0000001938218520__en-us_topic_0000002338102386_en-us_topic_0000001933318570_li1798555810535"><span id="EN-US_TOPIC_0000001938218520__en-us_topic_0000002338102386_ph523831318386">Log in to the CSS management console.</span></li><li id="EN-US_TOPIC_0000001938218520__en-us_topic_0000002338102386_li164461631123811">In the navigation pane on the left, choose <span class="uicontrol" id="EN-US_TOPIC_0000001938218520__en-us_topic_0000002338102386_uicontrol86487267685117"><b>Clusters &gt; Elasticsearch</b></span>.</li><li id="EN-US_TOPIC_0000001938218520__en-us_topic_0000002338102386_li184472316387">In the cluster list, click the name of the target cluster. The cluster information page is displayed.</li><li id="EN-US_TOPIC_0000001938218520__en-us_topic_0000002338102386_en-us_topic_0000001933318570_li146461036135810">Click the <span class="wintitle" id="EN-US_TOPIC_0000001938218520__en-us_topic_0000002338102386_wintitle326154154412"><b>Overview</b></span> tab. In the <span class="wintitle" id="EN-US_TOPIC_0000001938218520__en-us_topic_0000002338102386_wintitle1076156104413"><b>Configuration</b></span> area, click <strong id="EN-US_TOPIC_0000001938218520__en-us_topic_0000002338102386_b1317531104720">Download Certificate</strong> next to <span class="uicontrol" id="EN-US_TOPIC_0000001938218520__en-us_topic_0000002338102386_uicontrol263216261449"><b>HTTPS Access</b></span>.<div class="fignone" id="EN-US_TOPIC_0000001938218520__en-us_topic_0000002338102386_en-us_topic_0000001223914344_fig1877019549519"><span class="figcap"><b>Figure 3 </b>Downloading a security certificate</span><br><span><img id="EN-US_TOPIC_0000001938218520__en-us_topic_0000002338102386_en-us_topic_0000001223914344_image2793173420519" src="images/en-us_image_0000002412557593.png"></span></div>
</li></ol>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="css_01_0004.html">Importing Data to an Elasticsearch Cluster</a></div>
</div>
</div>