Chuyển tới nội dung chính

Kiểm tra integration log của Webhook

Cách webhook ghi log​

Mỗi lần gửi webhook, WebhookServiceImpl tự động ghi log qua IntegrationLogService (async) với các thông tin:

TrườngGiá trị
codeWEBHOOK_{tenantId} (ví dụ: WEBHOOK_123)
operationWEBHOOK_SEND
systemNEBULA
statusSUCCESS hoặc FAILED
requestWebhook config id, method, url, request body
responseResponse body (thành công) hoặc error message (thất bại)
userIdtenantId (dạng String)

Kiểm tra qua Admin API​

Endpoint​

POST /api/general/control/integration-log/filter

Các trường có thể filter​

TrườngGiá trị để filter webhook
codeWEBHOOK_{tenantId} (ví dụ: WEBHOOK_123)
integrationOperationWEBHOOK_SEND
integrationSystemNEBULA
integrationStatusSUCCESS hoặc FAILED
userIdtenantId

Hỗ trợ pagination và sort (mặc định sort DESC theo id = mới nhất trước).

Endpoint xem chi tiết​

GET /api/general/control/integration-log/detail/{id}

Kiểm tra bằng SQL​

Tìm tất cả webhook log của một tenant​

SELECT id, code, integration_status, request, response, created_date
FROM integration_log
WHERE code = 'WEBHOOK_123'
AND integration_operation = 'WEBHOOK_SEND'
ORDER BY created_date DESC
LIMIT 20;

Tìm webhook thất bại​

SELECT id, code, request, response, created_date
FROM integration_log
WHERE integration_operation = 'WEBHOOK_SEND'
AND integration_status = 'FAILED'
ORDER BY created_date DESC
LIMIT 50;

Tìm webhook theo khoảng thời gian​

SELECT id, code, integration_status, response, created_date
FROM integration_log
WHERE integration_operation = 'WEBHOOK_SEND'
AND created_date BETWEEN '2024-03-01' AND '2024-03-28'
ORDER BY created_date DESC;

Kiểm tra Webhook Execution​

Bảng webhook_execution lưu chi tiết hơn integration log: URL, headers, request/response body, mã HTTP, số lần retry, lỗi, thời gian retry tiếp theo.

Các trường của WebhookExecution​

TrườngKiểuMô tả
idLongID tự tăng
tenant_idLongID tenant
webhook_idLongID của TenantWebhook config
urlStringURL đã gửi
headersText (JSON)Headers đã gửi (bao gồm auth)
request_bodyTextRequest body đã gửi
statusInteger1=RETRY_FAILED, 2=SUCCESS, 3=FAILED, 4=RETRYING
http_status_codeIntegerMã HTTP nhận được
response_bodyTextResponse body nhận được
last_errorStringThông báo lỗi cuối cùng
retry_countIntegerSố lần đã retry
max_retriesIntegerSố lần retry tối đa (mặc định 3)
retry_policyInteger1=EXPONENTIAL_BACKOFF, 2=IMMEDIATE
next_execution_timeDateTimeThời gian retry tiếp theo
created_dateDateTimeThời gian tạo

Tìm execution theo tenant​

SELECT id, url, status, http_status_code, retry_count, last_error, created_date
FROM webhook_execution
WHERE tenant_id = 123
ORDER BY created_date DESC
LIMIT 20;

Tìm execution thất bại chưa retry hết​

SELECT id, tenant_id, url, status, retry_count, max_retries, next_execution_time, last_error
FROM webhook_execution
WHERE status = 1 -- RETRY_FAILED
ORDER BY next_execution_time ASC;

Tìm execution đang chờ retry (sắp được xử lý)​

SELECT id, tenant_id, url, retry_count, next_execution_time
FROM webhook_execution
WHERE status = 1 -- RETRY_FAILED
AND next_execution_time <= NOW()
ORDER BY next_execution_time ASC
LIMIT 100;

Tìm execution thất bại vĩnh viễn​

SELECT id, tenant_id, url, http_status_code, retry_count, last_error, created_date
FROM webhook_execution
WHERE status = 3 -- FAILED (hết retry)
ORDER BY created_date DESC
LIMIT 50;

Thống kê execution theo status​

SELECT
CASE status
WHEN 1 THEN 'RETRY_FAILED'
WHEN 2 THEN 'SUCCESS'
WHEN 3 THEN 'FAILED'
WHEN 4 THEN 'RETRYING'
END AS status_name,
COUNT(*) AS total
FROM webhook_execution
WHERE tenant_id = 123
GROUP BY status;

So sánh Integration Log và Webhook Execution​

Integration LogWebhook Execution
Mục đíchGhi log tổng quanTheo dõi chi tiết từng lần gửi
Thông tinRequest/response dạng textURL, headers, body, mã trạng thái, thông tin retry
Retry infoKhông cóCó: retry_count, max_retries, next_execution_time
Dùng khiKiểm tra nhanh thành công/thất bạiDebug chi tiết, kiểm tra retry, xem response