diff --git a/demo/prometheus/prometheus-docker-compose.yaml b/demo/prometheus/prometheus-docker-compose.yaml new file mode 100644 index 0000000000..0777e2585e --- /dev/null +++ b/demo/prometheus/prometheus-docker-compose.yaml @@ -0,0 +1,27 @@ +#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.3' +services: + prometheus: + image: prom/prometheus + container_name: prometheus + restart: always + command: + - '--config.file=/etc/prometheus/prometheus.yml' + volumes: + - ./prometheus.yml:/etc/prometheus/prometheus.yml:ro + ports: + - '9090:9090' diff --git a/demo/prometheus/prometheus.yml b/demo/prometheus/prometheus.yml new file mode 100644 index 0000000000..744f1899d9 --- /dev/null +++ b/demo/prometheus/prometheus.yml @@ -0,0 +1,15 @@ +global: + scrape_interval: 15s + evaluation_interval: 15s + +scrape_configs: + - job_name: 'prometheus' + static_configs: + - targets: + - '127.0.0.1:9090' + + - job_name: 'layotto' + scheme: http + static_configs: + - targets: + - 'docker.for.mac.localhost:34903' \ No newline at end of file diff --git a/docs/_sidebar.md b/docs/_sidebar.md index 75457ecea0..e833829bba 100644 --- a/docs/_sidebar.md +++ b/docs/_sidebar.md @@ -18,6 +18,8 @@ - Flow Control on the 7th layer network - [Method Level Flow Control](en/start/stream_filter/flow_control.md) - [Observability (trace, metric)](en/start/trace/trace.md) + - [Prometheus metrics](en/start/trace/prometheus.md) + - [Skywalking trace](en/start/trace/skywalking.md) - [Health check and metadata query](en/start/actuator/start.md) - [Run business logic in Layotto using WASM](en/start/wasm/start.md) - [FaaS model based on WASM and Runtime](en/start/faas/start.md) diff --git a/docs/en/start/trace/prometheus.md b/docs/en/start/trace/prometheus.md new file mode 100644 index 0000000000..2629219588 --- /dev/null +++ b/docs/en/start/trace/prometheus.md @@ -0,0 +1,64 @@ +# Prometheus metrics + +## Run prometheus + +window users need to change the layotto in prometheus.yml to 'docker.for.windows.localhost:34903' + +![](https://gw.alipayobjects.com/mdn/rms_5891a1/afts/img/A*mMAeSa8VQ-UAAAAAAAAAAAAAARQnAQ) + +```shell +cd ${project_path}/demo/prometheus + +docker-compose -f prometheus-docker-compose.yaml up -d +``` + +## Run layotto + +A layotto server can be started as follows. + +```shell +cd ${project_path}/cmd/layotto +``` + +Build it: + +```shell @if.not.exist layotto +go build -o layotto +``` + +Run it: + +```shell @background +./layotto start -c ../../configs/config_trace_skywalking.json +``` + +## Run Demo + +The corresponding call-side code is in [client.go](https://github.com/mosn/layotto/blob/main/demo/flowcontrol/client.go), and running it calls layotto's SayHello interface. + +```shell + cd ${project_path}/demo/flowcontrol/ +``` + +Build the demo client: +```shell @if.not.exist client + go build -o client +``` + +Run the demo client: +```shell + ./client +``` + +Access http://127.0.0.1:9090/graph?g0.expr=grpc_request_total + +![](https://gw.alipayobjects.com/mdn/rms_5891a1/afts/img/A*mEVNSZMvtvEAAAAAAAAAAAAAARQnAQ) + + +Release resources + +```shell +cd ${project_path}/demo/prometheus + +docker-compose -f prometheus-docker-compose.yaml down +``` \ No newline at end of file diff --git a/docs/en/start/trace/skywalking.md b/docs/en/start/trace/skywalking.md new file mode 100644 index 0000000000..21af1e18fc --- /dev/null +++ b/docs/en/start/trace/skywalking.md @@ -0,0 +1,78 @@ +# Skywalking trace + +## Configuration + +Example: configs/config_trace_skywalking.json + +````json +{ + "tracing": { + "enable": true, + "driver": "SkyWalking", + "config": { + "reporter": "gRPC", + "backend_service": "127.0.0.1:11800", + "service_name": "layotto" + } + } +} +```` + +| Field | Required fields | Description | +|------------------|-----|--------------------------| +| reporter | Y | Reporting method grpc | +| backend_service | Y | skywalking oap server address | +| service_name | Y | Service Name | + +## Run skywalking + +```shell +cd ${project_path}/diagnostics/skywalking + +docker-compose -f skywalking-docker-compose.yaml up -d +``` + +## Run layotto + +```shell +cd ${project_path}/cmd/layotto_multiple_api/ +``` + +Build it: +```shell @if.not.exist layotto +go build -o layotto +``` + +Run it: + +```shell @background +./layotto start -c ../../configs/config_trace_skywalking.json +``` + +## Run Demo + +```shell + cd ${project_path}/demo/flowcontrol/ +``` + +Build the demo client: +```shell @if.not.exist client + go build -o client +``` + +Run the demo client: +```shell + ./client +``` + +Access http://127.0.0.1:8080 + +![](../../../img/trace/sky.png) + +## Release resources + +```shell +cd ${project_path}/diagnostics/skywalking + +docker-compose -f skywalking-docker-compose.yaml down +``` \ No newline at end of file diff --git a/docs/zh/_sidebar.md b/docs/zh/_sidebar.md index 1a3f39b83d..4ce2ae0bd7 100644 --- a/docs/zh/_sidebar.md +++ b/docs/zh/_sidebar.md @@ -22,6 +22,7 @@ - [健康检查、查询运行时元数据](zh/start/actuator/start.md) - 可观测性 - [Trace, Metrics](zh/start/trace/trace.md) + - [Metrics 接入 Prometheus](zh/start/trace/prometheus.md) - [Trace 接入 Skywalking](zh/start/trace/skywalking.md) - [将业务逻辑通过 WASM 下沉进sidecar](zh/start/wasm/start.md) - [基于 WASM 跟 Runtime 实现的 Faas 模型](zh/start/faas/start.md) diff --git a/docs/zh/start/trace/prometheus.md b/docs/zh/start/trace/prometheus.md new file mode 100644 index 0000000000..5945b3d454 --- /dev/null +++ b/docs/zh/start/trace/prometheus.md @@ -0,0 +1,69 @@ +# Prometheus metrics 接入 + +## 运行prometheus + +window用户需要将prometheus.yml中的layotto改成'docker.for.windows.localhost:34903' + +![](https://gw.alipayobjects.com/mdn/rms_5891a1/afts/img/A*mMAeSa8VQ-UAAAAAAAAAAAAAARQnAQ) + +```shell +cd ${project_path}/demo/prometheus + +docker-compose -f prometheus-docker-compose.yaml up -d +``` + +## 运行layotto + +可以按照如下方式启动一个layotto的server: + +切换目录: + +```shell +cd ${project_path}/cmd/layotto +``` + +构建: + +```shell @if.not.exist layotto +go build -o layotto +``` + +运行: + +```shell @background +./layotto start -c ../../configs/runtime_config.json +``` + +## 运行 Demo + +对应的调用端代码在[client.go](https://github.com/mosn/layotto/blob/main/demo/flowcontrol/client.go) 中,运行它会调用layotto的SayHello接口: + +切换目录: + +```shell + cd ${project_path}/demo/flowcontrol/ +``` + +构建: + +```shell @if.not.exist client + go build -o client +``` +运行: + +```shell +./client +``` + +访问 http://127.0.0.1:9090/graph?g0.expr=grpc_request_total + +![](https://gw.alipayobjects.com/mdn/rms_5891a1/afts/img/A*mEVNSZMvtvEAAAAAAAAAAAAAARQnAQ) + + +## 清理资源 + +```shell +cd ${project_path}/demo/prometheus + +docker-compose -f prometheus-docker-compose.yaml down +``` \ No newline at end of file diff --git a/etc/script/test-quickstart.sh b/etc/script/test-quickstart.sh index 447a808733..8f3426b667 100755 --- a/etc/script/test-quickstart.sh +++ b/etc/script/test-quickstart.sh @@ -29,7 +29,10 @@ quickstarts_in_default="docs/en/start/configuration/start.md docs/en/start/actuator/start.md docs/zh/start/trace/trace.md docs/en/start/trace/trace.md + docs/en/start/trace/skywalking.md docs/zh/start/trace/skywalking.md + docs/zh/start/trace/prometheus.md + docs/en/start/trace/prometheus.md docs/en/start/wasm/start.md docs/zh/start/wasm/start.md "