Nginx+SpringBoot反向代理,链路无法串联原因:因为agent中设置了namespace,导致获取http header头 sw8 时,发生异常。
集群搭建教程(skywalking集群、nacos集群、es集群、nginx 负载均衡):055. SkyWalking 集群环境搭建 - 山海紫穹 - OSCHINA - 中文开源技术交流社区
官方集群搭建博客:SkyWalking 极简入门 | Apache SkyWalking
SpringCloud+SkyWalking链路追踪集合:芋道 Spring Cloud 链路追踪 SkyWalking | 芋道源码 —— 纯源码解析博客
全链路监控:skywalking中文文档_如何使用skywalking 进行全链路监控_weixin_39944375的博客-CSDN博客
Skywalking系列博客:标签: Skywalking | 周立的博客 - 关注Spring Cloud、Docker
skywalking(集群):Tag-8.3.0,es:7(集群),nacos(注册配置中心+mysql持久化),下载地址:https://github.com/apache/skywalking/tags
模块:RocketBotUI,OAPServer,JavaAgent(oracle plugin单独获取)
example:https://www.cnblogs.com/MikeYao/p/14374264.html
1、javaAgent介绍及使用,包括plugins以及配置属性介绍
https://github.com/apache/skywalking/blob/master/docs/en/setup/service-agent/java-agent/README.md
2、Oracle agent-plugins、
https://github.com/SkyAPM/java-plugin-extensions
2.1、Nginx Plugin、Openresty安装
GitHub - apache/skywalking-nginx-lua: The Nginx Lua agent for Apache SkyWalking
OpenResty - 安装
当 Openresty/Nginx 遇上 Skyalking - 知乎
3、插件模块介绍及外部插件获取方式
https://www.cnblogs.com/kebibuluan/p/13151144.html
4、B站视频
05-环境搭建-skywalking环境搭建_哔哩哔哩_bilibili
5、告警配置相关
Skywalking-告警功能实践_successful rate of service stock-sentinel is lower_OkidoGreen的博客-CSDN博客
6、前端告警上报功能
SkyWalking 前端监控的应用 | 云原生社区 (cloudnative.to)
SkyWalking 8.2.0 中的新特性: 浏览器端监控; 使用标签查询; 指标分析语言 | Apache SkyWalking
7、ES7集群部署+SkyWalking部署
ES7集群搭建及SkyWalking部署_skywalking 9对应es_alanzy123的博客-CSDN博客
(1669条消息) 【elasticsearch】elasticsearch7.x集群搭建_es7集群搭建_郝少的博客-CSDN博客
7.1、关于集群部署
【弄nèng - Skywalking】入门篇(二)—— Skywalking集群部署_skywalking nacos 采样_司马缸砸缸了的博客-CSDN博客
7.2、集群相关配置属性
参数解释以及集群模式部署 · Apache Skywalking Handbook
8、配合日志框架打印 traceId、span
https://lux-sun.blog.csdn.net/article/details/109220200
skywalking项目打印traceId_skywalking打印traceid_xixingzhe2的博客-CSDN博客
8.1、上报请求参数
skywalking上报请求参数及日志打印traceId_skywalking 上报请求参数_it噩梦的博客-CSDN博客
9、调用链忽略跟踪(心跳等)
SkyWalking 调用链忽略(取消跟踪)_ignored_trace_OkidoGreen的博客-CSDN博客
10、SkyWalking 数据清理机制(TTL) elasticsearch
SkyWalking 数据清理机制(TTL) - zm123321的个人空间 - OSCHINA - 中文开源技术交流社区
后端(Oap)又分为三个角色
Mixed: Receive agent data, Level 1 aggregate, Level 2 aggregate
Receiver: Receive agent data, Level 1 aggregate
Aggregator: Level 2 aggregate
后端集群角色配置,默认 Mixed 代表 Receiver 和 Aggregator 角色共存。
当我们的微服务规模较大的时候,可以通过调整 Receiver 和 Aggregator 集群来指责分离,提高 OAP 集群接收数据的效率。
SW_CORE_ROLE
在集群模式下可以还可以设置成Receiver和Aggregator来提高系统性能。
如果集群只有Receiver节点,在收集数据时会报错,因为内部通讯(发送/接收)找不到接收节点而失败。
11、SkyWalking 存储介绍 及相关配置调优说明
Skywalking的存储配置与调优_skywalking日志量过大_smooth00的博客-CSDN博客
12、ES7-Head插件安装:自行百度,需安装npm+grunt
13、实操,agent上报+数据应用
https://www.yuque.com/liuzhiqing/note/voksxx
14、SkyWalking 不使用 mq 进行agent与oap通信的原因?
https://github.com/apache/skywalking/blob/master/docs/en/FAQ/why_mq_not_involved.md
15、SkyWalking Query协议及 相关接口
graphql:https://github.com/apache/skywalking-query-protocol
说明文档:https://github.com/apache/skywalking/blob/master/docs/en/protocols/query-protocol.md
99、异常与问题
controller:
package com.example.demo.controller;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.HashMap;
import java.util.Map;
import java.lang.Thread;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.List;
@RestController
public class DemoController {
/**
* demo
* 用于调试agent是否上报成功
*/
@GetMapping("/demo/{id}")
public Map demo(@PathVariable("id") Integer id) throws Exception {
System.out.println("Controller-demo receive id = "+id);
Map map = new HashMap();
map.put("demo-id",id+"");
return map;
}
/**
* sleep
* 用于调试告警信息及alarm
*/
@GetMapping("/sleep/{id}")
public Map sleep(@PathVariable("id") Integer id) throws Exception {
Thread.sleep(1500);
System.out.println("Controller-sleep receive id = "+id);
Map map = new HashMap();
map.put("sleep-id",id+"");
return map;
}
/**
* alarm
* 接收来自skywalking的webhook
*/
@PostMapping("/alarm")
public List
启动命令
java -javaagent:C:\Users\gy25\Desktop\skywalking-apm-bin-es7\agent\skywalking-agent.jar -jar demo-0.0.1-SNAPSHOT.jar
启动参数说明/配置覆盖
配置覆盖
我们每次部署应用都需要复制一份agent,修改其中的服务名称,这样很麻烦。可以使用skywalking提供的配置覆盖功能通过启动命令动态指定服务名,这样agent只需要部署一份即可。skywalking支持的几种配置方式:
1、系统配置(System properties):
使用skywalking.+配置文件中的配置名作为系统配置项来进行覆盖。
为什么需要添加前缀?
agent的系统配置和环境与目标应用共享,所以加上前缀可以有效避免冲突。
java -Dxxxx=xxxx -Dxxxx=xxxx,
就是系统属性. 有关Skywalking的参数全部都要加 skywalking.+key作为属性的key.
案例,通过如下进行agent.service_name的覆盖
-Dskywalking.agent.service_name=application_name
2、探针配置(Agent options):
add the properties after the agent path in JVMarguments
-javaagent:/path/to/skywalking-agent.jar=[option1]=[value1],[option2]=[value2]
案例,通过如下进行agent.service_name的覆盖
-javaagent:/path/to/skywalking-agent.jar=agent.service_name=application_name
特殊字符,如果配置中包含分割父(,或者=),就必须使用引号包裹起来
-javaagent:/path/to/skywalking-agent.jar=agent.ignore_suffix='.jpg,.jpeg'
3、系统环境变量(system environment variables)
案例,由于agent.service_name配置项如下所示:
#The service name in UI
agent.service_name=${SW_AGNET_NAME:Your_ApplicationName}
可以在环境变量中设置SW_AGENT_NAME的值来指定服务名。
覆盖优先级
探针配置>系统配置>系统环境变量>配置文件中的值
目录:skywalking-apm-bin-es7\agent
配置文件:\config\agent.config
jar:skywalking-agent.jar
系统参数说明:Skywalking:Java Agent配置_简单随风的博客-CSDN博客
# 只列出了一些重要的
# 以下属性都可以在javaagent 启动中,增加 -Dskywalking.agent.service_name=demo
# The agent namespace,UI展示可分类,上报命名空间
# agent.namespace=${SW_AGENT_NAMESPACE:default-namespace}
# The service name in UI ,上报服务名
agent.service_name=${SW_AGENT_NAME:DEMO}
# Backend service addresses. 上报skywalking-oap地址
collector.backend_service=${SW_AGENT_COLLECTOR_BACKEND_SERVICES:127.0.0.1:11800}
# Logging file_name agent 日志名,默认logs目录下
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:""}
启动脚本:\bin\startup.bat
oap-server目录:skywalking-apm-bin-es7
oap-server配置文件:\config\application.yml
oap-server启动脚本:\bin\oapService.bat
oap-server可选plugin:skywalking-apm-bin-es7\agent\optional-plugins,移至 plugins 目录即可启用
核心类:oap-libs/*,org.apache.skywalking.oap.server.starter.OAPServerStartUp
# 默认standalone单机模式,集群模式可选择注册中心(zk、nacos、etcd、consul等)
#存储选用elasticsearch7,可以更改es7相关属性,集群或单机,namespace=cluster-name
storage:
selector: ${SW_STORAGE:elasticsearch7}
elasticsearch7:
nameSpace: ${SW_NAMESPACE:""}
clusterNodes: ${SW_STORAGE_ES_CLUSTER_NODES:localhost:9200}
#配置中心,可选择(zk、nacos等,与注册中心雷同)
configuration:
selector: ${SW_CONFIGURATION:none}
# 定义定期清理ES中数据的时间,单位为天,可根据需求自行延长
core
recordDataTTL: ${SW_CORE_RECORD_DATA_TTL:3} # Unit is day
metricsDataTTL: ${SW_CORE_METRICS_DATA_TTL:7} # Unit is day
webapp-目录:skywalking-apm-bin-es7
webapp配置文件:\webapp\webapp.yml
jar:\webapp\skywalking-webapp.jar
webapp启动脚本:\bin\webappService.bat
# 配置主站入口
server:
port: 8088
collector:
path: /graphql
ribbon:
ReadTimeout: 10000
# Point to all backend's restHost:restPort, split by ,
# sw core-rest api地址
listOfServers: 127.0.0.1:12800
配置目录文件:skywalking-apm-bin-es7\config\alarm-settings.yml
# 下面的默认注释有些标注不是太清楚,service_resp_time 应该是最近5分钟内 所有上报应用
# 的响应时间超过阈值 1000的次数大于 2次,即调用最后 webhooks中的 http请求。
# 可选参数可以自行查阅官方文档
rules:
# Rule unique name, must be ended with `_rule`.
service_resp_time_rule:
metrics-name: service_resp_time
op: ">"
threshold: 1000
period: 5
count: 2
silence-period: 2
message: Response time of service {name} is more than 1000ms in 3 minutes of last 10 minutes.
service_sla_rule:
...
message: Successful rate of service {name} is lower than 80% in 2 minutes of last 10 minutes
service_resp_time_percentile_rule:
...
message: Percentile response time of service {name} alarm in 3 minutes of last 10 minutes, due to more than one condition of p50 > 1000, p75 > 1000, p90 > 1000, p95 > 1000, p99 > 1000
service_instance_resp_time_rule:
...
message: Response time of database access {name} is more than 1000ms in 2 minutes of last 10 minutes
endpoint_relation_resp_time_rule:
...
message: Response time of endpoint relation {name} is more than 1000ms in 2 minutes of last 10 minutes
webhooks:
- http://127.0.0.1:8080/alarm
# - http://127.0.0.1/notify/
# - http://127.0.0.1/go-wechat/
1、单机版正常安装即可,此处先忽略,默认端口 9200
2、head插件需要优先安装 npm+grunt+head插件,默认端口 9100