mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-09-29 05:56:38 +08:00
f0e234df1f
Agent 仅上报 host_metrics/edge_health/access_logs;业务流量与 UV 由 Server 侧访问日志聚合。新增 of_node_edge_health 与 of_access_log_hourly, 删除 request_reports/openresty 吞吐路径;API 不再暴露 traffic_reports 与 openresty_rx|tx。心跳/离线默认阈值与回填迁移一并入库。
46 lines
1.5 KiB
Go
46 lines
1.5 KiB
Go
// Copyright 2026 Arctel.net
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
package analytics
|
|
|
|
import (
|
|
"fmt"
|
|
"time"
|
|
)
|
|
|
|
const (
|
|
nodeAccessLogTableName = "of_node_access_logs"
|
|
nodeAccessLogInsertColumns = "id, node_id, logged_at, remote_addr, region, host, path, status_code, bytes_sent, request_length, request_time_ms, created_at"
|
|
)
|
|
|
|
// NodeAccessLog stores OpenFlare edge node access records in ClickHouse.
|
|
type NodeAccessLog struct {
|
|
ID uint64 `gorm:"column:id"`
|
|
NodeID string `gorm:"column:node_id"`
|
|
LoggedAt time.Time `gorm:"column:logged_at"`
|
|
RemoteAddr string `gorm:"column:remote_addr"`
|
|
Region string `gorm:"column:region"`
|
|
Host string `gorm:"column:host"`
|
|
Path string `gorm:"column:path"`
|
|
StatusCode int32 `gorm:"column:status_code"`
|
|
BytesSent uint64 `gorm:"column:bytes_sent"`
|
|
RequestLength uint64 `gorm:"column:request_length"`
|
|
RequestTimeMs uint32 `gorm:"column:request_time_ms"`
|
|
CreatedAt time.Time `gorm:"column:created_at"`
|
|
}
|
|
|
|
// TableName returns the ClickHouse table name.
|
|
func (NodeAccessLog) TableName() string {
|
|
return nodeAccessLogTableName
|
|
}
|
|
|
|
// InsertColumns returns comma-separated column names for batch insert.
|
|
func (NodeAccessLog) InsertColumns() string {
|
|
return nodeAccessLogInsertColumns
|
|
}
|
|
|
|
// BatchInsertSQL returns the INSERT prefix used by native batch writers.
|
|
func (NodeAccessLog) BatchInsertSQL() string {
|
|
return fmt.Sprintf("INSERT INTO %s (%s)", nodeAccessLogTableName, nodeAccessLogInsertColumns)
|
|
}
|