

Terjemahan disediakan oleh mesin penerjemah. Jika konten terjemahan yang diberikan bertentangan dengan versi bahasa Inggris aslinya, utamakan versi bahasa Inggris.

# Kueri untuk permintaan atau alamat yang diblokir
<a name="query-examples-waf-logs-blocked-requests"></a>

Contoh di bagian ini meminta permintaan atau alamat yang diblokir.
+ [Extract the top 100 IP addresses blocked by a specified rule type](#waf-example-extract-top-100-blocked-ip-by-rule)
+ [Count the number of times a request from a specified country has been blocked](#waf-example-count-request-blocks-from-country)
+ [Count the number of times a request has been blocked, grouping by specific attributes](#waf-example-count-request-blocks-by-attribute)
+ [Count the number of times a specific terminating rule ID has been matched](#waf-example-count-terminating-rule-id-matches)
+ [Retrieve the top 100 IP addresses blocked during a specified date range](#waf-example-top-100-ip-addresses-blocked-for-date-range)

**Example — Ekstrak 100 alamat IP teratas yang diblokir oleh jenis aturan tertentu**  
Kueri berikut ekstrak dan menghitung atas 100 alamat IP yang telah diblokir oleh`RATE_BASED`mengakhiri aturan selama rentang tanggal yang ditentukan.  

```
SELECT COUNT(httpRequest.clientIp) as count,
httpRequest.clientIp
FROM waf_logs
WHERE terminatingruletype='RATE_BASED' AND action='BLOCK' and "date" >= '2021/03/01'
AND "date" < '2021/03/31'
GROUP BY httpRequest.clientIp
ORDER BY count DESC
LIMIT 100
```

**Example — Hitung berapa kali permintaan dari negara tertentu telah diblokir**  
Kueri berikut menghitung jumlah kali permintaan telah tiba dari alamat IP milik Irlandia (IE) dan telah diblokir oleh`RATE_BASED`mengakhiri aturan.  

```
SELECT 
  COUNT(httpRequest.country) as count, 
  httpRequest.country 
FROM waf_logs
WHERE 
  terminatingruletype='RATE_BASED' AND 
  httpRequest.country='IE'
GROUP BY httpRequest.country
ORDER BY count
LIMIT 100;
```

**Example — Hitung berapa kali permintaan diblokir, dikelompokkan berdasarkan atribut tertentu**  
Kueri berikut menghitung berapa kali permintaan telah diblokir, dengan hasil dikelompokkan berdasarkan WebACL,, Clientip RuleId, dan HTTP Request URI.  

```
SELECT 
  COUNT(*) AS count,
  webaclid,
  terminatingruleid,
  httprequest.clientip,
  httprequest.uri
FROM waf_logs
WHERE action='BLOCK'
GROUP BY webaclid, terminatingruleid, httprequest.clientip, httprequest.uri
ORDER BY count DESC
LIMIT 100;
```

**Example — Hitung berapa kali ID aturan penghentian tertentu telah dicocokkan**  
Kueri berikut menghitung berapa kali ID aturan terminating tertentu telah dicocokkan (`WHERE terminatingruleid='e9dd190d-7a43-4c06-bcea-409613d9506e'`). Kueri kemudian grup hasil dengan WebACL, Action, ClientIP, dan HTTP Request URI.  

```
SELECT 
  COUNT(*) AS count,
  webaclid,
  action,
  httprequest.clientip,
  httprequest.uri
FROM waf_logs
WHERE terminatingruleid='e9dd190d-7a43-4c06-bcea-409613d9506e'
GROUP BY webaclid, action, httprequest.clientip, httprequest.uri
ORDER BY count DESC
LIMIT 100;
```

**Example — Ambil 100 alamat IP teratas yang diblokir selama rentang tanggal tertentu**  
Kueri berikut ekstrak atas 100 alamat IP yang telah diblokir untuk rentang tanggal yang ditentukan. Kueri juga mencantumkan berapa kali alamat IP telah diblokir.  

```
SELECT "httprequest"."clientip", "count"(*) "ipcount", "httprequest"."country"
FROM waf_logs
WHERE "action" = 'BLOCK' and "date" >= '2021/03/01'
AND "date" < '2021/03/31'
GROUP BY "httprequest"."clientip", "httprequest"."country"
ORDER BY "ipcount" DESC limit 100
```