Optimize logging docs (#1036)
* small fix for example Signed-off-by: 楚岳 <wangyike.wyk@alibaba-inc.com> * small fix for logging docs Signed-off-by: 楚岳 <wangyike.wyk@alibaba-inc.com> * fix typo Signed-off-by: 楚岳 <wangyike.wyk@alibaba-inc.com> Signed-off-by: 楚岳 <wangyike.wyk@alibaba-inc.com>
This commit is contained in:
parent
1e030e1a34
commit
5f46e3f5a6
|
@ -124,18 +124,28 @@ Configure the `stdout-logs` trait in the component, as follows:
|
|||
apiVersion: core.oam.dev/v1beta1
|
||||
kind: Application
|
||||
metadata:
|
||||
name: app-collect-stdout
|
||||
name: app-stdout-log
|
||||
namespace: default
|
||||
spec:
|
||||
components:
|
||||
- name: flog
|
||||
type: webservice
|
||||
- type: webservice
|
||||
name: comp-stdout-log
|
||||
properties:
|
||||
cmd:
|
||||
- flog
|
||||
image: mingrammer/flog
|
||||
image: busybox
|
||||
traits:
|
||||
- type: stdout-logs
|
||||
- type: command
|
||||
properties:
|
||||
command:
|
||||
- sh
|
||||
- -c
|
||||
- |
|
||||
while :
|
||||
do
|
||||
now=$(date +"%T")
|
||||
echo "stdout: $now"
|
||||
sleep 10
|
||||
done
|
||||
- type: stdout-logs
|
||||
```
|
||||
|
||||
After the application is created, you can find the deployment resource created by the application in the application dashboard of grafana, click `Detail` button to jump to the deployment resource dashboard, and find the log data below. as follows:
|
||||
|
@ -217,37 +227,40 @@ spec:
|
|||
|
||||
In this example, we transform nginx `combinded` format logs to json format, and adding a `new_field` json key to each log, the json value is `new value`. Please refer to [document](https://vector.dev/docs/reference/vrl/) for how to write vector VRL.
|
||||
|
||||
If you have a special log analysis dashboard for this processing method, you can refer to [document](../observability) to import it into grafana.
|
||||
If you have a special log analysis dashboard for this processing method, you can refer to [document](./visualization#dashboard-customization) to import it into grafana.
|
||||
|
||||
## Collecting file log
|
||||
|
||||
The loki addon also support to collect file logs of containers. It doesn't matter with which mode you're enabling the loki addon, it work for all modes. Use the trait as follows:
|
||||
The loki addon also support to collect file logs of containers. It doesn't matter with which mode you're enabling the loki addon, it works for all modes. Use the trait as follows:
|
||||
|
||||
```yaml
|
||||
apiVersion: core.oam.dev/v1beta1
|
||||
kind: Application
|
||||
metadata:
|
||||
name: app-vector
|
||||
name: app-file
|
||||
namespace: default
|
||||
spec:
|
||||
components:
|
||||
- name: my-biz
|
||||
type: webservice
|
||||
- type: webservice
|
||||
name: file-log-comp
|
||||
properties:
|
||||
cmd:
|
||||
- flog
|
||||
- -t
|
||||
- log
|
||||
- -o
|
||||
- /data/daily.log
|
||||
- -d
|
||||
- 10s
|
||||
- -w
|
||||
image: mingrammer/flog
|
||||
image: busybox
|
||||
traits:
|
||||
- properties:
|
||||
path: "/data/daily.log"
|
||||
type: file-logs
|
||||
- type: command
|
||||
properties:
|
||||
command:
|
||||
- sh
|
||||
- -c
|
||||
- |
|
||||
while :
|
||||
do
|
||||
now=$(date +"%T")
|
||||
echo "file: $now" >> /root/verbose.log
|
||||
sleep 10
|
||||
done
|
||||
- type: file-logs
|
||||
properties:
|
||||
path: /root/verbose.log
|
||||
```
|
||||
|
||||
In the example, we let business log of the `my-biz` component write to the `/data/daily.log` path in the container. After the application is created, you can view the corresponding file log results through the `deployment` dashboard.
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 689 KiB After Width: | Height: | Size: 184 KiB |
|
@ -121,18 +121,28 @@ loki 插件开启后会在各个集群装中安装一个专门的组件,负责
|
|||
apiVersion: core.oam.dev/v1beta1
|
||||
kind: Application
|
||||
metadata:
|
||||
name: app-collect-stdout
|
||||
name: app-stdout-log
|
||||
namespace: default
|
||||
spec:
|
||||
components:
|
||||
- name: flog
|
||||
type: webservice
|
||||
- type: webservice
|
||||
name: comp-stdout-log
|
||||
properties:
|
||||
cmd:
|
||||
- flog
|
||||
image: mingrammer/flog
|
||||
image: busybox
|
||||
traits:
|
||||
- type: stdout-logs
|
||||
- type: command
|
||||
properties:
|
||||
command:
|
||||
- sh
|
||||
- -c
|
||||
- |
|
||||
while :
|
||||
do
|
||||
now=$(date +"%T")
|
||||
echo "stdout: $now"
|
||||
sleep 10
|
||||
done
|
||||
- type: stdout-logs
|
||||
```
|
||||
|
||||
应用创建之后你可以在对应 grafana 应用大盘中找到该应用创建的 deployment 资源,从而点击跳转到 deployment 资源大盘,并在下面找到采集上来的日志数据。如下:
|
||||
|
@ -213,7 +223,7 @@ spec:
|
|||
```
|
||||
|
||||
该例子中,除了将 nginx 输出的 `combinded` 日志转换成 json 格式,并为每条日志增加一个 `new_field` 的 json key ,json value 的值为 `new value`。具体 vector VRL 如何编写请参考[文档](https://vector.dev/docs/reference/vrl/)。
|
||||
如果你针对这种处理方式,专门了特殊的日志分析大盘,可以参考 [文档](../observability) 将其导入到 grafana 中。
|
||||
如果你针对这种处理方式,制作了专门的日志分析大盘,可以参考 [文档](./visualization#dashboard-customization) 提供的三种方式将其导入到 grafana 中。
|
||||
|
||||
## 应用文件日志
|
||||
|
||||
|
@ -223,27 +233,30 @@ spec:
|
|||
apiVersion: core.oam.dev/v1beta1
|
||||
kind: Application
|
||||
metadata:
|
||||
name: app-vector
|
||||
name: app-file
|
||||
namespace: default
|
||||
spec:
|
||||
components:
|
||||
- name: my-biz
|
||||
type: webservice
|
||||
- type: webservice
|
||||
name: file-log-comp
|
||||
properties:
|
||||
cmd:
|
||||
- flog
|
||||
- -t
|
||||
- log
|
||||
- -o
|
||||
- /data/daily.log
|
||||
- -d
|
||||
- 10s
|
||||
- -w
|
||||
image: mingrammer/flog
|
||||
image: busybox
|
||||
traits:
|
||||
- properties:
|
||||
path: "/data/daily.log"
|
||||
type: file-logs
|
||||
- type: command
|
||||
properties:
|
||||
command:
|
||||
- sh
|
||||
- -c
|
||||
- |
|
||||
while :
|
||||
do
|
||||
now=$(date +"%T")
|
||||
echo "file: $now" >> /root/verbose.log
|
||||
sleep 10
|
||||
done
|
||||
- type: file-logs
|
||||
properties:
|
||||
path: /root/verbose.log
|
||||
```
|
||||
|
||||
在上面的例子中,我们把 `my-biz` 组件的业务日志输出到了容器内的 `/data/daily.log` 路径下。应用创建之后,你就可以通过应用下的 `deployment` 大盘查看到对应的文件日志结果。
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 689 KiB After Width: | Height: | Size: 184 KiB |
Loading…
Reference in New Issue