Mình ví dụ bạn có log như sau dưới dạng Json
{
"logRecord": {
"attributes": {
"cluster_name": "prod-region-cluster-name",
"log.file.path": "/var/log/pods/namespace_pod-name_pod-uid/container-name/0.log",
"log.iostream": "stdout",
"logtag": "F",
"time": "2025-10-17T06:59:59.829749004Z"
},
"body": {
"current_level": 2,
"current_number": 342,
"dataId": "example_data_id_12345::fb5827455d",
"engines": [
"comodo",
"zillya",
"aegislab",
"clamav",
"cmc",
"k7",
"nano",
"cyren",
"mcafee",
"viritml",
"xviruspersonalguard",
"webroot",
"emsisoft",
"ahnlab",
"quickheal",
"tachyon",
"filseclab",
"bkav",
"viritexplorer",
"avira",
"rocketcyber",
"ikarus",
"bitdefender",
"archive"
],
"esIndexName": "results",
"fileInfo": {
"child_file_start_timestamp": "2025-10-17T06:59:59.242Z",
"display_name": "example-file.js",
"file_extensions": "JS",
"file_size": 4012,
"file_type": "application/javascript",
"file_type_description": "JavaScript Source",
"md5": "REDACTED_MD5_HASH",
"sha1": "REDACTED_SHA1_HASH",
"sha256": "REDACTED_SHA256_HASH",
"type_category": ["T"]
},
"filetypeInfo": {
"file_info": {
"description": "JavaScript Source",
"detected_by": "ML Detection Model",
"encrypted": false,
"extensions": "js",
"groupID": "T",
"groupIDs": ["T"],
"group_description": "Text Files",
"likely_type_ids": [
{
"score": 1,
"typeID": "JS"
},
{
"score": 0.8,
"typeID": "TXT"
}
],
"type": "application/javascript",
"typeID": "JS",
"type_ids": ["JS"]
},
"final_verdict": {
"verdict": "allowed",
"verdict_explanation": []
},
"other_detections": [
{
"description": "JS",
"detector": "Magika",
"score": 1
},
{
"description": "",
"detector": "TrID",
"score": 1
},
{
"description": "ASCII text",
"detector": "libmagic",
"score": 1
}
],
"result_template_hash": "example_template_hash_abc123",
"spoofing_info": {
"detection_result": "Not Configured",
"result_explanation": "",
"result_overview": "Spoofing Detection Was Not Configured"
},
"version": 2
},
"parentId": "example_parent_id_67890::ab468caeec",
"priority": "ARCHIVE",
"processInfo": {
"blocked_reasons": [],
"failure_reasons": [],
"post_processing": {
"actions_failed": "",
"actions_ran": "",
"converted_destination": "",
"converted_to": "",
"copy_move_destination": "",
"sanitization_details": {
"description": "",
"details": "",
"failure_category": "",
"sanitized_file_info": {
"data_id": "",
"file_path": "/path/to/file",
"file_size": 0,
"md5": "",
"sha1": "",
"sha256": ""
}
}
},
"processing_time": 23769,
"processing_time_details": {
"aggregated_time": 472,
"archive_time": 0,
"av_scan_time": 216,
"cdr_time": 0,
"coo_time": 0,
"dlp_time": 0,
"download_time": 51,
"filescanio_time": 0,
"filetype_time": 266,
"oesis_time": 0,
"others_time": 0,
"sbom_time": 0,
"total_inqueue_time": 23769
},
"progress_percentage": 100,
"result": "Allowed",
"verdicts": ["No Threat Detected"]
},
"requestId": "example_request_id_abc123",
"scanResults": {
"current_av_result_a": "No Threat Detected",
"current_av_result_i": 0,
"data_id": "example_data_id_12345::fb5827455d",
"first_response_received_by_apiv4handler_timestamp": "2025-10-17T06:59:34.501Z",
"first_response_received_by_resulthandler_timestamp": "2025-10-17T06:59:34.513Z",
"last_response_aggregated_by_apiv4handler_timestamp": "2025-10-17T06:59:59.803Z",
"last_response_received_by_resulthandler_timestamp": "2025-10-17T06:59:59.802Z",
"request_processed_by_request_handler_timestamp": "2025-10-17T06:59:34.515Z",
"request_received_from_scantopic_timestamp": "2025-10-17T06:59:34.361Z",
"scan_all_result_a": "No Threat Detected",
"scan_all_result_i": 0,
"scan_details": {
"aegislab": {
"db_package_version": "1760679323",
"def_time": "2025-10-17T06:25:07.767Z",
"eng_id": "aegislab",
"eng_package_version": "8.23-1713",
"inqueue_time": 9,
"scan_result_i": 0,
"scan_time": 3,
"threat_found": ""
},
"ahnlab": {
"db_package_version": "2025.10.17.02",
"def_time": "2025-10-17T06:37:24.340Z",
"eng_id": "ahnlab",
"eng_package_version": "3.27.2.4-2358",
"inqueue_time": 10,
"scan_result_i": 0,
"scan_time": 8,
"threat_found": ""
},
"clamav": {
"db_package_version": "1760572800",
"def_time": "2025-10-17T06:28:29.798Z",
"eng_id": "clamav",
"eng_package_version": "1.4.3-2545",
"inqueue_time": 9,
"scan_result_i": 0,
"scan_time": 12,
"threat_found": ""
}
},
"start_time": "2025-10-17T06:59:59.244Z",
"total_avs": 23,
"total_time": 216
},
"stat": {
"aggregated_time": 501,
"download_time": 51,
"engine_7z_processed_request_timestamp": "2025-10-17T06:59:59.213Z",
"engine_7z_received_request_timestamp": "2025-10-17T06:59:35.607Z",
"engine_7z_request_inqueue_time": 23643,
"engine_7z_result_inqueue_time": null,
"engine_7z_scan_time": 23606,
"engine_aegislab_processed_request_timestamp": "2025-10-17T06:59:59.301Z",
"engine_aegislab_received_request_timestamp": "2025-10-17T06:59:59.259Z",
"engine_aegislab_request_inqueue_time": 9,
"engine_aegislab_result_inqueue_time": 49,
"engine_aegislab_result_received_timestamp": "2025-10-17T06:59:59.350Z",
"engine_aegislab_scan_time": 42,
"first_result_received_timestamp": "2025-10-17T06:59:59.315Z",
"request_inqueue_time": 23643,
"request_processed_timestamp": "2025-10-17T06:59:59.250Z",
"request_processing_time": 6,
"request_received_timestamp": "2025-10-17T06:59:59.244Z",
"result_aggregate_completed_timestamp": "2025-10-17T06:59:59.816Z",
"result_inqueue_time": 126,
"total_engine_scan_time": 23606,
"total_inqueue_time": 23769,
"total_scan_time": 572
},
"totalTimeOutAvs": 0
},
"observedTimeUnixNano": 1760684399858131700,
"timeUnixNano": 1760684399829749000,
"timestamp": "2025-10-17 06:59:59"
},
"resource": {
"attributes": {
"k8s.container.name": "archive-result-handler",
"k8s.container.restart_count": "0",
"k8s.deployment.name": "archive-result-handler",
"k8s.namespace.name": "application-namespace",
"k8s.node.name": "ip-10-0-0-100.region.compute.internal",
"k8s.pod.name": "archive-result-handler-bc8f9b75-r5zvt",
"k8s.pod.uid": "c6f279a8-2eca-4554-98ba-fa3d6f096288"
}
},
"scope": {
"attributes": {}
}
}
Bạn muốn lấy total Scan time để vẽ chart.
Đây lấy được Patent Query đâu tiên bạn có thể hỏi AI có sẵn trong Coralogix trước nhé.


Nó sẽ gợi ý như sau

Bạn có thể kiểm tra nó có match với log của bạn không?
Giờ chúng ta thử vẽ:

source logs
| filter $d.logRecord.attributes.cluster_name ~ 'prod-uswest2-mdcl-nim'
| filter $d.logRecord.body.stat.request_inqueue_time != null
| create time_bucket from roundTime($m.timestamp, 5.toInterval('m'))
| groupby time_bucket aggregate avg($d.logRecord.body.stat.request_inqueue_time) as request_inqueue_time
source logs
| filter $d.logRecord.attributes.cluster_name ~ 'prod-uswest2-mdcl-nim'
| filter $d.logRecord.body.stat.result_inqueue_time != null
| create time_bucket from roundTime($m.timestamp, 5.toInterval('m'))
| groupby time_bucket aggregate avg($d.logRecord.body.stat.result_inqueue_time) as result_inqueue_time
source logs
| filter $d.logRecord.attributes.cluster_name ~ 'prod-uswest2-mdcl-nim'
| filter $d.logRecord.body.stat.total_scan_time != null
| create time_bucket from roundTime($m.timestamp, 5.toInterval('m'))
| groupby time_bucket aggregate avg($d.logRecord.body.stat.total_scan_time) as total_scan_time
source logs
| filter $d.logRecord.body.scanResults.scan_details.ahnlab.inqueue_time != null
| create time_bucket from roundTime($m.timestamp, 5.toInterval('m'))
| groupby time_bucket aggregate avg($d.logRecord.body.scanResults.scan_details.ahnlab.inqueue_time) as avg_inqueue_time
| choose time_bucket, avg_inqueue_time
Call the API to get the log by Dataprime
Method 1: Using the JSON Metadata
Cách rõ ràng nhất để chỉ định thời gian bắt đầu và kết thúc tuyệt đối thông qua API là thêm các trường startDate và endDate vào bên trong đối tượng JSON metadata. Các dấu thời gian phải được định dạng theo chuẩn ISO 8601 (ví dụ: UTC với chữ Z ở cuối).
curl -X POST "https://api.coralogix.us/api/v1/dataprime/query" \
-H "Authorization: Bearer cccccjkXzqJ6kVFccccc6CBcccccd1C6z3" \
-H "Content-Type: application/json" \
-d '{
"query": "source logs | filter $l.applicationname == '\''nim-engines-integration'\''",
"metadata": {
"tier": "TIER_ARCHIVE",
"startDate": "2026-03-12T00:00:00Z",
"endDate": "2026-03-13T00:00:00Z"
}
}'
TIER_ARCHIVE: nghĩa là all log (Gồm cả log bạn lưu trữ trên S3 để tiết kiệm tiền)
TIER_FREQUENT_SEARCH: Đây là store mặc định của Coralogix
Method 2: Filtering Relative Time in the Query
Nếu bạn muốn liên tục kéo nhật ký cho một khung thời gian trượt (ví dụ: 2 giờ cuối cùng hoặc 15 phút cuối cùng), bạn có thể sử dụng hàm now() và trường siêu dữ liệu $m.timestamp trực tiếp trong chuỗi truy vấn DataPrime của bạn.
curl -X POST "https://api.coralogix.us/api/v1/dataprime/query" \
-H "Authorization: Bearer cccccjkXzqJ6kVFccccc6CBcccccd1C6z3" \
-H "Content-Type: application/json" \
-d '{
"query": "source logs | filter now() - $m.timestamp < 2h | filter $l.applicationname == '\''mdaas-engines-integration'\''",
"metadata": {
"tier": "TIER_ARCHIVE"
}
}'
Method 3: Using the “between” Keyword in the Query
Bạn cũng có thể đặt ranh giới thời gian tuyệt đối bằng cách thêm từ khóa between ngay sau nhật ký nguồn trong truy vấn DataPrime của bạn. Lưu ý rằng các ký tự thời gian trong DataPrime yêu cầu ký hiệu @ theo sau là dấu nháy đơn, cần được thoát trong tập lệnh Bash của bạn dưới dạng '\''
curl -X POST "https://api.coralogix.us/api/v1/dataprime/query" \
-H "Authorization: Bearer cccccjkXzqJ6kVFccccc6CBcccccd1C6z3" \
-H "Content-Type: application/json" \
-d '{
"query": "source logs between @'\''2026-03-12T00:00:00Z'\'' and @'\''2026-03-13T00:00:00Z'\'' | filter $l.applicationname == '\''mdaas-engines-integration'\''",
"metadata": {
"tier": "TIER_ARCHIVE"
}
}'