springboot集成skywalking 实现分布式链路追踪 日志采集 性能分析

目录

springboot使用docker方式集成skywalking

实现分布式链路追踪 日志采集 性能分析 


ES

​
docker run --name elasticsearch -d -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" docker.elastic.co/elasticsearch/elasticsearch:7.11.2

skywalking-oap-server

Docker Hub

docker run \
--name skywalking-oap-server \
-d --restart always \
-p 1234:1234 \
-p 11800:11800 \
-p 12800:12800 \
-e SW_STORAGE=elasticsearch7 \
-e SW_STORAGE_ES_CLUSTER_NODES=192.168.29.74:9200 \
-e SW_CORE_RECORD_DATA_TTL=3 \
-e SW_CORE_METRICS_DATA_TTL=7 \
apache/skywalking-oap-server:8.7.0-es7
docker run --name skywalking-oap-server -d --restart always -p 1234:1234 -p 11800:11800 -p 12800:12800 -e SW_STORAGE=elasticsearch7 -e SW_STORAGE_ES_CLUSTER_NODES=192.168.29.74:9200 -e SW_CORE_RECORD_DATA_TTL=3 -e SW_CORE_METRICS_DATA_TTL=7 apache/skywalking-oap-server:8.7.0-es7

skywalking-ui

Docker Hub

docker run \
--name skywalking-ui \
--restart always \
-d -p 8080:8080 \
-e SW_OAP_ADDRESS=http://192.168.29.74:12800 \
apache/skywalking-ui:8.7.0
docker run --name skywalking-ui --restart always -d -p 8080:8080 -e SW_OAP_ADDRESS=http://192.168.29.74:12800 apache/skywalking-ui:8.7.0

web访问地址

java agent

java -javaagent:/opt/apache-skywalking-apm-bin/agent/skywalking-agent.jar 
-Dskywalking.agent.service_name=xxxtest 
-Dskywalking.collector.backend_service=192.168.29.74:11800
-jar /opt/spring-boot-demo-0.0.1-SNAPSHOT.jar

-javaagent 指定agent包位置

-Dskywalking.agent.service_name 指定服务名

-Dskywalking.collector.backend_service 指定skywalking oap地址,由于在本机,地址为:127.0.0.1:11800

-jar 指定jar包的路径

docker

Docker Hub

FROM  apache/skywalking-java-agent:8.7.0-jdk8 AS skywalking
MAINTAINER suonanjiexi 
COPY ./demo-*.jar   /usr/local/app.jar
COPY --from=apache/skywalking-java-agent:8.7.0-jdk8 /skywalking/agent /usr/local/agent
ENV TimeZone=Asia/Shanghai
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
WORKDIR /
ENV SW_AGENT_NAMESPACE='suonanjiexi' SW_AGENT_NAME=demo SW_AGENT_COLLECTOR_BACKEND_SERVICES='192.168.29.70:11800'
ENV SW_GRPC_LOG_SERVER_HOST=192.168.29.70 SW_GRPC_LOG_SERVER_PORT=11800 SW_GRPC_LOG_MAX_MESSAGE_SIZE=10485760 SW_GRPC_LOG_GRPC_UPSTREAM_TIMEOUT=30
ENTRYPOINT ["java","-Xmx512m","-Xms512m", "-spring.profiles.active=dev", "-Djava.security.egd=file:/dev/./urandom","-jar","/usr/local/app.jar"]
$ vi /etc/sysctl.conf
vm.max_map_count=262144
$ sysctl -p
​
$ vi/etc/systemd/system.conf
DefaultLimitNOFILE=65536
DefaultLimitNPROC=32000
DefaultLimitMEMLOCK=infinity
$ systemctl daemon-reload
​
$ vi /etc/security/limits.conf
* soft nofile 65536
* hard nofile 65536
* soft nproc 4096
* hard nproc 4096
* hard memlock unlimited
* soft memlock unlimited
plugin.toolkit.log.grpc.reporter.server_host=${SW_GRPC_LOG_SERVER_HOST:172.16.1.244}
# 指定要向其报告日志数据的grpc服务器的端口
plugin.toolkit.log.grpc.reporter.server_port=${SW_GRPC_LOG_SERVER_PORT:11800}
# 指定grpc客户端要报告的日志数据的最大大小
plugin.toolkit.log.grpc.reporter.max_message_size=${SW_GRPC_LOG_MAX_MESSAGE_SIZE:10485760}
# 客户端向上游发送数据时将超时多长时间。单位是秒
plugin.toolkit.log.grpc.reporter.upstream_timeout=${SW_GRPC_LOG_GRPC_UPSTREAM_TIMEOUT:30}
​

skywalking 5.X 分布式链路跟踪 使用笔记_jilo88的博客-CSDN博客_skywalking-agent

# 基于哪个镜像
FROM java:8
# 拷贝文件到容器,也可以直接写成ADD microservice-discovery-eureka-0.0.1-SNAPSHOT.jar /app.jar
ADD ./*.jar app.jar
RUN mkdir -p /var/logs/Sentinel
RUN mkdir -p /var/logs/jvm
RUN mkdir -p /var/logs/dump
RUN bash -c 'touch /app.jar'
# 开放8080端口
EXPOSE 8080
# 配置容器启动后执行的命令
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-Dsentinel.dashboard.auth.username=sentinel","-Dsentinel.dashboard.auth.password=123456","-Dserver.servlet.session.timeout=7200","-XX:-PrintGCDetails","-XX:-PrintGCTimeStamps","-XX:-HeapDumpOnOutOfMemoryError","-XX:HeapDumpPath=/var/logs/dump/oom_dump.dump","-Xloggc:/var/logs/jvm/app.log","-Dfile.encoding=UTF8","-Duser.timezone=GMT+08","-XX:CMSInitiatingOccupancyFraction=90","-XX:MaxGCPauseMillis=200","-XX:StringTableSize=20000","-XX:+UseG1GC","-Xss256k","-Xmx1024m","-Xms512m","-jar","/app.jar"]

idea 测试

 -javaagent:/Users/suonanjiexi/Downloads/apache-skywalking-apm-bin-es7/agent/skywalking-agent.jar
 -Dskywalking.agent.service_name=test 
 -Dskywalking.collector.backend_service=192.168.29.74:11800

skywalking 性能分析

配置详细说明地址 https://github.com/apache/skywalking/blob/v8.7.0/docs/en/setup/service-agent/java-agent/README.md

# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements.  See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership.  The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License.  You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
​
# The agent namespace
 agent.namespace=${SW_AGENT_NAMESPACE:default-namespace}
​
# The service name in UI
agent.service_name=${SW_AGENT_NAME:Your_ApplicationName}
​
# The number of sampled traces per 3 seconds
# Negative or zero means off, by default
 agent.sample_n_per_3_secs=${SW_AGENT_SAMPLE:-1}
​
# Authentication active is based on backend setting, see application.yml for more details.
# agent.authentication = ${SW_AGENT_AUTHENTICATION:xxxx}
​
# The max amount of spans in a single segment.
# Through this config item, SkyWalking keep your application memory cost estimated.
 agent.span_limit_per_segment=${SW_AGENT_SPAN_LIMIT:150}
​
# If the operation name of the first span is included in this set, this segment should be ignored. Multiple values should be separated by `,`.
 agent.ignore_suffix=${SW_AGENT_IGNORE_SUFFIX:.jpg,.jpeg,.js,.css,.png,.bmp,.gif,.ico,.mp3,.mp4,.html,.svg}
​
# If true, SkyWalking agent will save all instrumented classes files in `/debugging` folder.
# SkyWalking team may ask for these files in order to resolve compatible problem.
 agent.is_open_debugging_class = ${SW_AGENT_OPEN_DEBUG:true}
​
# If true, SkyWalking agent will cache all instrumented classes files to memory or disk files (decided by class cache mode),
# allow other javaagent to enhance those classes that enhanced by SkyWalking agent.
 agent.is_cache_enhanced_class = ${SW_AGENT_CACHE_CLASS:false}
​
# The instrumented classes cache mode: MEMORY or FILE
# MEMORY: cache class bytes to memory, if instrumented classes is too many or too large, it may take up more memory
# FILE: cache class bytes in `/class-cache` folder, automatically clean up cached class files when the application exits
 agent.class_cache_mode = ${SW_AGENT_CLASS_CACHE_MODE:MEMORY}
​
# The operationName max length
# Notice, in the current practice, we don't recommend the length over 190.
 agent.operation_name_threshold=${SW_AGENT_OPERATION_NAME_THRESHOLD:150}
​
# The agent use gRPC plain text in default.
# If true, SkyWalking agent uses TLS even no CA file detected.
 agent.force_tls=${SW_AGENT_FORCE_TLS:false}
​
# If true, skywalking agent will enable profile when user create a new profile task. Otherwise disable profile.
 profile.active=${SW_AGENT_PROFILE_ACTIVE:true}
​
# Parallel monitor segment count
 profile.max_parallel=${SW_AGENT_PROFILE_MAX_PARALLEL:5}
​
# Max monitor segment time(minutes), if current segment monitor time out of limit, then stop it.
 profile.max_duration=${SW_AGENT_PROFILE_DURATION:10}
​
# Max dump thread stack depth
 profile.dump_max_stack_depth=${SW_AGENT_PROFILE_DUMP_MAX_STACK_DEPTH:500}
​
# Snapshot transport to backend buffer size
 profile.snapshot_transport_buffer_size=${SW_AGENT_PROFILE_SNAPSHOT_TRANSPORT_BUFFER_SIZE:50}
​
# Backend service addresses.
collector.backend_service=${SW_AGENT_COLLECTOR_BACKEND_SERVICES:127.0.0.1:11800}
​
# Logging file_name
logging.file_name=${SW_LOGGING_FILE_NAME:skywalking-api.log}
​
# Logging level
logging.level=${SW_LOGGING_LEVEL:INFO}
​
# Logging dir
 logging.dir=${SW_LOGGING_DIR:""}
​
# Logging max_file_size, default: 300 * 1024 * 1024 = 314572800
 logging.max_file_size=${SW_LOGGING_MAX_FILE_SIZE:314572800}
​
# The max history log files. When rollover happened, if log files exceed this number,
# then the oldest file will be delete. Negative or zero means off, by default.
 logging.max_history_files=${SW_LOGGING_MAX_HISTORY_FILES:-1}
​
# Listed exceptions would not be treated as an error. Because in some codes, the exception is being used as a way of controlling business flow.
# Besides, the annotation named IgnoredException in the trace toolkit is another way to configure ignored exceptions.
 statuscheck.ignored_exceptions=${SW_STATUSCHECK_IGNORED_EXCEPTIONS:5}
​
# The max recursive depth when checking the exception traced by the agent. Typically, we don't recommend setting this more than 10, which could cause a performance issue. Negative value and 0 would be ignored, which means all exceptions would make the span tagged in error status.
# statuscheck.max_recursive_depth=${SW_STATUSCHECK_MAX_RECURSIVE_DEPTH:1}
​
# Mount the specific folders of the plugins. Plugins in mounted folders would work.
plugin.mount=${SW_MOUNT_FOLDERS:plugins,activations}
​
# Exclude activated plugins
 plugin.exclude_plugins=${SW_EXCLUDE_PLUGINS:}
​
# If set to true, the parameters of the sql (typically java.sql.PreparedStatement) would be collected.
 plugin.jdbc.trace_sql_parameters=${SW_JDBC_TRACE_SQL_PARAMETERS:true}
​
# Kafka producer configuration
# plugin.kafka.bootstrap_servers=${SW_KAFKA_BOOTSTRAP_SERVERS:localhost:9092}
# if you want to set namespace. please make sure the OAP server has set it in Kafka fetcher module
 plugin.kafka.namespace=${SW_KAFKA_NAMESPACE:""}
​
# Match spring bean with regex expression for classname
 plugin.springannotation.classname_match_regex=${SW_SPRINGANNOTATION_CLASSNAME_MATCH_REGEX:}
​
plugin.toolkit.log.grpc.reporter.server_host=${SW_GRPC_LOG_SERVER_HOST:192.168.29.74}
# 指定要向其报告日志数据的grpc服务器的端口
plugin.toolkit.log.grpc.reporter.server_port=${SW_GRPC_LOG_SERVER_PORT:11800}
# 指定grpc客户端要报告的日志数据的最大大小
plugin.toolkit.log.grpc.reporter.max_message_size=${SW_GRPC_LOG_MAX_MESSAGE_SIZE:10485760}
# 客户端向上游发送数据时将超时多长时间。单位是秒
plugin.toolkit.log.grpc.reporter.upstream_timeout=${SW_GRPC_LOG_GRPC_UPSTREAM_TIMEOUT:30}
​
​
plugin.springmvc.use_qualified_name_as_endpoint_name=true
plugin.toolit.use_qualified_name_as_operation_name=true
plugin.tomcat.collect_http_params=true
plugin.springmvc.collect_http_params=true
plugin.http.http_params_length_threshold=true
plugin.http.http_headers_length_threshold=true
plugin.http.include_http_headers=true
plugin.feign.collect_request_body=true
plugin.lettuce.trace_redis_parameters=true
plugin.lettuce.redis_parameter_max_length=true
​

你可能感兴趣的:(skywalking,分布式,spring,boot,elasticsearch,skywalking,spring,cloud)