LCA日志系统2.0重磅来袭
使用 Docker 快速部署依赖服务:
cd docker/etcd && docker-compose up -d cd docker/mysql && docker-compose up -d # MySQL root 密码:max2024 cd docker/redis && docker-compose up -d 密码:max2024 # 创建 ES 映射目录 mkdir -p /data/backups/es /data/es01/data /data/es02/data chmod 777 /data/es01/data /data/es02/data 修改 vm.max_map_count = 262144 # 修改 docker-compose.yaml 中的 ES 配置(IP、内存等) cd docker/elasticsearch && docker-compose up -d cd docker/kafka && docker-compose up -d vim /etc/hosts 加上 172.16.0.70(内网IP) kafka
lca 程序。/opt/lca_sys/manifest/config/config.yaml/opt/lca_sys/resource/data/lca.sqlauth: order_no: "2025071799571021"
nohup ./lca & # 可先运行 ./lca 查看是否有报错
server {
listen 80;
server_name testlca.c4eee.cn;
access_log /www/wwwlogs/lca_access_nginx.log;
error_log /www/wwwlogs/lca_access_error_nginx.log;
# 静态资源根目录(指向 dist 文件夹)
root /opt/lca_sys/dist;
index index.html;
location / {
try_files $uri $uri/ /index.html; # 支持 Vue Router 的 history 模式
}
# 处理静态资源(JS/CSS/图片等)
location /assets/ {
alias /opt/lca_sys/dist/assets/;
expires 1y;
add_header Cache-Control "public";
}
location /api {
proxy_pass http://127.0.0.1:8808; #后端接口地址
proxy_set_header Host $proxy_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Authorization $http_authorization;
}
# 禁止访问 .git 等敏感文件
location ~ /\.(?!well-known) {
deny all;
}
}
支持动态路径,系统自动替换:
{Y} → 2025{y} → 25{M} → 01(补零){m} → 1(不补零){D} → 01{d} → 1{H} → 小时(24小时制)通过 HTTP 接口实时推送日志:
curl -X POST "http://你的地址:8086/send" \ -H "Content-Type: application/x-www-form-urlencoded" \ -d "topic=ai_api&data=你的日志内容"
开发人员可轻松集成,吞吐率高。
// 要发送的数据
$data = [
'topic' => 'ai_api',
'data' => 'PHP测试日志' // 这里替换为你的实际日志内容
];
// 目标 URL
$url = 'http://8.138.162.13:8086/send';
// 初始化 cURL 句柄
$ch = curl_init();
// 设置 cURL 选项
curl_setopt_array($ch, [
CURLOPT_URL => $url,
CURLOPT_POST => true, // 使用 POST 方法
CURLOPT_POSTFIELDS => http_build_query($data), // 发送 POST 数据(自动编码为 x-www-form-urlencoded)
CURLOPT_HTTPHEADER => [
'Content-Type: application/x-www-form-urlencoded' // 设置请求头
],
CURLOPT_RETURNTRANSFER => true, // 将响应作为字符串返回,而不是直接输出
CURLOPT_TIMEOUT => 30, // 设置超时时间(秒)
CURLOPT_SSL_VERIFYPEER => false, // 如果是 HTTPS,可选:跳过 SSL 证书验证(生产环境慎用)
]);
// 执行请求
$response = curl_exec($ch);
// 检查是否有 cURL 错误
if (curl_error($ch)) {
echo 'cURL Error: ' . curl_error($ch);
} else {
// 输出响应状态码
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
echo "HTTP Status Code: $httpCode\n";
// 输出响应体
echo "Response: " . $response . "\n";
}
// 关闭 cURL 句柄
curl_close($ch);
package main
import (
"fmt"
"io"
"log"
"net/http"
"net/url"
"strings"
"time"
)
func main() {
// 定义目标 URL
urlStr := "http://8.138.162.13:8086/send"
// 准备表单数据
data := url.Values{}
data.Set("topic", "ai_api")
data.Set("data", "go测试日志")
// 创建请求体 (字符串)
reqBody := strings.NewReader(data.Encode()) // Encode() 将 Values 转为 "key=value&..." 格式
// 创建 POST 请求
req, err := http.NewRequest("POST", urlStr, reqBody)
if err != nil {
log.Fatalf("创建请求失败: %v", err)
}
// 设置请求头
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
// 创建 HTTP 客户端,可以设置超时等
client := &http.Client{
Timeout: 30 * time.Second, // 设置 30 秒超时
}
// 发送请求
resp, err := client.Do(req)
if err != nil {
log.Fatalf("请求失败: %v", err)
}
defer resp.Body.Close()
// 输出状态码
fmt.Printf("HTTP 状态码: %d\n", resp.StatusCode)
// 可选:读取并打印响应体
body, _ := io.ReadAll(resp.Body)
fmt.Printf("响应内容: %s\n", body)
}
// Node.js >= 18
const data = new URLSearchParams();
data.append('topic', 'ai_api');
data.append('data', 'Node.js 发送的日志');
const url = 'http://8.138.162.13:8086/send';
async function sendLog() {
try {
const response = await fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
body: data
});
console.log('状态码:', response.status);
if (!response.ok) {
throw new Error(`HTTP ${response.status}`);
}
const result = await response.text();
console.log('响应:', result);
} catch (error) {
console.error('错误:', error);
}
}
sendLog();