当前位置:网站首页>Deploy loglistener in tke container to collect logs to CLS
Deploy loglistener in tke container to collect logs to CLS
2022-06-24 07:15:00 【Nieweixing】
tke The business log collection of the cluster container usually uses the log collection component to collect logs , But there is one problem , The log collection cannot be delivered to cls, That is to say, the logs of the cluster can only be delivered to those in the same region cls in , But in some areas there is no cls Service , Then you cannot use the log collection service to collect tke Cluster container log to cls 了 . There is another way to deploy in the container LogListener, Post the container log to via the public network cls in . Today, let's talk about the specific implementation of this log collection method .
We're here docker Build a mirror image , take LogListener Install it into our image , Our image build directory is as follows
Be careful : The application in my example is demo, We will replace it with our own business procedures according to the actual situation , Corresponding dockerfile It also needs to be modified
[[email protected] log-collect]# ll total 11824 -rwxrwxrwx 1 root root 12098786 Jul 3 18:09 demo -rw-r--r-- 1 root root 566 Jul 3 18:19 Dockerfile -rwxr-xr-x 1 root root 56 Jul 3 18:19 start.sh
- demo: One go Program demo The executable of , The listening port is 3000, The log is in /data Under the table of contents
- Dockerfile: Used for image building
- start.sh: The startup script of the image
Let's take a look at the corresponding file contents
demo Files can be obtained directly from the connection https://github.com/nieweixing/go-test/blob/main/main/demo
Dockerfile Is as follows ,secretid and secretkey Replace with your own , If it is a public network, you need to add parameters -network internet
FROM centos:7 RUN yum install wget -y && mkdir -p /data RUN wget https://mirrors.tencent.com/install/cls/loglistener-linux-x64-2.6.1.tar.gz && tar -zxvf loglistener-linux-x64-2.6.1.tar.gz -C /usr/local && cd /usr/local/loglistener-2.6.1/tools && ./loglistener.sh install RUN /usr/local/loglistener-2.6.1/tools/loglistener.sh init -secretid AKIDJNM71vniy85mCNxxxxxx -secretkey 608zbx5wmY4YyF9uRitsxxxxx -region ap-guangzhou -network internet COPY demo /root COPY start.sh /root/start.sh CMD ["/root/start.sh"]
LogListener Installation reference documentation for https://cloud.tencent.com/document/product/614/17414
start.sh Is as follows
#!/bin/bash /etc/init.d/loglistenerd start ./root/demo
Create a directory , Then access the file to the directory , Execute the image build command to build an image
docker build -t xxxx .
You can also use the good image I built to test ccr.ccs.tencentyun.com/nwx_registry/log-to-cls:latest
After the image is built , Here we are cls It is in Guangzhou , We deployed the image to Beijing tke colony , See if it can be delivered to across regional public networks cls
We exposed a public network clb Type of service To provide access to
And then we have cls There are machine groups and topics configured to save logs , To configure the machine group, you need to go to the container to get the following group ip, stay cls Configuring machine groups ip Is to fill in group ip, Not a container ip.
[[email protected] /]# /etc/init.d/loglistenerd check | grep "group ip" group ip:172.18.0.15
We went to the cls Console create machine group
Then create a log topic to associate with the machine group created in the previous step
The acquisition path configured here is /data/ All under log Log file at the end
cls After the theme is configured , Let's visit the corresponding service, Then the program prints some logs , And then to cls Search
for i in {1..100}; do curl 49.xx.xx.xx:3000/health_check; doneFirst, let's go to the container to see if the log is generated
[[email protected] data]# tail /data/go.log 2021/07/03 11:02:33 I visited Health check This path 2021/07/03 11:02:33 I visited Health check This path 2021/07/03 11:02:33 I visited Health check This path 2021/07/03 11:02:34 I visited Health check This path 2021/07/03 11:02:34 I visited Health check This path 2021/07/03 11:02:34 I visited Health check This path 2021/07/03 11:02:34 I visited Health check This path 2021/07/03 11:02:34 I visited Health check This path 2021/07/03 11:02:34 I visited Health check This path 2021/07/03 11:02:34 I visited Health check This path
Enter the container to view the log file. The access log is generated , Then we go to cls Search below
cls Only logs can be retrieved , Here we use LogListener The collection container log is posted to cls Was a success
边栏推荐
- In the middle of the year, I have prepared a small number of automated interview questions. Welcome to the self-test
- c#:互斥锁的使用
- 捏脸师: 炙手可热的元宇宙造型师
- 云监控系统 HertzBeat v1.1.0 发布,一条命令开启监控之旅!
- 【均衡器】LS均衡器,DEF均衡器以及LMMSE均衡器的误码率性能对比仿真
- 取模软件 模拟显示验证取模数据正确性 逆向 把点阵数组bin文件转显示
- Multi sensor fusion track fusion
- 0 foundation a literature club low code development member management applet (III)
- Research on redis High Availability Mechanism
- Intranet learning notes (4)
猜你喜欢

JVM调试工具-Arthas

【pointNet】基于pointNet的三维点云目标分类识别matlab仿真

Open source and innovation

【图像融合】基于伪 Wigner 分布 (PWD) 实现图像融合附matlab代码

Win11笔记本省电模式怎么开启?Win11电脑节电模式打开方法

. Net7 miniapi (special part):preview5 optimizes JWT verification (Part 1)

JVM debugging tool -jvisualvm

Unexpected token u in JSON at position 0

In the middle of the year, I have prepared a small number of automated interview questions. Welcome to the self-test

年中了,准备了少量的自动化面试题,欢迎来自测
随机推荐
The cloud monitoring system hertzbeat V1.1.0 is released, and a command starts the monitoring journey!
Outils de débogage JVM - Arthas
SAP实施项目上的内部顾问与外部顾问,相互为难还是相互成就?【英文版】
Spark项目打包优化实践
【图像融合】基于伪 Wigner 分布 (PWD) 实现图像融合附matlab代码
Spark累加器和广播变量
为什么要用lock 【readonly】object?为什么不要lock(this)?
自动化测试是什么?什么软件项目适合自动化测试?
Smart space 𞓜 visualization of operation of digital twin cargo spacecraft
【图像融合】基于方向离散余弦变换和主成分分析的图像融合附matlab代码
展锐芯片之GPU频率
智能视觉组A4纸识别样例
Clickhouse source code note 6: exploring the sorting of columnar storage systems
Computing power and intelligence of robot fog
NVIDIA control panel does not open what is NVIDIA control panel
Huawei cloud database advanced learning
High energy ahead: Figure 18 shows you how to use the waterfall chart to visually reflect data changes
在js中正则表达式验证小时分钟,将输入的字符串转换为对应的小时和分钟
RealNetworks vs. 微软:早期流媒体行业之争
JVM调试工具-jmap