Query Methods
<p class="shortdesc">Ping An Cloud Log Service supports following query methods: keyword-based query,
phrase-based query, fuzzy query, key-value-based query, and query based on the multiple
criteria.</p>
<p class="p"><strong class="ph b">Keyword-Based Query</strong></p>
<p class="p">This method queries logs by keyword or the combination of keywords in a query syntax.</p>
<p class="p">For example, to query the logs containing both keywords a and b, use a AND b.</p>
<p class="p"><strong class="ph b">Phrase-based Query</strong></p>
<p class="p">If a phrase contains spaces, use quotation marks ("") to enclose the phrase.</p>
<p class="p">For example, to query logs containing hello pingan cloud, use "hello pingan cloud".</p>
<p class="p"><strong class="ph b">Fuzzy Query</strong></p>
<p class="p">To perform fuzzy query, add the asterisk (*) or the question mark (?) to the middle or
end of a keyword. Then, the system will search the first 10000 logs starting with the
keyword.</p>
<p class="p">For example, to query the logs starting with the keyword hello, use hello*.</p>
<p class="p"><strong class="ph b">Key-Value-Based Query</strong></p>
<p class="p">Ping An Cloud supports the following methods of key-value-based log query:</p>
<p class="p"><strong class="ph b">Method 1:</strong> Query logs by using the key-value pairs extracted by Log Service by
default. </p>
<div class="note important note_important"><span class="note__title">Important:</span>
<ol class="ol" id="Search_Method__ol_grx_q5l_wnb">
<li class="li">Ping An Cloud Log Service extracts the following key-value pairs by default:
appname, message, source, collector_node_id, file, and timestamp. For more
information about these keys, see <a class="xref" href="/ssr/help/middleware/LogCloud/index.Concepts" target="_blank">Logs</a>.</li>
<li class="li">If you specify only a keyword or a query syntax for query, the message key-value
pair is used by default and the system searches the log messages for the
matching data. </li>
</ol>
</div>
<p class="p">Example 1: Use appname:<em class="ph i">UUID-name</em>to query logs with a specific project name.</p>
<div class="note note note_note"><span class="note__title">Note:</span>
<p class="p">To obtain <em class="ph i">UUID-name</em>:</p>
<ol class="ol" id="Search_Method__ol_tfl_t5l_wnb">
<li class="li">In the left navigation pane of the Log Service console, click <strong class="ph b">Project
Management</strong>. </li>
<li class="li">On the <strong class="ph b">Project Management</strong> page, click the target project name. As shown
in the figure below, the content in the red box of the URL is the project ID
(UUID). </li>
</ol>
</div>
<img class="image" id="Search_Method__image_kfb_mb1_xmb" src="https://obs-cn-shanghai.yun.pingan.com/pcp-portal/20210106133703-14ac1bdc9cf5.png" width="830">
<p class="p"> Example 2: Use source:<em class="ph i">UUID-source</em> to query logs of the ECS with a specific host
name.</p>
<div class="note note note_note"><span class="note__title">Note:</span>
<p class="p">To obtain <em class="ph i">UUID-source</em>:</p>
<ol class="ol" id="Search_Method__ol_vg5_y5l_wnb">
<li class="li">In the left navigation page of the ECS console, click <strong class="ph b">Instance</strong>. </li>
<li class="li">On the<strong class="ph b"> Instance Management</strong> page, click the instance name. The hostname of
the ECS instance is displayed on the <strong class="ph b">Instance Information</strong> page.</li>
</ol>
</div>
<img class="image" id="Search_Method__image_krt_pb1_xmb" src="https://obs-cn-shanghai.yun.pingan.com/pcp-portal/20210106133703-1aedb4689be7.png" width="830">
<p class="p"> Example 3: Use collector_node_id:<em class="ph i">IP-address</em> to query the logs of the ECS with a
specific IP address.</p>
<div class="note note note_note"><span class="note__title">Note:</span>
<p class="p">To obtain <em class="ph i">IP-address</em>: </p>
<ol class="ol" id="Search_Method__ol_fd3_cvl_wnb">
<li class="li">In the left navigation page of the ECS console, click <strong class="ph b">Instance</strong>.</li>
<li class="li">On the<strong class="ph b"> Instance Management</strong> page, click the instance name. The IP address
of the ECS instance is displayed in the <strong class="ph b">Intranet IP </strong>field on the
<strong class="ph b">Instance Information</strong> page.</li>
</ol>
</div>
<img class="image" id="Search_Method__image_igl_sb1_xmb" src="https://obs-cn-shanghai.yun.pingan.com/pcp-portal/20210106133703-12b77f1d9579.png" width="830">
<p class="p">Example 4: Use file:<em class="ph i">file-name</em>to query logs under a specific collection path.</p>
<div class="note note note_note"><span class="note__title">Note:</span>
<p class="p">To obtain <em class="ph i">file-name</em>: </p>
<ol class="ol" id="Search_Method__ol_gyt_fvl_wnb">
<li class="li">In the left navigation pane of the Log Service console, click <strong class="ph b">Project
Management</strong>. </li>
<li class="li">On the <strong class="ph b">Project Management</strong> page, click the target project name. </li>
<li class="li">Click the <strong class="ph b">AGENT CONFIG</strong> tab to view the target path.</li>
</ol>
</div>
<img class="image" id="Search_Method__image_el4_xb1_xmb" src="https://obs-cn-shanghai.yun.pingan.com/pcp-portal/20210106133703-126af4249eb2.png" width="830">
<p class="p"><strong class="ph b">Method 2:</strong> For Nginx logs, if the content to be queried is of the double or long
type, you can specify a value range.</p>
<p class="p">For example, to query logs for HTTP requests whose request time (request processing time)
is more than 300 milliseconds and return status is not 200, use request_time> 300 AND
NOT status: 200.</p>
<p class="p"><strong class="ph b">Query by Combination of Criteria </strong></p>
<p class="p">This method queries logs by using the combination of keywords and query operators, such
as AND, OR, and parentheses (( )).</p>
<ul class="ul" id="Search_Method__ul_xmv_kvl_wnb">
<li class="li">Example 1: Use appname:Project1<em class="ph i">_UUID</em> AND (collector_node_id:10.0.0.2 OR
collector_node_id:10.0.0.3) AND "hello world" to query logs that meet the following
requirements:<ul class="ul" id="Search_Method__ul_ymv_kvl_wnb">
<li class="li">Belonging to Project1.</li>
<li class="li">Collected from ECS 10.0.0.2 or 10.0.0.</li>
<li class="li">Containing the keyword hello world.</li>
</ul></li>
<li class="li">Example 2: Use ((source: HOST1 OR source: HOST2) AND (file: /var/log/*.log)) AND
"hello world" to query logs that meet the following requirements:<ul class="ul" id="Search_Method__ul_zmv_kvl_wnb">
<li class="li">Containing "hello world" </li>
<li class="li">Collected from /var/log/*.log on HOST1 or HOST2.</li>
</ul></li>
</ul>
Did the above content solve your problem?
Yes
No
Submitted successfully! Thank you for your feedback, we will try our best to do better and better!