当前位置:网站首页>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
边栏推荐
- Spark accumulators and broadcast variables
- 0 foundation a literature club low code development member management applet (III)
- 【图像分割】基于形态学实现视网膜血管分割附matlab代码
- Laravel文档阅读笔记-Laravel Str slug() Function Example
- Big factories are not the only way to measure ability. The three years' experience of Shangcai's graduation
- MFC使用控制台时 项目路径中不能有空格和中文,否则会报错误 LNK1342 未能保存要编辑的二进制文件的备份副本等
- The third session of freshman engineering education seminar is under registration
- [security] how to [host security - hybrid cloud version] support secure access to non Tencent virtual machines
- 【云驻共创】华为云HCIA-IoT V2.5培训系列内容之物联网概览
- Accelerate large-scale data analysis based on Apache iceberg through data organization optimization
猜你喜欢

JVM调试工具-Arthas

FreeRTOS MPU makes the system more robust!

Huawei cloud database advanced learning

【信号识别】基于深度学习CNN实现信号调制分类附matlab代码

蓝牙耳机怎么连接电脑使用,win10电脑如何连接蓝牙耳机

Decryption of the original divine square stone mechanism

Leetcode概率题面试突击系列11~15

Become TD hero, a superhero who changes the world with Technology | invitation from tdengine community

在js中正则表达式验证小时分钟,将输入的字符串转换为对应的小时和分钟

原神方石机关解密
随机推荐
[security] how to [host security - hybrid cloud version] support secure access to non Tencent virtual machines
RealNetworks vs. 微软:早期流媒体行业之争
Stop looking! The most complete data analysis strategy of the whole network is here
The cloud monitoring system hertzbeat V1.1.0 is released, and a command starts the monitoring journey!
Accelerate large-scale data analysis based on Apache iceberg through data organization optimization
JVM调试工具-Arthas
【愚公系列】2022年6月 ASP.NET Core下CellReport报表工具基本介绍和使用
JVM debugging tool -jvisualvm
Development of IOT device end - establishment of development environment
Spark project Packaging Optimization Practice
Kaseya of the United States was attacked by hackers, and 1500 downstream enterprises were damaged. How can small and medium-sized enterprises prevent extortion virus?
Typora收费?搭建VS Code MarkDown写作环境
0 foundation a literature club low code development member management applet (5)
【图像融合】基于方向离散余弦变换和主成分分析的图像融合附matlab代码
蓝牙耳机怎么连接电脑使用,win10电脑如何连接蓝牙耳机
MAUI使用Masa blazor组件库
Mysql---三张表(student,课程,分数) 查询课程为数学的学生姓名,编号,成绩
High energy ahead: Figure 18 shows you how to use the waterfall chart to visually reflect data changes
Leetcode概率题面试突击系列11~15
Accumulateur Spark et variables de diffusion