Apache SkyWalking 监控 Linux 实战_skywalking监控服务器内存、cpu使用情 ...

立山  金牌会员 | 2024-10-4 18:10:09 | 来自手机 | 显示全部楼层 | 阅读模式
打印 上一主题 下一主题

主题 904|帖子 904|积分 2712

limitations under the License.

version: ‘3.8’
services:
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch-oss{ES_VERSION}
container_name: elasticsearch
ports:
- “9200:9200”
healthcheck:
test: [ “CMD-SHELL”, “curl --silent --fail localhost:9200/_cluster/health || exit 1” ]
interval: 30s
timeout: 10s
retries: 3
start_period: 10s
environment:
- discovery.type=single-node
- bootstrap.memory_lock=true
- “ES_JAVA_OPTS=-Xms512m -Xmx512m”
ulimits:
memlock:
soft: -1
hard: -1
oap:
image: ${OAP_IMAGE}
container_name: oap
depends_on:
elasticsearch:
condition: service_healthy
links:
- elasticsearch
ports:
- “11800:11800”
- “12800:12800”
healthcheck:
test: [ “CMD-SHELL”, “/skywalking/bin/swctl ch” ]
interval: 30s
timeout: 10s
retries: 3
start_period: 10s
environment:
SW_STORAGE: elasticsearch
SW_STORAGE_ES_CLUSTER_NODES: elasticsearch:9200
SW_HEALTH_CHECKER: default
SW_TELEMETRY: prometheus
JAVA_OPTS: “-Xms2048m -Xmx2048m”
ui:
image: ${UI_IMAGE}
container_name: ui
depends_on:
oap:
condition: service_healthy
links:
- oap
ports:
- “8080:8080”
environment:
SW_OAP_ADDRESS: http://oap:12800
SW_ZIPKIN_ADDRESS: http://oap:9412
  1. ###### .env
  2. 用于镜像版本,这里使用 SkyWalking 9.7.0 版本,也是当前最新的版本
复制代码
The docker-compose.yml file is meant to be used locally for testing only after a local build, if you want to use it

with officially released Docker images, please modify the environment variables on your command line interface.

i.e.:

export OAP_IMAGE=apache/skywalking-oap-server:

export UI_IMAGE=apache/skywalking-ui:

docker compose up

ES_VERSION=7.4.2
OAP_IMAGE=apache/skywalking-oap-server:9.7.0
UI_IMAGE=apache/skywalking-ui:9.7.0
  1. 启动 SkyWalking
复制代码
docker compose up
  1. 启动完成后,访问 <http://IP:8080> 就可以正常打开 dashboard 页面了,当然这个时候还看不到监控数据。
  2. ##### 部署 Prometheus node-exporter
  3. [node-exporter 官方文档]( ) ,下载地址 <https://prometheus.io/download/#node_exporter>  
  4. 这里下载 1.7.0 版本
复制代码
wget https://github.com/prometheus/node_exporter/releases/download/v1.7.0/node_exporter-1.7.0.linux-amd64.tar.gz
tar xvfz node_exporter-1.7.0.linux-amd64.tar.gz
cd node_exporter-1.7.0.linux-amd64
./node_exporter
  1. 启动成功后访问 <http://IP:9100/metrics> 可以看到采集到的 metrics 信息。  
  2. ![node-exporter-metrics](https://img-blog.csdnimg.cn/direct/614bb2d2a17942908aedb3a77488f143.png#pic_center)
  3. ##### 部署 OpenTelemetry Collector
  4. [OpenTelemetry Collector 官方文档]( )  
  5. 这里将 `otel-collector` 和 skywalking 一起通过 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-oss{ES_VERSION}
container_name: elasticsearch
ports:
- “9200:9200”
healthcheck:
test: [ “CMD-SHELL”, “curl --silent --fail localhost:9200/_cluster/health || exit 1” ]
interval: 30s
timeout: 10s
retries: 3
start_period: 10s
environment:
- discovery.type=single-node
- bootstrap.memory_lock=true
- “ES_JAVA_OPTS=-Xms512m -Xmx512m”
ulimits:
memlock:
soft: -1
hard: -1
oap:
image: ${OAP_IMAGE}
container_name: oap
depends_on:
elasticsearch:
condition: service_healthy
links:
- elasticsearch
ports:
- “11800:11800”
- “12800:12800”
healthcheck:
test: [ “CMD-SHELL”, “/skywalking/bin/swctl ch” ]
interval: 30s
timeout: 10s
retries: 3
start_period: 10s
environment:
SW_STORAGE: elasticsearch
SW_STORAGE_ES_CLUSTER_NODES: elasticsearch:9200
SW_HEALTH_CHECKER: default
SW_TELEMETRY: prometheus
JAVA_OPTS: “-Xms2048m -Xmx2048m”
ui:
image: ${UI_IMAGE}
container_name: ui
depends_on:
oap:
condition: service_healthy
links:
- oap
ports:
- “8080:8080”
environment:
SW_OAP_ADDRESS: http://oap:12800
SW_ZIPKIN_ADDRESS: http://oap:9412
otel-collector:
image: otel/opentelemetry-collector:0.50.0
container_name: otel-collector
command: [ “–config=/etc/otel-collector-config.yaml” ]
volumes:
- /opt/docker/skywalking/otel-collector-config.yaml:/etc/otel-collector-config.yaml
expose:
- 55678
  1. 在 /opt/docker/skywalking 目录(也可以自定义)创建配置文件 otel-collector-config.yaml
复制代码
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.

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: [“192.168.56.102:9100”] # OpenTelemetry Collector 的地点,根据本身的服务器IP举行调整
processors:
batch:
exporters:
otlp:
endpoint: “oap: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
#insecure: true
Exports data to the console

logging:
loglevel: debug
service:
pipelines:
metrics:
receivers: [prometheus]
processors: [batch]
exporters: [otlp, logging]
  1. docker compose 重新启动
复制代码
docker compose restart
  1. 访问 SkyWalking dashboard 页面,正常情况下就可以看到监控到的数据了。![linux-os-monitor](https://img-blog.csdnimg.cn/direct/d2b15d6e31574a60bdc6a8dd40f25e4c.png#pic_center)  
  2. ![linux-os-monitor-metrics](https://img-blog.csdnimg.cn/direct/aa498745a9ad415696bc229a1c262e01.png#pic_center)
  3. 相关链接
  4. * <https://skywalking.apache.org/docs/main/next/en/setup/backend/backend-vm-monitoring/>
复制代码
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。
回复

使用道具 举报

0 个回复

倒序浏览

快速回复

您需要登录后才可以回帖 登录 or 立即注册

本版积分规则

立山

金牌会员
这个人很懒什么都没写!

标签云

快速回复 返回顶部 返回列表