1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
| curl -u elastic:123456 -k -X GET "https://192.168.10.100:9200/kind-logs-*/_search?pretty" -H 'Content-Type: application/json' -d' { "size": 1, "sort": [{ "@timestamp": "desc" }] } ' { "took" : 16, "timed_out" : false, "_shards" : { "total" : 1, "successful" : 1, "skipped" : 0, "failed" : 0 }, "hits" : { "total" : { "value" : 1560, "relation" : "eq" }, "max_score" : null, "hits" : [ { "_index" : "kind-logs-2026.04.01", "_id" : "k3B3SJ0BhqMFurw_h4yK", "_score" : null, "_source" : { "time" : "2026-04-01T09:54:40.590735118Z", "stream" : "stderr", "_p" : "F", "log" : "I0401 09:54:40.590512 1 main.go:297] Handling node with IPs: map[172.19.0.2:{}]", "kubernetes" : { "pod_name" : "kindnet-nncxf", "namespace_name" : "kube-system", "pod_id" : "c725a431-7ed2-446d-b658-117b2db76821", "labels" : { "app" : "kindnet", "controller-revision-hash" : "5b49848c94", "k8s-app" : "kindnet", "pod-template-generation" : "1", "tier" : "node" }, "host" : "ws-k8s-worker", "pod_ip" : "172.19.0.4", "container_name" : "kindnet-cni", "docker_id" : "ad3a9ffe8101377b135ea0113d6612fd9d251ce2eb089cab587b484db0afbb25", "container_hash" : "sha256:50415e5d05f05adbdfd902507532ebb86f924dc2e05511a3b47920156ee4236e", "container_image" : "docker.io/kindest/kindnetd:v20241108-5c6d2daf" }, "@timestamp" : "2026-04-01T09:54:40.590735118+00:00" }, "sort" : [ 1775037280590 ] } ] } }
# 定义索引模板 PUT _index_template/kind_logs_template { "index_patterns": ["kind-logs-*"], "priority": 200, "template": { "settings": { "index.number_of_shards": 1, "index.number_of_replicas": 0, "index.refresh_interval": "10s" }, "mappings": { "properties": { "@timestamp": { "type": "date" }, "log": { "type": "text", "analyzer": "standard" }, "stream": { "type": "keyword" }, "time": { "type": "date" }, "kubernetes": { "properties": { "pod_name": { "type": "keyword" }, "namespace_name": { "type": "keyword" }, "host": { "type": "keyword" }, "container_name": { "type": "keyword" }, "docker_id": { "type": "keyword" }, "labels": { "type": "object", "enabled": true } } } } } } }
|