一、集成
1、引入nuget包
SkyAPM.Agent.AspNetCore
2、增加环境变量
ASPNETCORE_HOSTINGSTARTUPASSEMBLIES=SkyAPM.Agent.AspNetCore
3、增加配置文件
"SkyWalking": {
"ServiceName": "order", //服务名
"Namespace": "",
"HeaderVersions": [
"sw8"
],
"Sampling": {
"SamplePer3Secs": -1,
"Percentage": -1.0,
"LogSqlParameterValue": false
},
"Logging": {
"Level": "Information",
"FilePath": "logs/skyapm-{Date}.log"
},
"Transport": {
"Interval": 3000,
"ProtocolVersion": "v8",
"QueueSize": 30000,
"BatchSize": 3000,
"gRPC": {
"Servers": "10.6.14.30:11800", //指向SkywalkingOAP的地址
"Timeout": 100000,
"ConnectTimeout": 100000,
"ReportTimeout": 600000
}
}
}
二、部署
1、部署要准备的文件
docker-compose.yml
version: '2.3'
services:
elasticsearch:
image: 10.6.14.30:8845/rancher/elasticsearch:7.10.1
container_name: spd-elasticsearch
extra_hosts:
- "gateway.docker.internal:host-gateway"
ports:
- 9300:9300
- 9200:9200
restart: always
environment:
- TZ=Asia/Shanghai
- "ES_JAVA_OPTS=-Xms64m -Xmx512m"
- "discovery.type=single-node"
volumes:
- /home/skywalking/elasticsearch/data:/usr/share/elasticsearch/data
- /home/skywalking/elasticsearch/plugins:/usr/share/elasticsearch/plugins
networks:
- skywalking-network
skywalking-oap:
image: 10.6.14.30:8845/rancher/skywalking-oap-server:9.6.0
container_name: skywalking-oap
security_opt:
- seccomp:unconfined
extra_hosts:
- "gateway.docker.internal:host-gateway"
environment:
- TZ=Asia/Shanghai
- SW_ES_USER=
- SW_ES_PASSWORD=
- SW_STORAGE=elasticsearch
- SW_STORAGE_ES_CLUSTER_NODES=10.6.14.45:9200
ports:
- 11800:11800
- 12800:12800
volumes:
- /etc/localtime:/etc/localtime:ro
restart: always
networks:
- skywalking-network
skywalking-ui:
image: 10.6.14.30:8845/rancher/skywalking-ui:9.6.0
container_name: skywalking-ui
security_opt:
- seccomp:unconfined
extra_hosts:
- "gateway.docker.internal:host-gateway"
ports:
- 8070:8080
environment:
- TZ=Asia/Shanghai
- SW_OAP_ADDRESS=http://10.6.14.45:12800
restart: always
networks:
- skywalking-network
opentelemetry:
image: 10.6.14.30:8845/rancher/opentelemetry-collector:0.86.0
container_name: opentelemetry
extra_hosts:
- "gateway.docker.internal:host-gateway"
ports:
- 55678:55678
command: [ "--config=/etc/otel-collector-config.yaml" ]
volumes:
- /home/skywalking/otel-collector-config.yaml:/etc/otel-collector-config.yaml
restart: always
networks:
- skywalking-network
mysqld-exporter:
image: 10.6.14.30:8845/rancher/mysqld-exporter:v0.14.0
container_name: mysqld-exporter
extra_hosts:
- "gateway.docker.internal:host-gateway"
ports:
- 9104:9104
environment:
- TZ=Asia/Shanghai
- DATA_SOURCE_NAME=root:JZTeya0!@(10.6.14.45:3306)/
restart: always
networks:
- skywalking-network
networks:
skywalking-network:
external: false
otel-collector-config.yaml
receivers:
prometheus:
config:
scrape_configs:
- job_name: "vm-monitoring" # make sure to use this in the vm.yaml to filter only VM metrics
scrape_interval: 10s
static_configs:
- targets: ['gateway.docker.internal:9100']
prometheus/2:
config:
scrape_configs:
- job_name: 'mysql-monitoring'
scrape_interval: 5s
static_configs:
- targets: ['gateway.docker.internal:9104']
labels:
host_name: showcase
processors:
batch:
batch/2:
exporters:
otlp:
endpoint: gateway.docker.internal:11800 # The OAP Server address
# The config format of OTEL version prior to 0.34.0, eg. 0.29.0, should be:
# insecure: true
tls:
insecure: true
otlp/2:
endpoint: gateway.docker.internal:11800
tls:
insecure: true
#insecure: true
service:
pipelines:
metrics:
receivers: [prometheus]
processors: [batch]
exporters: [otlp]
metrics/2:
receivers: [prometheus/2]
processors: [batch/2]
exporters: [otlp/2]
2、部署成功后的服务
skywalking-ui
spd-elasticsearch
skywalking-oap
3、部署成功后的界面
三、使用