doc-exports/docs/rds/api-ref/rds_06_0005.html
Wang , Deng Ke 21e968a153 rds api 2.0.38sp24 version
Reviewed-by: Hasko, Vladimir <vladimir.hasko@t-systems.com>
Co-authored-by: Wang , Deng Ke <wangdengke2@huawei.com>
Co-committed-by: Wang , Deng Ke <wangdengke2@huawei.com>
2023-01-12 13:50:31 +00:00

235 lines
19 KiB
HTML

<a name="rds_06_0005"></a><a name="rds_06_0005"></a>
<h1 class="topictitle1">Querying Database Slow Logs</h1>
<div id="body1544167946150"><div class="section" id="rds_06_0005__section61759636"><h4 class="sectiontitle">Function</h4><p id="rds_06_0005__p33831530">This API is used to query the latest 2000 database slow query logs.</p>
<ul id="rds_06_0005__ul12259155218373"><li id="rds_06_0005__en-us_topic_0240111818_li836513175363">Before calling an API, you need to understand the API in <a href="rds_03_0001.html">Authentication</a>.</li><li id="rds_06_0005__en-us_topic_0240111818_li1991981933613">Before calling this API, obtain the required <a href="https://docs.otc.t-systems.com/en-us/endpoint/index.html" target="_blank" rel="noopener noreferrer">region and endpoint</a>.</li></ul>
</div>
<div class="section" id="rds_06_0005__section18965813"><h4 class="sectiontitle">URI</h4><ul id="rds_06_0005__ul13194498"><li id="rds_06_0005__li41603465301">URI format<p id="rds_06_0005__p11160246123012"><a name="rds_06_0005__li41603465301"></a><a name="li41603465301"></a>GET https://{<em id="rds_06_0005__i1288545311165">Endpoint</em>}/v3/{project_id}/instances/{instance_id}/slowlog?start_date={start_date}&amp;end_date={end_date}</p>
</li></ul>
<ul id="rds_06_0005__ul55999443"><li id="rds_06_0005__li21405046">Parameter description
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="rds_06_0005__table58427690" frame="border" border="1" rules="all"><caption><b>Table 1 </b>Parameter description</caption><thead align="left"><tr id="rds_06_0005__row1482002"><th align="left" class="cellrowborder" valign="top" width="21%" id="mcps1.3.2.3.1.1.2.4.1.1"><p id="rds_06_0005__p52933326"><strong id="rds_06_0005__b84235270691445">Name</strong></p>
</th>
<th align="left" class="cellrowborder" valign="top" width="24%" id="mcps1.3.2.3.1.1.2.4.1.2"><p id="rds_06_0005__p59740974"><strong id="rds_06_0005__b1882434014210">Mandatory</strong></p>
</th>
<th align="left" class="cellrowborder" valign="top" width="55.00000000000001%" id="mcps1.3.2.3.1.1.2.4.1.3"><p id="rds_06_0005__p7180698"><strong id="rds_06_0005__b842352706163417">Description</strong></p>
</th>
</tr>
</thead>
<tbody><tr id="rds_06_0005__row44765691"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.3.2.3.1.1.2.4.1.1 "><p id="rds_06_0005__p2142393">project_id</p>
</td>
<td class="cellrowborder" valign="top" width="24%" headers="mcps1.3.2.3.1.1.2.4.1.2 "><p id="rds_06_0005__p39316155">Yes</p>
</td>
<td class="cellrowborder" valign="top" width="55.00000000000001%" headers="mcps1.3.2.3.1.1.2.4.1.3 "><p id="rds_06_0005__p30492010">Specifies the project ID of a tenant in a region.</p>
<p id="rds_06_0005__p18985742094">For details about how to obtain the project ID, see <a href="rds_03_0002.html">Obtaining a Project ID</a>.</p>
</td>
</tr>
<tr id="rds_06_0005__row5992637"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.3.2.3.1.1.2.4.1.1 "><p id="rds_06_0005__p15641626">instance_id</p>
</td>
<td class="cellrowborder" valign="top" width="24%" headers="mcps1.3.2.3.1.1.2.4.1.2 "><p id="rds_06_0005__p59012183">Yes</p>
</td>
<td class="cellrowborder" valign="top" width="55.00000000000001%" headers="mcps1.3.2.3.1.1.2.4.1.3 "><p id="rds_06_0005__p15257500">Specifies the ID of the queried DB instance.</p>
</td>
</tr>
<tr id="rds_06_0005__row241814298545"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.3.2.3.1.1.2.4.1.1 "><p id="rds_06_0005__p24007821174547">start_date</p>
</td>
<td class="cellrowborder" valign="top" width="24%" headers="mcps1.3.2.3.1.1.2.4.1.2 "><p id="rds_06_0005__p65585369174547">Yes</p>
</td>
<td class="cellrowborder" valign="top" width="55.00000000000001%" headers="mcps1.3.2.3.1.1.2.4.1.3 "><p id="rds_06_0005__p10814706174547">Specifies the start date in the "yyyy-mm-ddThh:mm:ssZ" format.</p>
<p id="rds_06_0005__p442615191195"><strong id="rds_06_0005__b983044010216">T</strong> is the separator between the calendar and the hourly notation of time. <strong id="rds_06_0005__b12830124092120">Z</strong> indicates the time zone offset. </p>
</td>
</tr>
<tr id="rds_06_0005__row205151333105411"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.3.2.3.1.1.2.4.1.1 "><p id="rds_06_0005__p32183997174547">end_date</p>
</td>
<td class="cellrowborder" valign="top" width="24%" headers="mcps1.3.2.3.1.1.2.4.1.2 "><p id="rds_06_0005__p56766964174547">Yes</p>
</td>
<td class="cellrowborder" valign="top" width="55.00000000000001%" headers="mcps1.3.2.3.1.1.2.4.1.3 "><p id="rds_06_0005__p79271845194012">Specifies the end time in the "yyyy-mm-ddThh:mm:ssZ" format.</p>
<p id="rds_06_0005__p494616411342"><strong id="rds_06_0005__b47652772616">T</strong> is the separator between the calendar and the hourly notation of time. <strong id="rds_06_0005__b1677227192611">Z</strong> indicates the time zone offset. You can only query slow logs generated within a month.</p>
</td>
</tr>
<tr id="rds_06_0005__row6701931155415"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.3.2.3.1.1.2.4.1.1 "><p id="rds_06_0005__p11832481174547">offset</p>
</td>
<td class="cellrowborder" valign="top" width="24%" headers="mcps1.3.2.3.1.1.2.4.1.2 "><p id="rds_06_0005__p18906893174547">No</p>
</td>
<td class="cellrowborder" valign="top" width="55.00000000000001%" headers="mcps1.3.2.3.1.1.2.4.1.3 "><p id="rds_06_0005__p55063325174547">Specifies the page offset, such as 1, 2, 3, or 4. The parameter value is <strong id="rds_06_0005__b842352706164811">1</strong> by default if it is not specified.</p>
</td>
</tr>
<tr id="rds_06_0005__row15563113513549"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.3.2.3.1.1.2.4.1.1 "><p id="rds_06_0005__p10063368174547">limit</p>
</td>
<td class="cellrowborder" valign="top" width="24%" headers="mcps1.3.2.3.1.1.2.4.1.2 "><p id="rds_06_0005__p9826466174547">No</p>
</td>
<td class="cellrowborder" valign="top" width="55.00000000000001%" headers="mcps1.3.2.3.1.1.2.4.1.3 "><p id="rds_06_0005__p57746301174547">Specifies the number of records on a page. Its value range is from 1 to 100. The parameter value is <strong id="rds_06_0005__b842352706164925">10</strong> by default if it is not specified.</p>
</td>
</tr>
<tr id="rds_06_0005__row1094152745413"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.3.2.3.1.1.2.4.1.1 "><p id="rds_06_0005__p956544614368">type</p>
</td>
<td class="cellrowborder" valign="top" width="24%" headers="mcps1.3.2.3.1.1.2.4.1.2 "><p id="rds_06_0005__p1193327112018">No</p>
</td>
<td class="cellrowborder" valign="top" width="55.00000000000001%" headers="mcps1.3.2.3.1.1.2.4.1.3 "><p id="rds_06_0005__p2053145617536">Specifies the statement type. If it is left blank, all statement types are queried. Valid value:</p>
<ul id="rds_06_0005__ul1281145815538"><li id="rds_06_0005__li115141015414">INSERT</li><li id="rds_06_0005__li7588523548">UPDATE</li><li id="rds_06_0005__li397815385412">SELECT</li><li id="rds_06_0005__li1161666544">DELETE</li><li id="rds_06_0005__li158120588535">CREATE</li></ul>
</td>
</tr>
</tbody>
</table>
</div>
</li></ul>
</div>
<div class="section" id="rds_06_0005__section36474591"><h4 class="sectiontitle">Request</h4><ul id="rds_06_0005__ul1183180183717"><li id="rds_06_0005__li1283110163719">Request parameters<p id="rds_06_0005__p848415163614"><a name="rds_06_0005__li1283110163719"></a><a name="li1283110163719"></a>None</p>
</li></ul>
<ul id="rds_06_0005__ul51575500564"><li id="rds_06_0005__li4411135064210">Example<p id="rds_06_0005__p1454414211213"><a name="rds_06_0005__li4411135064210"></a><a name="li4411135064210"></a>GET https://rds.eu-de.otc.t-systems.com/v3/0483b6b16e954cb88930a360d2c4e663/instances/cee5265e1e5845649e354841234567dfin01/slowlog?offset=1&amp;limit=10&amp;start_date=2018-08-06T10:41:14+0800&amp;end_date=2018-08-07T10:41:14+0800&amp;type=INSERT</p>
</li></ul>
</div>
<div class="section" id="rds_06_0005__section59835867"><h4 class="sectiontitle">Response</h4><ul id="rds_06_0005__ul66273227"><li id="rds_06_0005__li59588135">Normal response
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="rds_06_0005__table29752153" frame="border" border="1" rules="all"><caption><b>Table 2 </b>Parameter description</caption><thead align="left"><tr id="rds_06_0005__row62070345"><th align="left" class="cellrowborder" valign="top" width="19.040000000000003%" id="mcps1.3.4.2.1.1.2.4.1.1"><p id="rds_06_0005__p61642077"><strong id="rds_06_0005__b232101342">Name</strong></p>
</th>
<th align="left" class="cellrowborder" valign="top" width="47.63%" id="mcps1.3.4.2.1.1.2.4.1.2"><p id="rds_06_0005__p26952341"><strong id="rds_06_0005__b842352706164541">Type</strong></p>
</th>
<th align="left" class="cellrowborder" valign="top" width="33.33%" id="mcps1.3.4.2.1.1.2.4.1.3"><p id="rds_06_0005__p35656026"><strong id="rds_06_0005__b518355602">Description</strong></p>
</th>
</tr>
</thead>
<tbody><tr id="rds_06_0005__row49943891183823"><td class="cellrowborder" valign="top" width="19.040000000000003%" headers="mcps1.3.4.2.1.1.2.4.1.1 "><p id="rds_06_0005__p17747976183823">slow_log_list</p>
</td>
<td class="cellrowborder" valign="top" width="47.63%" headers="mcps1.3.4.2.1.1.2.4.1.2 "><p id="rds_06_0005__p28299952183823">Array of objects</p>
</td>
<td class="cellrowborder" valign="top" width="33.33%" headers="mcps1.3.4.2.1.1.2.4.1.3 "><p id="rds_06_0005__p10594789183823">Indicates detailed information.</p>
<p id="rds_06_0005__p12254535568">For details, see <a href="#rds_06_0005__table66531170">Table 3</a>.</p>
</td>
</tr>
<tr id="rds_06_0005__row6331999514368"><td class="cellrowborder" valign="top" width="19.040000000000003%" headers="mcps1.3.4.2.1.1.2.4.1.1 "><p id="rds_06_0005__p27570747143630">total_record</p>
</td>
<td class="cellrowborder" valign="top" width="47.63%" headers="mcps1.3.4.2.1.1.2.4.1.2 "><p id="rds_06_0005__p18638029143630">Integer</p>
</td>
<td class="cellrowborder" valign="top" width="33.33%" headers="mcps1.3.4.2.1.1.2.4.1.3 "><p id="rds_06_0005__p33285367143630">Indicates the total number of records.</p>
</td>
</tr>
</tbody>
</table>
</div>
<div class="tablenoborder"><a name="rds_06_0005__table66531170"></a><a name="table66531170"></a><table cellpadding="4" cellspacing="0" summary="" id="rds_06_0005__table66531170" frame="border" border="1" rules="all"><caption><b>Table 3 </b>slow_log_list field data structure description</caption><thead align="left"><tr id="rds_06_0005__row12984378"><th align="left" class="cellrowborder" valign="top" width="19.040000000000003%" id="mcps1.3.4.2.1.2.2.4.1.1"><p id="rds_06_0005__p45101667"><strong id="rds_06_0005__b1314582541">Name</strong></p>
</th>
<th align="left" class="cellrowborder" valign="top" width="13.22%" id="mcps1.3.4.2.1.2.2.4.1.2"><p id="rds_06_0005__p29356372"><strong id="rds_06_0005__b952825224">Type</strong></p>
</th>
<th align="left" class="cellrowborder" valign="top" width="67.74%" id="mcps1.3.4.2.1.2.2.4.1.3"><p id="rds_06_0005__p29055926"><strong id="rds_06_0005__b795743230">Description</strong></p>
</th>
</tr>
</thead>
<tbody><tr id="rds_06_0005__row4719792"><td class="cellrowborder" valign="top" width="19.040000000000003%" headers="mcps1.3.4.2.1.2.2.4.1.1 "><p id="rds_06_0005__p46758891">count</p>
</td>
<td class="cellrowborder" valign="top" width="13.22%" headers="mcps1.3.4.2.1.2.2.4.1.2 "><p id="rds_06_0005__p29373839">String</p>
</td>
<td class="cellrowborder" valign="top" width="67.74%" headers="mcps1.3.4.2.1.2.2.4.1.3 "><p id="rds_06_0005__p30470722">Indicates the number of executions.</p>
</td>
</tr>
<tr id="rds_06_0005__row5801050"><td class="cellrowborder" valign="top" width="19.040000000000003%" headers="mcps1.3.4.2.1.2.2.4.1.1 "><p id="rds_06_0005__p123050">time</p>
</td>
<td class="cellrowborder" valign="top" width="13.22%" headers="mcps1.3.4.2.1.2.2.4.1.2 "><p id="rds_06_0005__p9967070">String</p>
</td>
<td class="cellrowborder" valign="top" width="67.74%" headers="mcps1.3.4.2.1.2.2.4.1.3 "><p id="rds_06_0005__p2026335">Indicates the execution time.</p>
</td>
</tr>
<tr id="rds_06_0005__row1562610185558"><td class="cellrowborder" valign="top" width="19.040000000000003%" headers="mcps1.3.4.2.1.2.2.4.1.1 "><p id="rds_06_0005__p27564685185558">lock_time</p>
</td>
<td class="cellrowborder" valign="top" width="13.22%" headers="mcps1.3.4.2.1.2.2.4.1.2 "><p id="rds_06_0005__p18147022185558">String</p>
</td>
<td class="cellrowborder" valign="top" width="67.74%" headers="mcps1.3.4.2.1.2.2.4.1.3 "><p id="rds_06_0005__p60622679185558">Indicates the lock wait time.</p>
<p id="rds_06_0005__p9255016162718">This parameter is not present in the response for PostgreSQL DB engine.</p>
</td>
</tr>
<tr id="rds_06_0005__row46227617185624"><td class="cellrowborder" valign="top" width="19.040000000000003%" headers="mcps1.3.4.2.1.2.2.4.1.1 "><p id="rds_06_0005__p61882053185624">rows_sent</p>
</td>
<td class="cellrowborder" valign="top" width="13.22%" headers="mcps1.3.4.2.1.2.2.4.1.2 "><p id="rds_06_0005__p46390393185624">String</p>
</td>
<td class="cellrowborder" valign="top" width="67.74%" headers="mcps1.3.4.2.1.2.2.4.1.3 "><p id="rds_06_0005__p66634382185624">Indicates the number of sent rows.</p>
<p id="rds_06_0005__p12173173002717">This parameter is not present in the response for PostgreSQL DB engine.</p>
</td>
</tr>
<tr id="rds_06_0005__row26041859185714"><td class="cellrowborder" valign="top" width="19.040000000000003%" headers="mcps1.3.4.2.1.2.2.4.1.1 "><p id="rds_06_0005__p62791567185714">rows_examined</p>
</td>
<td class="cellrowborder" valign="top" width="13.22%" headers="mcps1.3.4.2.1.2.2.4.1.2 "><p id="rds_06_0005__p52952143185714">String</p>
</td>
<td class="cellrowborder" valign="top" width="67.74%" headers="mcps1.3.4.2.1.2.2.4.1.3 "><p id="rds_06_0005__p61265200185714">Indicates the number of scanned rows.</p>
<p id="rds_06_0005__p195083942719">This parameter is not present in the response for PostgreSQL DB engine.</p>
</td>
</tr>
<tr id="rds_06_0005__row8051277185753"><td class="cellrowborder" valign="top" width="19.040000000000003%" headers="mcps1.3.4.2.1.2.2.4.1.1 "><p id="rds_06_0005__p65936923185753">database</p>
</td>
<td class="cellrowborder" valign="top" width="13.22%" headers="mcps1.3.4.2.1.2.2.4.1.2 "><p id="rds_06_0005__p39290538185753">String</p>
</td>
<td class="cellrowborder" valign="top" width="67.74%" headers="mcps1.3.4.2.1.2.2.4.1.3 "><p id="rds_06_0005__p28417034185753">Indicates the database which the slow log belongs to.</p>
</td>
</tr>
<tr id="rds_06_0005__row62737284185755"><td class="cellrowborder" valign="top" width="19.040000000000003%" headers="mcps1.3.4.2.1.2.2.4.1.1 "><p id="rds_06_0005__p65776751185755">users</p>
</td>
<td class="cellrowborder" valign="top" width="13.22%" headers="mcps1.3.4.2.1.2.2.4.1.2 "><p id="rds_06_0005__p26316620185755">String</p>
</td>
<td class="cellrowborder" valign="top" width="67.74%" headers="mcps1.3.4.2.1.2.2.4.1.3 "><p id="rds_06_0005__p51271494185755">Indicates the account.</p>
</td>
</tr>
<tr id="rds_06_0005__row24608043185759"><td class="cellrowborder" valign="top" width="19.040000000000003%" headers="mcps1.3.4.2.1.2.2.4.1.1 "><p id="rds_06_0005__p60502836185759">query_sample</p>
</td>
<td class="cellrowborder" valign="top" width="13.22%" headers="mcps1.3.4.2.1.2.2.4.1.2 "><p id="rds_06_0005__p1782674185759">String</p>
</td>
<td class="cellrowborder" valign="top" width="67.74%" headers="mcps1.3.4.2.1.2.2.4.1.3 "><p id="rds_06_0005__p10178909185759">Indicates the execution syntax.</p>
</td>
</tr>
<tr id="rds_06_0005__row2025783011386"><td class="cellrowborder" valign="top" width="19.040000000000003%" headers="mcps1.3.4.2.1.2.2.4.1.1 "><p id="rds_06_0005__p325819308383">type</p>
</td>
<td class="cellrowborder" valign="top" width="13.22%" headers="mcps1.3.4.2.1.2.2.4.1.2 "><p id="rds_06_0005__p132581130143820">String</p>
</td>
<td class="cellrowborder" valign="top" width="67.74%" headers="mcps1.3.4.2.1.2.2.4.1.3 "><p id="rds_06_0005__p16258530153812">Indicates the statement type.</p>
</td>
</tr>
<tr id="rds_06_0005__row1231875112369"><td class="cellrowborder" valign="top" width="19.040000000000003%" headers="mcps1.3.4.2.1.2.2.4.1.1 "><p id="rds_06_0005__p65886183815">start_time</p>
</td>
<td class="cellrowborder" valign="top" width="13.22%" headers="mcps1.3.4.2.1.2.2.4.1.2 "><p id="rds_06_0005__p115881219388">String</p>
</td>
<td class="cellrowborder" valign="top" width="67.74%" headers="mcps1.3.4.2.1.2.2.4.1.3 "><p id="rds_06_0005__p185881613381">Indicates the time in the UTC format.</p>
</td>
</tr>
<tr id="rds_06_0005__row0376204863619"><td class="cellrowborder" valign="top" width="19.040000000000003%" headers="mcps1.3.4.2.1.2.2.4.1.1 "><p id="rds_06_0005__p8588161113810">client_ip</p>
</td>
<td class="cellrowborder" valign="top" width="13.22%" headers="mcps1.3.4.2.1.2.2.4.1.2 "><p id="rds_06_0005__p658815117386">String</p>
</td>
<td class="cellrowborder" valign="top" width="67.74%" headers="mcps1.3.4.2.1.2.2.4.1.3 "><p id="rds_06_0005__p458919153810">Indicates the IP address.</p>
</td>
</tr>
</tbody>
</table>
</div>
</li></ul>
<ul id="rds_06_0005__ul26818564"><li id="rds_06_0005__li40040492">Example normal response<pre class="codeblock" id="rds_06_0005__codeblock1595400517759">{
"total_record": 1,
"slow_log_list": [
{
"count": "1",
"time": "1.04899 s",
"lock_time": "0.00003 s",
"rows_sent": "0",
"rows_examined": "0",
"database": "mysql",
"users": "root",
"query_sample": "INSERT INTO time_zone_name (Name, Time_zone_id) VALUES (N, @time_zone_id);",
"type": "INSERT",
"start_time": "2018-08-06T10:41:14",
"client_ip": "192.*.*.1"
}
]
}</pre>
</li><li id="rds_06_0005__li15461118163817">Abnormal Response<p id="rds_06_0005__p46896054"><a name="rds_06_0005__li15461118163817"></a><a name="li15461118163817"></a>For details, see <a href="en-us_topic_0032488197.html">Abnormal Request Results</a>.</p>
</li></ul>
</div>
<div class="section" id="rds_06_0005__section4778540915440"><h4 class="sectiontitle">Status Code</h4><ul id="rds_06_0005__en-us_topic_0032347778_ul7858132212142"><li id="rds_06_0005__en-us_topic_0032347778_li58581622171411">Normal<p id="rds_06_0005__en-us_topic_0032347778_p1040982941020"><a name="rds_06_0005__en-us_topic_0032347778_li58581622171411"></a><a name="en-us_topic_0032347778_li58581622171411"></a>200</p>
</li><li id="rds_06_0005__en-us_topic_0032347778_li11583183218149">Abnormal<p id="rds_06_0005__en-us_topic_0032347778_p0723374409"><a name="rds_06_0005__en-us_topic_0032347778_li11583183218149"></a><a name="en-us_topic_0032347778_li11583183218149"></a>For details, see <a href="en-us_topic_0032488240.html">Status Codes</a>.</p>
</li></ul>
</div>
<div class="section" id="rds_06_0005__section1183074220016"><h4 class="sectiontitle">Error Code</h4><p id="rds_06_0005__en-us_topic_0032347778_p19357163913406">For details, see <a href="en-us_topic_0032488241.html">Error Codes</a>.</p>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="en-us_topic_0056887472.html">Log Information Queries</a></div>
</div>
</div>