Files
waf-platform/EdgeHttpDNS/internal/accesslogs/httpdns_ingest_log.go
2026-03-02 20:07:53 +08:00

58 lines
1.9 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package accesslogs
import "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
// HTTPDNSIngestLog HTTPDNS 访问日志单行结构JSONEachRow字段与
// ClickHouse httpdns_access_logs_ingest 表一一对应。
type HTTPDNSIngestLog struct {
Timestamp int64 `json:"timestamp"`
RequestId string `json:"request_id"`
ClusterId int64 `json:"cluster_id"`
NodeId int64 `json:"node_id"`
AppId string `json:"app_id"`
AppName string `json:"app_name"`
Domain string `json:"domain"`
QType string `json:"qtype"`
ClientIP string `json:"client_ip"`
ClientRegion string `json:"client_region"`
Carrier string `json:"carrier"`
SDKVersion string `json:"sdk_version"`
OS string `json:"os"`
ResultIPs string `json:"result_ips"`
Status string `json:"status"`
ErrorCode string `json:"error_code"`
CostMs int32 `json:"cost_ms"`
CreatedAt int64 `json:"created_at"`
Day string `json:"day"`
Summary string `json:"summary"`
}
// FromPBAccessLog 将 pb.HTTPDNSAccessLog 转为本地 ingest 结构。
func FromPBAccessLog(log *pb.HTTPDNSAccessLog) *HTTPDNSIngestLog {
if log == nil {
return nil
}
return &HTTPDNSIngestLog{
Timestamp: log.GetCreatedAt(),
RequestId: log.GetRequestId(),
ClusterId: log.GetClusterId(),
NodeId: log.GetNodeId(),
AppId: log.GetAppId(),
AppName: log.GetAppName(),
Domain: log.GetDomain(),
QType: log.GetQtype(),
ClientIP: log.GetClientIP(),
ClientRegion: log.GetClientRegion(),
Carrier: log.GetCarrier(),
SDKVersion: log.GetSdkVersion(),
OS: log.GetOs(),
ResultIPs: log.GetResultIPs(),
Status: log.GetStatus(),
ErrorCode: log.GetErrorCode(),
CostMs: log.GetCostMs(),
CreatedAt: log.GetCreatedAt(),
Day: log.GetDay(),
Summary: log.GetSummary(),
}
}