Skywalking Demo

参考 https://www.cnblogs.com/fallTakeMan/p/13437215.html

SkyWalking 是观察性分析平台和应用性能管理系统。提供分布式追踪、服务网格遥测分析、度量聚合和可视化一体化解决方案。支持Java, .Net Core, PHP, NodeJS, Golang, LUA语言探针,支持Envoy + Istio构建的Service Mesh。

  这里抛出两个概念,SkyWalking 服务和语言探针。SkyWalking 本身是用 Java 写的,作为应用性能管理系统,探针是收集应用性能指标数据的,比如在 .net core 项目中引入 SkyAPM.Agent.AspNetCore,做一些配置,就可以将该项目的数据报告给 SkyWalking 服务,在 SkyWalking UI 界面看到可视化的数据。

  SkyWalking 展示的数据是需要存储的,默认是 H2,同时也支持使用ElasticSearch、MySQL、TiDB、InfluxDB,这里使用 elasticsearch。

1.docker compose 进行安装

# 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.

version: '3.8'
services:
  elasticsearch:
    image: docker.elastic.co/elasticsearch/elasticsearch:7.5.0
    container_name: elasticsearch
    restart: always
    ports:
      - 9200:9200
    healthcheck:
      test: ["CMD-SHELL", "curl --silent --fail localhost:9200/_cluster/health || exit 1"]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 40s
    environment:
      - discovery.type=single-node
      - bootstrap.memory_lock=true
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
    ulimits:
      memlock:
        soft: -1
        hard: -1
  oap:
    image: apache/skywalking-oap-server:8.1.0-es7
    container_name: oap
    depends_on:
      - elasticsearch
    links:
      - elasticsearch
    restart: always
    ports:
      - 11800:11800
      - 12800:12800
    healthcheck:
      test: ["CMD-SHELL", "/skywalking/bin/swctl"]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 40s
    environment:
      SW_STORAGE: elasticsearch7
      SW_STORAGE_ES_CLUSTER_NODES: elasticsearch:9200
  ui:
    image: apache/skywalking-ui:8.1.0
    container_name: ui
    depends_on:
      - oap
    links:
      - oap
    restart: always
    ports:
      - 8080:8080
    environment:
      SW_OAP_ADDRESS: oap:12800
docker-compose.yml

2.创建webapi 项目添加nuget包和配置文件

dotnet new webapi -n sampleapp
cd sampleapp
dotnet add package SkyAPM.Agent.AspNetCore
set ASPNETCORE_HOSTINGSTARTUPASSEMBLIES=SkyAPM.Agent.AspNetCore
set SKYWALKING__SERVICENAME=sample_app

3.添加CLI和配置文件config

#Install SkyAPM.DotNet.CLI

dotnet tool install -g SkyAPM.DotNet.CLI

#Use dotnet skyapm config [your_service_name] [your_servers] to generate config file.

dotnet skyapm config sample_app 172.24.16.1:11800

4.运行项目

dotnet run

5.查看UI

本机访问 SkyWalking 服务地址,UI 暴露端口是 8080.

 

 

posted @ 2022-04-11 21:39  最爱吃汤圆27  阅读(226)  评论(0编辑  收藏  举报