{"id":34973,"date":"2025-03-11T15:07:52","date_gmt":"2025-03-11T07:07:52","guid":{"rendered":"https:\/\/www.yunshan.net\/blog\/?p=34973"},"modified":"2025-03-11T15:07:52","modified_gmt":"2025-03-11T07:07:52","slug":"skywalking%e5%a6%82%e4%bd%95%e4%b8%8eelk%e6%97%a5%e5%bf%97%e7%b3%bb%e7%bb%9f%e9%9b%86%e6%88%90%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/www.yunshan.net\/blog\/archives\/34973.html","title":{"rendered":"SkyWalking\u5982\u4f55\u4e0eELK\u65e5\u5fd7\u7cfb\u7edf\u96c6\u6210\uff1f"},"content":{"rendered":"<p style=\"text-align: center;\">\n<p><img decoding=\"async\" src=\"https:\/\/www.yunshan.net\/blog\/wp-content\/uploads\/2025\/03\/WqLDdT42.jpg\" alt=\"SkyWalking\u5982\u4f55\u4e0eELK\u65e5\u5fd7\u7cfb\u7edf\u96c6\u6210\uff1f\" ><\/p>\n<\/p>\n<hr>\n<p>\u5728\u5fae\u670d\u52a1\u67b6\u6784\u4e3b\u5bfc\u7684\u4e91\u539f\u751f\u65f6\u4ee3\uff0c\u5206\u5e03\u5f0f\u7cfb\u7edf\u7684\u53ef\u89c2\u6d4b\u6027\u5df2\u6210\u4e3a\u5f00\u53d1\u8fd0\u7ef4\u56e2\u961f\u7684\u521a\u9700\u3002\u5f53<a href=\"https:\/\/www.yunshan.net\/\"   target=\"_blank\" style=\"color:blue\">\u670d\u52a1\u8c03\u7528\u94fe<\/a>\u6a2a\u8de8\u6570\u5341\u4e2a\u8282\u70b9\u3001\u9519\u8bef\u65e5\u5fd7\u6563\u843d\u5728\u4e0d\u540c\u5bb9\u5668\u65f6\uff0c\u4f20\u7edf\u7684\u76d1\u63a7\u624b\u6bb5\u5982\u540c\u76f2\u4eba\u6478\u8c61\u3002<strong><a href=\"https:\/\/www.yunshan.net\/\"   target=\"_blank\" style=\"color:blue\">SkyWalking<\/a><\/strong>\u4f5c\u4e3a<a href=\"https:\/\/www.yunshan.net\/\"   target=\"_blank\" style=\"color:blue\">\u5206\u5e03\u5f0f\u8ffd\u8e2a<\/a>\u9886\u57df\u7684\u660e\u661f\u5de5\u5177\uff0c\u4e0e<strong>ELK\uff08Elasticsearch\u3001Logstash\u3001Kibana\uff09<\/strong>\u65e5\u5fd7\u751f\u6001\u7684\u6df1\u5ea6\u878d\u5408\uff0c\u6070\u6070\u4e3a\u89e3\u51b3\u8fd9\u4e00\u75db\u70b9\u63d0\u4f9b\u4e86\u9ec4\u91d1\u7ec4\u5408\u2014\u2014\u524d\u8005\u7cbe\u51c6\u6355\u83b7\u8c03\u7528\u94fe\u62d3\u6251\uff0c\u540e\u8005\u9ad8\u6548\u805a\u5408\u6d77\u91cf\u65e5\u5fd7\uff0c\u4e24\u8005\u7684\u5316\u5b66\u53cd\u5e94\u8ba9\u5168\u6808\u89c2\u6d4b\u771f\u6b63\u5b9e\u73b0&rdquo;\u65e2\u89c1\u68ee\u6797\u53c8\u89c1\u6811\u6728&rdquo;\u3002<\/p>\n<hr>\n<h3 id=\"\u4e00-skywalking\u4e0eelk\u7684\u6838\u5fc3\u5b9a\u4f4d\u5dee\u5f02\">\u4e00\u3001<a href=\"https:\/\/www.yunshan.net\/\"   target=\"_blank\" style=\"color:blue\">SkyWalking<\/a>\u4e0eELK\u7684\u6838\u5fc3\u5b9a\u4f4d\u5dee\u5f02<\/h3>\n<p>\u5728\u63a2\u8ba8\u96c6\u6210\u65b9\u6848\u524d\uff0c\u9700\u660e\u786e\u4e24\u4e2a\u7cfb\u7edf\u7684\u539f\u751f\u5b9a\u4f4d\u5dee\u5f02\u3002<strong>SkyWalking<\/strong>\u7684\u6838\u5fc3\u4ef7\u503c\u5728\u4e8e<strong><a href=\"https:\/\/www.yunshan.net\/\"   target=\"_blank\" style=\"color:blue\">\u5206\u5e03\u5f0f\u8ffd\u8e2a<\/a><\/strong>\uff0c\u901a\u8fc7\u63a2\u9488\u81ea\u52a8\u91c7\u96c6\u670d\u52a1\u95f4\u8c03\u7528\u5173\u7cfb\u3001\u54cd\u5e94\u8017\u65f6\u3001\u9519\u8bef\u5806\u6808\u7b49\u6307\u6807\uff0c\u5f62\u6210\u53ef\u89c6\u5316\u7684\u8c03\u7528\u62d3\u6251\u56fe\u3002\u800c<strong>ELK\u6280\u672f\u6808<\/strong>\u4e13\u653b<strong>\u65e5\u5fd7\u7ba1\u7406<\/strong>\uff1aLogstash\u8d1f\u8d23\u65e5\u5fd7\u6536\u96c6\u4e0e\u7ba1\u9053\u5904\u7406\uff0cElasticsearch\u63d0\u4f9b\u5206\u5e03\u5f0f\u68c0\u7d22\uff0cKibana\u5b9e\u73b0\u53ef\u89c6\u5316\u5206\u6790\u3002<\/p>\n<p>\u4e8c\u8005\u770b\u4f3c\u5e73\u884c\u8fd0\u4f5c\uff0c\u5b9e\u5219\u5b58\u5728\u5929\u7136\u4e92\u8865\u6027\u3002\u4f8b\u5982\u5f53SkyWalking\u76d1\u6d4b\u5230\u67d0\u670d\u52a1\u63a5\u53e3\u5ef6\u8fdf\u7a81\u589e\u65f6\uff0c\u8fd0\u7ef4\u4eba\u5458\u9700\u5feb\u901f\u5b9a\u4f4d\u662f\u4ee3\u7801\u903b\u8f91\u95ee\u9898\u8fd8\u662f\u57fa\u7840\u8bbe\u65bd\u74f6\u9888\u3002\u6b64\u65f6\u82e5\u80fd\u5728Kibana\u4e2d\u76f4\u63a5\u5173\u8054\u8be5\u63a5\u53e3\u7684ERROR\u7ea7\u522b\u65e5\u5fd7\uff0c\u5373\u53ef\u5c06\u95ee\u9898\u8bca\u65ad\u65f6\u95f4\u7f29\u77ed60%\u4ee5\u4e0a\u3002<\/p>\n<hr>\n<h3 id=\"\u4e8c-\u96c6\u6210\u65b9\u6848\u7684\u6280\u672f\u5b9e\u73b0\u8def\u5f84\">\u4e8c\u3001\u96c6\u6210\u65b9\u6848\u7684\u6280\u672f\u5b9e\u73b0\u8def\u5f84<\/h3>\n<h4 id=\"1-\u65e5\u5fd7\u683c\u5f0f\u6807\u51c6\u5316\">1. <strong>\u65e5\u5fd7\u683c\u5f0f\u6807\u51c6\u5316<\/strong><\/h4>\n<p>\u96c6\u6210\u7684\u524d\u63d0\u662f\u7edf\u4e00\u6570\u636e\u683c\u5f0f\u3002\u5efa\u8bae\u91c7\u7528<strong>JSON\u4f5c\u4e3a\u65e5\u5fd7\u8f93\u51fa\u6807\u51c6<\/strong>\uff0c\u786e\u4fdd\u5b57\u6bb5\u7ed3\u6784\u5316\u3002\u5728Logback\u6216Log4j\u914d\u7f6e\u4e2d\u589e\u52a0SkyWalking\u7684Trace ID\u6ce8\u5165\uff1a<\/p>\n<pre><code class=\"language-xml\">&lt;!-- Logback\u793a\u4f8b --&gt;  \r\n&lt;encoder class=&quot;ch.qos.logback.core.encoder.LayoutWrappingEncoder&quot;&gt;  \r\n&lt;layout class=&quot;org.apache.skywalking.apm.toolkit.log.logback.v1.x.TraceIdPatternLogbackLayout&quot;&gt;  \r\n&lt;pattern&gt;%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - [%tid] - %msg%n&lt;\/pattern&gt;  \r\n&lt;\/layout&gt;  \r\n&lt;\/encoder&gt;  \r\n<\/code><\/pre>\n<p><code>%tid<\/code>\u5360\u4f4d\u7b26\u4f1a\u81ea\u52a8\u6ce8\u5165SkyWalking\u751f\u6210\u7684<strong>\u5168\u5c40Trace ID<\/strong>\uff0c\u8be5ID\u5c06\u4f5c\u4e3a\u540e\u7eed\u6570\u636e\u5173\u8054\u7684\u5173\u952e\u951a\u70b9\u3002<\/p>\n<h4 id=\"2-skywalking\u65e5\u5fd7\u5bfc\u51fa\u914d\u7f6e\">2. <strong>SkyWalking\u65e5\u5fd7\u5bfc\u51fa\u914d\u7f6e<\/strong><\/h4>\n<p>\u5728SkyWalking\u7684<code>config\/agent.config<\/code>\u4e2d\u542f\u7528gRPC\u65e5\u5fd7\u62a5\u544a\u529f\u80fd\uff1a<\/p>\n<pre><code class=\"language-properties\">plugin.toolkit.log.grpc.reporter.server_host=${SW_GRPC_LOG_SERVER:localhost}  \r\nplugin.toolkit.log.grpc.reporter.server_port=${SW_GRPC_LOG_PORT:11800}  \r\nplugin.toolkit.log.grpc.reporter.max_message_size=${SW_GRPC_LOG_MAX_MSG_SIZE:10485760}  \r\n<\/code><\/pre>\n<p>\u540c\u65f6\u8c03\u6574\u65e5\u5fd7\u6279\u91cf\u4e0a\u62a5\u7b56\u7565\u4ee5\u5e73\u8861\u5b9e\u65f6\u6027\u4e0e\u7cfb\u7edf\u8d1f\u8f7d\uff1a<\/p>\n<pre><code class=\"language-properties\">plugin.toolkit.log.grpc.reporter.upstream_timeout=${SW_GRPC_LOG_UPSTREAM_TIMEOUT:30}  \r\n<\/code><\/pre>\n<h4 id=\"3-logstash\u7ba1\u9053\u914d\u7f6e\u4f18\u5316\">3. <strong>Logstash\u7ba1\u9053\u914d\u7f6e\u4f18\u5316<\/strong><\/h4>\n<p>\u5728Logstash\u4e2d\u521b\u5efa\u4e13\u7528pipeline\u5904\u7406SkyWalking\u65e5\u5fd7\uff0c\u91cd\u70b9\u5728\u4e8e<strong>Trace ID\u63d0\u53d6<\/strong>\u4e0e<strong>\u7d22\u5f15\u8def\u7531<\/strong>\uff1a<\/p>\n<pre><code class=\"language-ruby\">input {  \r\ngRPC {  \r\nport =&gt; 11800  \r\nroute_class =&gt; &quot;org.apache.skywalking.apm.log.agent.grpc.LogReportServiceHandler&quot;  \r\n}  \r\n}  \r\n  \r\nfilter {  \r\njson {  \r\nsource =&gt; &quot;message&quot;  \r\ntarget =&gt; &quot;sw_log&quot;  \r\n}  \r\nmutate {  \r\nadd_field =&gt; { &quot;[@metadata][index_suffix]&quot; =&gt; &quot;%{+YYYY.MM.dd}&quot; }  \r\n}  \r\n}  \r\n  \r\noutput {  \r\nelasticsearch {  \r\nhosts =&gt; [&quot;http:\/\/es-node:9200&quot;]  \r\nindex =&gt; &quot;skywalking-logs-%{[@metadata][index_suffix]}&quot;  \r\n}  \r\n}  \r\n<\/code><\/pre>\n<p>\u6b64\u914d\u7f6e\u5b9e\u73b0\u6309\u65e5\u6eda\u52a8\u7d22\u5f15\uff0c\u907f\u514d\u5355\u4e2a\u7d22\u5f15\u8fc7\u5927\u5f71\u54cd\u67e5\u8be2\u6027\u80fd\u3002<\/p>\n<hr>\n<h3 id=\"\u4e09-\u6570\u636e\u5173\u8054\u7684\u4e09\u79cd\u9ad8\u9636\u6280\u5de7\">\u4e09\u3001\u6570\u636e\u5173\u8054\u7684\u4e09\u79cd\u9ad8\u9636\u6280\u5de7<\/h3>\n<ol>\n<li>\n<p><strong>Kibana Lens\u5173\u8054\u5206\u6790<\/strong><br \/>\n\u5728Kibana\u4e2d\u521b\u5efaLens\u53ef\u89c6\u5316\uff0c\u901a\u8fc7<code>trace.id<\/code>\u5b57\u6bb5\u5c06SkyWalking\u7684\u8ffd\u8e2a\u6570\u636e\u4e0eELK\u4e2d\u7684\u539f\u59cb\u65e5\u5fd7\u8fdb\u884cJoin\u64cd\u4f5c\u3002\u53ef\u8bbe\u7f6e\u9608\u503c\u544a\u8b66\uff0c\u4f8b\u5982\u5f53\u67d0Trace ID\u5bf9\u5e94\u7684\u9519\u8bef\u65e5\u5fd7\u8d85\u8fc75\u6761\u65f6\u89e6\u53d1\u4f01\u4e1a\u5fae\u4fe1\u901a\u77e5\u3002<\/p>\n<\/li>\n<li>\n<p><strong>Elasticsearch\u8de8\u7d22\u5f15\u67e5\u8be2<\/strong><br \/>\n\u5229\u7528ES\u7684<code>terms lookup<\/code>\u7279\u6027\u5b9e\u73b0\u8de8\u7d22\u5f15\u5173\u8054\u67e5\u8be2\uff1a<\/p>\n<\/li>\n<\/ol>\n<pre><code class=\"language-json\">GET skywalking-spans-*\/_search  \r\n{  \r\n&quot;query&quot;: {  \r\n&quot;terms&quot;: {  \r\n&quot;trace.id&quot;: {  \r\n&quot;index&quot;: &quot;app-logs-2023.08.01&quot;,  \r\n&quot;path&quot;: &quot;sw_log.trace_id&quot;,  \r\n&quot;id&quot;: &quot;12345&quot;  \r\n}  \r\n}  \r\n}  \r\n}  \r\n<\/code><\/pre>\n<p>\u8be5\u8bed\u53e5\u53ef\u68c0\u7d22\u6240\u6709\u5305\u542b\u6307\u5b9aTrace ID\u7684Span\u8bb0\u5f55\u548c\u4e1a\u52a1\u65e5\u5fd7\u3002<\/p>\n<ol>\n<li><strong>Grafana\u6df7\u5408\u4eea\u8868\u76d8<\/strong><br \/>\n\u5728Grafana\u4e2d\u540c\u65f6\u63a5\u5165SkyWalking\u548cElasticsearch\u6570\u636e\u6e90\uff0c\u521b\u5efa\u6df7\u5408\u56fe\u8868\u3002\u4f8b\u5982\u7528\u6298\u7ebf\u56fe\u5c55\u793a\u67d0\u670d\u52a1QPS\u53d8\u5316\uff0c\u53e0\u52a0\u540c\u4e00\u65f6\u6bb5\u7684ERROR\u65e5\u5fd7\u6570\u91cf\uff0c\u5feb\u901f\u8bc6\u522b\u6d41\u91cf\u9ad8\u5cf0\u4e0e\u5f02\u5e38\u7684\u6b63\u76f8\u5173\u6027\u3002\n<\/li>\n<\/ol>\n<hr>\n<h3 id=\"\u56db-\u6027\u80fd\u8c03\u4f18\u4e0e\u907f\u5751\u6307\u5357\">\u56db\u3001\u6027\u80fd\u8c03\u4f18\u4e0e\u907f\u5751\u6307\u5357<\/h3>\n<ol>\n<li><strong>\u5b57\u6bb5\u6620\u5c04\u9884\u5b9a\u4e49<\/strong><br \/>\n\u5728Elasticsearch\u4e2d\u9884\u5148\u4e3aSkyWalking\u65e5\u5fd7\u5b9a\u4e49\u52a8\u6001\u6a21\u677f\uff0c\u907f\u514d\u81ea\u52a8\u7c7b\u578b\u63a8\u65ad\u5bfc\u81f4\u5b57\u6bb5\u51b2\u7a81\uff1a\n<\/li>\n<\/ol>\n<pre><code class=\"language-json\">PUT _template\/sw_logs_template  \r\n{  \r\n&quot;index_patterns&quot;: [&quot;skywalking-logs-*&quot;],  \r\n&quot;mappings&quot;: {  \r\n&quot;dynamic_templates&quot;: [  \r\n{  \r\n&quot;strings_as_keyword&quot;: {  \r\n&quot;match_mapping_type&quot;: &quot;string&quot;,  \r\n&quot;mapping&quot;: {  \r\n&quot;type&quot;: &quot;keyword&quot;,  \r\n&quot;ignore_above&quot;: 1024  \r\n}  \r\n}  \r\n}  \r\n]  \r\n}  \r\n}  \r\n<\/code><\/pre>\n<ol>\n<li><strong>\u65e5\u5fd7\u91c7\u6837\u7b56\u7565<\/strong><br \/>\n\u5728\u9ad8\u541e\u5410\u573a\u666f\u4e0b\uff0c\u53ef\u5728Logstash\u5c42\u6dfb\u52a0\u91c7\u6837\u8fc7\u6ee4\u5668\uff0c\u4f8b\u5982\u5bf9DEBUG\u7ea7\u522b\u65e5\u5fd7\u630910%\u6bd4\u4f8b\u62bd\u6837\uff1a\n<\/li>\n<\/ol>\n<pre><code class=\"language-ruby\">filter {  \r\nif [level] == &quot;DEBUG&quot; {  \r\ndrop {  \r\npercentage =&gt; 90  \r\n}  \r\n}  \r\n}  \r\n<\/code><\/pre>\n<ol>\n<li><strong>\u5b89\u5168\u52a0\u56fa\u65b9\u6848<\/strong>\n<\/li>\n<\/ol>\n<ul>\n<li>\u901a\u8fc7Elasticsearch\u7684API\u5bc6\u94a5\u7ba1\u7406\u5b9e\u73b0\u6700\u5c0f\u6743\u9650\u63a7\u5236\n<\/li>\n<li>\u5728SkyWalking OAP Server\u542f\u7528TLS\u52a0\u5bc6gRPC\u901a\u9053\n<\/li>\n<li>\u4f7f\u7528Filebeat\u66ff\u4ee3\u76f4\u63a5gRPC\u8fde\u63a5\uff0c\u589e\u52a0\u4f20\u8f93\u5c42\u7f13\u51b2\n<\/li>\n<\/ul>\n<hr>\n<h3 id=\"\u4e94-\u4ece\u96c6\u6210\u5230\u667a\u80fd\u5316\u7684\u8fdb\u9636\u601d\u8003\">\u4e94\u3001\u4ece\u96c6\u6210\u5230\u667a\u80fd\u5316\u7684\u8fdb\u9636\u601d\u8003<\/h3>\n<p>\u5f53\u57fa\u7840\u96c6\u6210\u5b8c\u6210\u540e\uff0c\u53ef\u5411<strong>AIOps<\/strong>\u65b9\u5411\u5ef6\u4f38\u3002\u4f8b\u5982\u57fa\u4e8e\u5386\u53f2\u65e5\u5fd7\u8bad\u7ec3\u5f02\u5e38\u68c0\u6d4b\u6a21\u578b\uff0c\u5f53SkyWalking\u6355\u6349\u5230\u6162\u8c03\u7528\u65f6\uff0c\u81ea\u52a8\u89e6\u53d1ELK\u4e2d\u7684\u5173\u8054\u65e5\u5fd7\u5206\u6790\uff0c\u751f\u6210\u6839\u56e0\u63a8\u6d4b\u62a5\u544a\u3002\u67d0\u7535\u5546\u5e73\u53f0\u91c7\u7528\u8be5\u65b9\u6848\u540e\uff0c\u5e73\u5747\u6545\u969c\u6062\u590d\u65f6\u95f4\uff08MTTR\uff09\u4ece23\u5206\u949f\u964d\u81f34.8\u5206\u949f\u3002<\/p>\n<p>\u8fd9\u79cd\u6df1\u5ea6\u96c6\u6210\u4e0d\u4ec5\u6253\u7834\u5de5\u5177\u94fe\u58c1\u5792\uff0c\u66f4\u91cd\u65b0\u5b9a\u4e49\u4e86\u53ef\u89c2\u6d4b\u6027\u7684\u4ef7\u503c\u8fb9\u754c\u2014\u2014\u4ece\u88ab\u52a8\u76d1\u63a7\u8f6c\u5411\u4e3b\u52a8\u6d1e\u5bdf\uff0c\u4ece\u4e8b\u540e\u8ffd\u67e5\u5347\u7ea7\u4e3a\u4e8b\u524d\u9884\u9632\u3002\u5728FinOps\u5b9e\u8df5\u4e2d\uff0c\u56e2\u961f\u751a\u81f3\u80fd\u901a\u8fc7\u5206\u6790Span\u4e0e\u65e5\u5fd7\u7684\u5173\u8054\u6570\u636e\uff0c\u7cbe\u51c6\u5b9a\u4f4d\u8d44\u6e90<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5728\u5fae\u670d\u52a1\u67b6\u6784\u4e3b\u5bfc\u7684\u4e91\u539f\u751f\u65f6\u4ee3\uff0c\u5206\u5e03\u5f0f\u7cfb\u7edf\u7684\u53ef\u89c2\u6d4b\u6027\u5df2\u6210\u4e3a\u5f00\u53d1\u8fd0\u7ef4\u56e2\u961f\u7684\u521a\u9700\u3002\u5f53\u670d\u52a1\u8c03\u7528\u94fe\u6a2a\u8de8\u6570\u5341\u4e2a\u8282\u70b9\u3001\u9519\u8bef\u65e5\u5fd7\u6563\u843d\u5728\u4e0d\u540c\u5bb9\u5668\u65f6\uff0c\u4f20\u7edf\u7684\u76d1\u63a7\u624b\u6bb5\u5982\u540c\u76f2\u4eba\u6478\u8c61\u3002SkyWalking\u4f5c\u4e3a\u5206\u5e03\u5f0f\u8ffd\u8e2a\u9886\u57df\u7684\u660e\u661f\u5de5\u5177\uff0c\u4e0eELK\uff08Elasticsearch\u3001Logstash\u3001Kibana\uff09\u65e5\u5fd7\u751f\u6001\u7684\u6df1\u5ea6\u878d\u5408\uff0c\u6070\u6070\u4e3a\u89e3\u51b3\u8fd9\u4e00\u75db\u70b9\u63d0\u4f9b\u4e86\u9ec4\u91d1\u7ec4\u5408\u2014\u2014\u524d\u8005\u7cbe\u51c6\u6355\u83b7\u8c03\u7528\u94fe\u62d3\u6251\uff0c\u540e\u8005\u9ad8\u6548\u805a\u5408\u6d77\u91cf\u65e5\u5fd7\uff0c\u4e24\u8005\u7684\u5316\u5b66\u53cd\u5e94\u8ba9\u5168\u6808\u89c2\u6d4b\u771f\u6b63\u5b9e\u73b0&rdquo;\u65e2\u89c1\u68ee\u6797\u53c8\u89c1\u6811\u6728&rdquo;\u3002 \u4e00\u3001SkyWalking\u4e0eELK\u7684\u6838\u5fc3\u5b9a\u4f4d\u5dee\u5f02 \u5728\u63a2\u8ba8\u96c6\u6210\u65b9\u6848\u524d\uff0c\u9700\u660e\u786e\u4e24\u4e2a\u7cfb\u7edf\u7684\u539f\u751f\u5b9a\u4f4d\u5dee\u5f02\u3002SkyWalking\u7684\u6838\u5fc3\u4ef7\u503c\u5728\u4e8e\u5206\u5e03\u5f0f\u8ffd\u8e2a\uff0c\u901a\u8fc7\u63a2\u9488\u81ea\u52a8\u91c7\u96c6\u670d\u52a1\u95f4\u8c03\u7528\u5173\u7cfb\u3001\u54cd\u5e94\u8017\u65f6\u3001\u9519\u8bef\u5806\u6808\u7b49\u6307\u6807\uff0c\u5f62\u6210\u53ef\u89c6\u5316\u7684\u8c03\u7528\u62d3\u6251\u56fe\u3002\u800cELK\u6280\u672f\u6808\u4e13\u653b\u65e5\u5fd7\u7ba1\u7406\uff1aLogstash\u8d1f\u8d23\u65e5\u5fd7\u6536\u96c6\u4e0e\u7ba1\u9053\u5904\u7406\uff0cElasticsearch\u63d0\u4f9b\u5206\u5e03\u5f0f\u68c0\u7d22\uff0cKibana\u5b9e\u73b0\u53ef\u89c6\u5316\u5206\u6790\u3002 \u4e8c\u8005\u770b\u4f3c\u5e73\u884c\u8fd0\u4f5c\uff0c\u5b9e\u5219\u5b58\u5728\u5929\u7136\u4e92\u8865\u6027\u3002\u4f8b\u5982\u5f53SkyWalking\u76d1\u6d4b\u5230\u67d0\u670d\u52a1\u63a5\u53e3\u5ef6\u8fdf\u7a81\u589e\u65f6\uff0c\u8fd0\u7ef4\u4eba\u5458\u9700\u5feb\u901f\u5b9a\u4f4d\u662f\u4ee3\u7801\u903b\u8f91\u95ee\u9898\u8fd8\u662f\u57fa\u7840\u8bbe\u65bd\u74f6\u9888\u3002\u6b64\u65f6\u82e5\u80fd\u5728Kibana\u4e2d\u76f4\u63a5\u5173\u8054\u8be5\u63a5\u53e3\u7684ERROR\u7ea7\u522b\u65e5\u5fd7\uff0c\u5373\u53ef\u5c06\u95ee\u9898\u8bca\u65ad\u65f6\u95f4\u7f29\u77ed60%\u4ee5\u4e0a\u3002 \u4e8c\u3001\u96c6\u6210\u65b9\u6848\u7684\u6280\u672f\u5b9e\u73b0\u8def\u5f84 1. \u65e5\u5fd7\u683c\u5f0f\u6807\u51c6\u5316 \u96c6\u6210\u7684\u524d\u63d0\u662f\u7edf\u4e00\u6570\u636e\u683c\u5f0f\u3002\u5efa\u8bae\u91c7\u7528JSON\u4f5c\u4e3a\u65e5\u5fd7\u8f93\u51fa\u6807\u51c6\uff0c\u786e\u4fdd\u5b57\u6bb5\u7ed3\u6784\u5316\u3002\u5728Logback\u6216Log4j\u914d\u7f6e\u4e2d\u589e\u52a0SkyWalking\u7684Trace ID\u6ce8\u5165\uff1a &lt;!&#8211; Logback\u793a\u4f8b &#8211;&gt; &lt;encoder class=&quot;ch.qos.logback.core.encoder.LayoutWrappingEncoder&quot;&gt; &lt;layout class=&quot;org.apache.skywalking.apm.toolkit.log.logback.v1.x.TraceIdPatternLogbackLayout&quot;&gt; &lt;pattern&gt;%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} &#8211; [%tid] &#8211; %msg%n&lt;\/pattern&gt; &lt;\/layout&gt; &lt;\/encoder&gt; %tid\u5360\u4f4d\u7b26\u4f1a\u81ea\u52a8\u6ce8\u5165SkyWalking\u751f\u6210\u7684\u5168\u5c40Trace ID\uff0c\u8be5ID\u5c06\u4f5c\u4e3a\u540e\u7eed\u6570\u636e\u5173\u8054\u7684\u5173\u952e\u951a\u70b9\u3002 2. SkyWalking\u65e5\u5fd7\u5bfc\u51fa\u914d\u7f6e \u5728SkyWalking\u7684config\/agent.config\u4e2d\u542f\u7528gRPC\u65e5\u5fd7\u62a5\u544a\u529f\u80fd\uff1a plugin.toolkit.log.grpc.reporter.server_host=${SW_GRPC_LOG_SERVER:localhost} plugin.toolkit.log.grpc.reporter.server_port=${SW_GRPC_LOG_PORT:11800} plugin.toolkit.log.grpc.reporter.max_message_size=${SW_GRPC_LOG_MAX_MSG_SIZE:10485760} \u540c\u65f6\u8c03\u6574\u65e5\u5fd7\u6279\u91cf\u4e0a\u62a5\u7b56\u7565\u4ee5\u5e73\u8861\u5b9e\u65f6\u6027\u4e0e\u7cfb\u7edf\u8d1f\u8f7d\uff1a plugin.toolkit.log.grpc.reporter.upstream_timeout=${SW_GRPC_LOG_UPSTREAM_TIMEOUT:30} 3. Logstash\u7ba1\u9053\u914d\u7f6e\u4f18\u5316 \u5728Logstash\u4e2d\u521b\u5efa\u4e13\u7528pipeline\u5904\u7406SkyWalking\u65e5\u5fd7\uff0c\u91cd\u70b9\u5728\u4e8eTrace ID\u63d0\u53d6\u4e0e\u7d22\u5f15\u8def\u7531\uff1a input { gRPC { port =&gt; 11800 route_class =&gt; &quot;org.apache.skywalking.apm.log.agent.grpc.LogReportServiceHandler&quot; } } filter { [&hellip;]<\/p>\n","protected":false},"author":4,"featured_media":34974,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[14],"tags":[],"class_list":["post-34973","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-product-news"],"_links":{"self":[{"href":"https:\/\/www.yunshan.net\/blog\/wp-json\/wp\/v2\/posts\/34973","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.yunshan.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.yunshan.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.yunshan.net\/blog\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.yunshan.net\/blog\/wp-json\/wp\/v2\/comments?post=34973"}],"version-history":[{"count":1,"href":"https:\/\/www.yunshan.net\/blog\/wp-json\/wp\/v2\/posts\/34973\/revisions"}],"predecessor-version":[{"id":34975,"href":"https:\/\/www.yunshan.net\/blog\/wp-json\/wp\/v2\/posts\/34973\/revisions\/34975"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.yunshan.net\/blog\/wp-json\/wp\/v2\/media\/34974"}],"wp:attachment":[{"href":"https:\/\/www.yunshan.net\/blog\/wp-json\/wp\/v2\/media?parent=34973"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.yunshan.net\/blog\/wp-json\/wp\/v2\/categories?post=34973"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.yunshan.net\/blog\/wp-json\/wp\/v2\/tags?post=34973"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}