Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: Add prometheus demo #480

Merged
merged 34 commits into from
May 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
4eff88c
feature: Add prometheus demo
LXPWing Apr 16, 2022
1c8d95e
Merge branch 'main' into feature/prometheus_demo
LXPWing Apr 16, 2022
79aea5d
feature: Add prometheus docker compose
LXPWing Apr 20, 2022
0e2edc8
fix: yml style
LXPWing Apr 20, 2022
98af484
Merge branch 'main' into feature/prometheus_demo
LXPWing Apr 21, 2022
d3ee0c3
Merge branch 'main' into feature/prometheus_demo
seeflood Apr 29, 2022
35a24f1
Merge branch 'main' into feature/prometheus_demo
seeflood May 3, 2022
509521c
Merge branch 'main' into feature/prometheus_demo
seeflood May 5, 2022
73b1d20
feature: add docs
LXPWing May 6, 2022
a30401e
Merge remote-tracking branch 'origin/feature/prometheus_demo' into fe…
LXPWing May 6, 2022
052bc2a
feature: add en docs
LXPWing May 7, 2022
85d1efc
Merge branch 'main' into feature/prometheus_demo
LXPWing May 7, 2022
efa1fcf
Merge branch 'main' into feature/prometheus_demo
seeflood May 10, 2022
4a1d282
delete prometheus.png and upload it to a CDN
seeflood May 10, 2022
413f50e
fix: docs error
LXPWing May 10, 2022
8439ca5
Merge remote-tracking branch 'origin/feature/prometheus_demo' into fe…
LXPWing May 10, 2022
d05acd6
Merge branch 'main' into feature/prometheus_demo
seeflood May 10, 2022
b711d01
Update docs/en/start/trace/skywalking.md
LXPWing May 10, 2022
89f9943
Update docs/en/start/trace/skywalking.md
LXPWing May 10, 2022
8721913
Update docs/zh/start/trace/prometheus.md
LXPWing May 10, 2022
e049b37
Update docs/en/start/trace/prometheus.md
LXPWing May 10, 2022
463ceda
Update docs/en/start/trace/prometheus.md
LXPWing May 10, 2022
3c585bd
fix: add test-quickstart.sh
LXPWing May 10, 2022
5822d9f
Merge remote-tracking branch 'origin/feature/prometheus_demo' into fe…
LXPWing May 10, 2022
cad49b9
fix: test-quickstart.sh style
LXPWing May 10, 2022
891f152
fix: docs
LXPWing May 10, 2022
466056d
fix: docs style
LXPWing May 11, 2022
f18f843
Merge branch 'main' into feature/prometheus_demo
seeflood May 11, 2022
c480e8d
Merge branch 'main' into feature/prometheus_demo
seeflood May 12, 2022
5092da0
fix: docs
LXPWing May 13, 2022
47b3e26
Merge remote-tracking branch 'origin/feature/prometheus_demo' into fe…
LXPWing May 13, 2022
a0ab119
Merge branch 'main' into feature/prometheus_demo
seeflood May 13, 2022
cb1c55d
upload image to cdn
seeflood May 13, 2022
d5226ec
Merge branch 'main' into feature/prometheus_demo
seeflood May 14, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions demo/prometheus/prometheus-docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -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'
15 changes: 15 additions & 0 deletions demo/prometheus/prometheus.yml
Original file line number Diff line number Diff line change
@@ -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'
LXPWing marked this conversation as resolved.
Show resolved Hide resolved
2 changes: 2 additions & 0 deletions docs/_sidebar.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
64 changes: 64 additions & 0 deletions docs/en/start/trace/prometheus.md
Original file line number Diff line number Diff line change
@@ -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
```
LXPWing marked this conversation as resolved.
Show resolved Hide resolved

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
```
LXPWing marked this conversation as resolved.
Show resolved Hide resolved

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
```
78 changes: 78 additions & 0 deletions docs/en/start/trace/skywalking.md
Original file line number Diff line number Diff line change
@@ -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
```
LXPWing marked this conversation as resolved.
Show resolved Hide resolved

Run it:

```shell @background
./layotto start -c ../../configs/config_trace_skywalking.json
LXPWing marked this conversation as resolved.
Show resolved Hide resolved
```

## 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
```
1 change: 1 addition & 0 deletions docs/zh/_sidebar.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
69 changes: 69 additions & 0 deletions docs/zh/start/trace/prometheus.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# Prometheus metrics 接入
LXPWing marked this conversation as resolved.
Show resolved Hide resolved

## 运行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
```
LXPWing marked this conversation as resolved.
Show resolved Hide resolved

## 运行layotto

可以按照如下方式启动一个layotto的server:

切换目录:

```shell
cd ${project_path}/cmd/layotto
```

构建:

```shell @if.not.exist layotto
go build -o layotto
```
LXPWing marked this conversation as resolved.
Show resolved Hide resolved

运行:

```shell @background
./layotto start -c ../../configs/runtime_config.json
LXPWing marked this conversation as resolved.
Show resolved Hide resolved
```

## 运行 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
```
3 changes: 3 additions & 0 deletions etc/script/test-quickstart.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
"
Expand Down