You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by ke...@apache.org on 2021/11/04 04:34:43 UTC

[skywalking-showcase] 10/12: Add virtual machine monitoring

This is an automated email from the ASF dual-hosted git repository.

kezhenxu94 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/skywalking-showcase.git

commit 367a60eeafebd61e569a194f6bf3238734e42376
Author: kezhenxu94 <ke...@apache.org>
AuthorDate: Thu Nov 4 10:55:50 2021 +0800

    Add virtual machine monitoring
---
 Makefile                                           | 23 +++-----
 Makefile.in                                        |  2 +
 deploy/platform/docker/Makefile                    | 14 ++++-
 .../docker/config/otel-collector-config.yaml       | 40 +++++++++++++
 ...ker-compose.yaml => docker-compose.agents.yaml} | 52 ++--------------
 deploy/platform/docker/docker-compose.vm.yaml      | 64 ++++++++++++++++++++
 deploy/platform/docker/docker-compose.yaml         | 69 ++--------------------
 scripts/make/help.mk                               |  7 +++
 8 files changed, 142 insertions(+), 129 deletions(-)

diff --git a/Makefile b/Makefile
index d4def26..57f5c08 100644
--- a/Makefile
+++ b/Makefile
@@ -15,9 +15,9 @@
 # specific language governing permissions and limitations
 # under the License.
 #
+include scripts/make/help.mk
 
-# Build each project under services/*
-
+##@ Build targets
 services = $(wildcard services/*)
 
 .PHONY: $(services)
@@ -25,14 +25,11 @@ $(services):
 	$(MAKE) -C $@ build
 
 .PHONY: build
-build: $(services)
-
-# Build Docker images
+build: $(services) ## Build the services
 
 services_docker = $(foreach svc,$(services),$(svc).docker.build)
-
 .PHONY: docker
-docker: $(services_docker)
+docker: $(services_docker) ## Build Docker images
 
 .PHONY: $(services_docker)
 $(services_docker): %.docker.build: %
@@ -41,22 +38,20 @@ $(services_docker): %.docker.build: %
 .PHONY: docker.build
 docker.build: $(services_docker)
 
-# Deploy and Undeploy
+##@ Deploy targets
 
-## Docker Compose
 .PHONY: deploy.docker
-deploy.docker: undeploy.docker
+deploy.docker: undeploy.docker ## Deploy the showcase with Docker Compose
 	$(MAKE) -C deploy/platform/docker deploy
 
 .PHONY: undeploy.docker
-undeploy.docker:
+undeploy.docker: ## Undeploy the showcase from Docker Compose
 	$(MAKE) -C deploy/platform/docker undeploy
 
-## Kubernetes
 .PHONY: deploy.kubernetes
-deploy.kubernetes: undeploy.kubernetes
+deploy.kubernetes: undeploy.kubernetes ## Deploy the showcase to Kubernetes
 	$(MAKE) -C deploy/platform/kubernetes deploy
 
 .PHONY: undeploy.kubernetes
-undeploy.kubernetes:
+undeploy.kubernetes: ## Undeploy the showcase from Kubernetes
 	$(MAKE) -C deploy/platform/kubernetes undeploy
diff --git a/Makefile.in b/Makefile.in
index 8ff0265..b1fc2b7 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -28,3 +28,5 @@ SW_ROCKET_BOT_IMAGE ?= ghcr.io/apache/skywalking/ui:c9bd79e8bb974e404766e3490c00
 
 SW_AGENT_NODEJS_BACKEND_VERSION ?= e755659c7f308d3b5589619778c8360308cb14f8
 SW_AGENT_NODEJS_FRONTEND_VERSION ?= af0565a67d382b683c1dbd94c379b7080db61449
+
+FEATURE_FLAGS ?= all
diff --git a/deploy/platform/docker/Makefile b/deploy/platform/docker/Makefile
index f1c65c8..d9e69c5 100644
--- a/deploy/platform/docker/Makefile
+++ b/deploy/platform/docker/Makefile
@@ -18,10 +18,20 @@
 
 include ../../../Makefile.in
 
+comma := ,
+
+ifeq ($(FEATURE_FLAGS),all)
+  features := $(wildcard docker-compose.*.yaml)
+  features := $(foreach f,$(features),-f $(f))
+else
+  features := $(subst $(comma), ,$(FEATURE_FLAGS))
+  features := $(foreach f,$(features),-f docker-compose.$(f).yaml)
+endif
+
 .PHONY: deploy
 deploy:
-	docker-compose up -d
+	docker-compose -f docker-compose.yaml $(features) up -d
 
 .PHONY: undeploy
 undeploy:
-	docker-compose --log-level ERROR down
+	docker-compose -f docker-compose.yaml $(features) --log-level ERROR down
diff --git a/deploy/platform/docker/config/otel-collector-config.yaml b/deploy/platform/docker/config/otel-collector-config.yaml
new file mode 100644
index 0000000..743a47a
--- /dev/null
+++ b/deploy/platform/docker/config/otel-collector-config.yaml
@@ -0,0 +1,40 @@
+# 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: 'otel-collector'
+          scrape_interval: 10s
+          static_configs:
+            - targets: [ 'vm1:9100', 'vm2:9100' ]
+
+processors:
+  batch:
+
+exporters:
+  opencensus:
+    endpoint: "oap:11800"
+    insecure: true
+  logging:
+    logLevel: debug
+
+service:
+  pipelines:
+    metrics:
+      receivers: [ prometheus ]
+      processors: [ batch ]
+      exporters: [ opencensus,logging ]
diff --git a/deploy/platform/docker/docker-compose.yaml b/deploy/platform/docker/docker-compose.agents.yaml
similarity index 67%
copy from deploy/platform/docker/docker-compose.yaml
copy to deploy/platform/docker/docker-compose.agents.yaml
index a1c908e..e64547d 100644
--- a/deploy/platform/docker/docker-compose.yaml
+++ b/deploy/platform/docker/docker-compose.agents.yaml
@@ -18,54 +18,7 @@
 version: '2.1'
 
 services:
-  elasticsearch:
-    image: docker.elastic.co/elasticsearch/elasticsearch-oss:${ES_VERSION}
-    networks: [ sw ]
-    ports:
-      - "9200:9200"
-    healthcheck:
-      test: [ "CMD-SHELL", "curl --silent --fail localhost:9200/_cluster/health" ]
-      interval: 30s
-      timeout: 10s
-      retries: 3
-    environment:
-      - discovery.type=single-node
-      - bootstrap.memory_lock=true
-      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
-    ulimits:
-      memlock:
-        soft: -1
-        hard: -1
-
-  oap:
-    image: ${SW_OAP_IMAGE}
-    networks: [ sw ]
-    environment:
-      SW_HEALTH_CHECKER: default
-      SW_TELEMETRY: prometheus
-      SW_STORAGE: elasticsearch
-      SW_STORAGE_ES_CLUSTER_NODES: elasticsearch:9200
-      JAVA_OPTS: "-Xms2048m -Xmx2048m"
-    healthcheck:
-      test: [ "CMD-SHELL", "/skywalking/bin/swctl ch" ]
-      interval: 30s
-      timeout: 10s
-      retries: 3
-    depends_on:
-      elasticsearch:
-        condition: service_healthy
-
-  rocket-bot:
-    image: ${SW_ROCKET_BOT_IMAGE}
-    networks: [ sw ]
-    ports:
-      - "9999:8080"
-    depends_on:
-      oap:
-        condition: service_healthy
-    environment:
-      SW_OAP_ADDRESS: http://oap:12800
-
+  # Java agent
   gateway:
     image: ${HUB}/gateway-service:${TAG}
     networks: [ sw ]
@@ -83,6 +36,7 @@ services:
       songs:
         condition: service_healthy
 
+  # Java agent
   songs:
     image: ${HUB}/songs-service:${TAG}
     networks: [ sw ]
@@ -98,6 +52,7 @@ services:
       oap:
         condition: service_healthy
 
+  # Python agent
   rcmd:
     image: ${HUB}/recommendation-service:${TAG}
     networks: [ sw ]
@@ -113,6 +68,7 @@ services:
       oap:
         condition: service_healthy
 
+  # NodeJS backend agent and NodeJS frontend agent
   app:
     image: ${HUB}/app:${TAG}
     networks: [ sw ]
diff --git a/deploy/platform/docker/docker-compose.vm.yaml b/deploy/platform/docker/docker-compose.vm.yaml
new file mode 100644
index 0000000..ac868f1
--- /dev/null
+++ b/deploy/platform/docker/docker-compose.vm.yaml
@@ -0,0 +1,64 @@
+# 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: '2.1'
+
+services:
+  # Pretend this is a virtual machine
+  vm1:
+    image: quay.io/prometheus/node-exporter:v1.2.2
+    networks: [ sw ]
+    expose:
+      - 9100
+    deploy:
+      resources:
+        limits:
+          cpus: 0.2
+          memory: 256M
+    depends_on:
+      oap:
+        condition: service_healthy
+
+  # Pretend this is a virtual machine
+  vm2:
+    image: quay.io/prometheus/node-exporter:v1.2.2
+    networks: [ sw ]
+    expose:
+      - 9100
+    deploy:
+      resources:
+        limits:
+          cpus: 0.2
+          memory: 256M
+    depends_on:
+      oap:
+        condition: service_healthy
+
+  otel-collector:
+    image: otel/opentelemetry-collector:0.29.0
+    networks: [ sw ]
+    command: [ "--config=/etc/otel-collector-config.yaml" ]
+    volumes:
+      - ./config/otel-collector-config.yaml:/etc/otel-collector-config.yaml
+    expose:
+      - 55678
+    depends_on:
+      oap:
+        condition: service_healthy
+
+networks:
+  sw:
diff --git a/deploy/platform/docker/docker-compose.yaml b/deploy/platform/docker/docker-compose.yaml
index a1c908e..ee1a435 100644
--- a/deploy/platform/docker/docker-compose.yaml
+++ b/deploy/platform/docker/docker-compose.yaml
@@ -42,9 +42,12 @@ services:
     networks: [ sw ]
     environment:
       SW_HEALTH_CHECKER: default
-      SW_TELEMETRY: prometheus
+      SW_OTEL_RECEIVER: default
+      SW_OTEL_RECEIVER_ENABLED_OC_RULES: vm
+      SW_PROMETHEUS_FETCHER: "default"
       SW_STORAGE: elasticsearch
       SW_STORAGE_ES_CLUSTER_NODES: elasticsearch:9200
+      SW_TELEMETRY: prometheus
       JAVA_OPTS: "-Xms2048m -Xmx2048m"
     healthcheck:
       test: [ "CMD-SHELL", "/skywalking/bin/swctl ch" ]
@@ -66,69 +69,5 @@ services:
     environment:
       SW_OAP_ADDRESS: http://oap:12800
 
-  gateway:
-    image: ${HUB}/gateway-service:${TAG}
-    networks: [ sw ]
-    environment:
-      SW_AGENT_NAME: gateway
-      SW_AGENT_COLLECTOR_BACKEND_SERVICES: oap:11800
-    healthcheck:
-      test: [ "CMD-SHELL", "wget -O /dev/null http://localhost/actuator/health" ]
-      interval: 30s
-      timeout: 10s
-      retries: 3
-    depends_on:
-      oap:
-        condition: service_healthy
-      songs:
-        condition: service_healthy
-
-  songs:
-    image: ${HUB}/songs-service:${TAG}
-    networks: [ sw ]
-    environment:
-      SW_AGENT_NAME: songs
-      SW_AGENT_COLLECTOR_BACKEND_SERVICES: oap:11800
-    healthcheck:
-      test: [ "CMD-SHELL", "wget -O /dev/null http://localhost/actuator/health" ]
-      interval: 30s
-      timeout: 10s
-      retries: 3
-    depends_on:
-      oap:
-        condition: service_healthy
-
-  rcmd:
-    image: ${HUB}/recommendation-service:${TAG}
-    networks: [ sw ]
-    environment:
-      SW_AGENT_NAME: recommendation
-      SW_AGENT_COLLECTOR_BACKEND_SERVICES: oap:11800
-    healthcheck:
-      test: [ "CMD-SHELL", "curl http://localhost/health" ]
-      interval: 30s
-      timeout: 10s
-      retries: 3
-    depends_on:
-      oap:
-        condition: service_healthy
-
-  app:
-    image: ${HUB}/app:${TAG}
-    networks: [ sw ]
-    ports:
-      - "9090:80"
-    environment:
-      SW_AGENT_NAME: app
-      SW_AGENT_COLLECTOR_BACKEND_SERVICES: oap:11800
-    healthcheck:
-      test: [ "CMD-SHELL", "curl http://localhost/health" ]
-      interval: 30s
-      timeout: 10s
-      retries: 3
-    depends_on:
-      oap:
-        condition: service_healthy
-
 networks:
   sw:
diff --git a/scripts/make/help.mk b/scripts/make/help.mk
new file mode 100644
index 0000000..8919cec
--- /dev/null
+++ b/scripts/make/help.mk
@@ -0,0 +1,7 @@
+##@ Other targets
+
+.PHONY: help
+help:  ## Display this help
+	@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n  make \033[36m<target>\033[0m\n"} \
+			/^[.a-zA-Z0-9_-]+:.*?##/ { printf "  \033[36m%-15s\033[0m \t%s\n", $$1, $$2 } \
+			/^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) }' $(MAKEFILE_LIST)