|
@@ -2,23 +2,22 @@ package nginx_log
|
|
|
|
|
|
import (
|
|
|
"sync"
|
|
|
- "time"
|
|
|
)
|
|
|
|
|
|
// LogFileInfo holds metadata about a log file
|
|
|
type LogFileInfo struct {
|
|
|
Path string
|
|
|
- LastModified time.Time
|
|
|
+ LastModified int64 // Unix timestamp
|
|
|
LastSize int64
|
|
|
- LastIndexed time.Time
|
|
|
+ LastIndexed int64 // Unix timestamp
|
|
|
IsCompressed bool
|
|
|
TimeRange *TimeRange
|
|
|
}
|
|
|
|
|
|
// TimeRange represents a time range for log entries
|
|
|
type TimeRange struct {
|
|
|
- Start time.Time
|
|
|
- End time.Time
|
|
|
+ Start int64 // Unix timestamp
|
|
|
+ End int64 // Unix timestamp
|
|
|
}
|
|
|
|
|
|
// CachedSearchResult represents a cached search result with total count
|
|
@@ -31,8 +30,8 @@ type CachedSearchResult struct {
|
|
|
type CachedStatsResult struct {
|
|
|
Stats *SummaryStats `json:"stats"`
|
|
|
QueryHash string `json:"query_hash"` // Hash of the query parameters
|
|
|
- LastCalculated time.Time `json:"last_calculated"` // When stats were calculated
|
|
|
- FilesModTime time.Time `json:"files_mod_time"` // Latest modification time of all log files
|
|
|
+ LastCalculated int64 `json:"last_calculated"` // Unix timestamp when stats were calculated
|
|
|
+ FilesModTime int64 `json:"files_mod_time"` // Unix timestamp of latest modification time of all log files
|
|
|
DocCount uint64 `json:"doc_count"` // Document count when stats were calculated
|
|
|
}
|
|
|
|
|
@@ -46,51 +45,51 @@ type IndexTask struct {
|
|
|
|
|
|
// IndexedLogEntry represents a log entry stored in the index
|
|
|
type IndexedLogEntry struct {
|
|
|
- ID string `json:"id"`
|
|
|
- FilePath string `json:"file_path"`
|
|
|
- Timestamp time.Time `json:"timestamp"`
|
|
|
- IP string `json:"ip"`
|
|
|
- RegionCode string `json:"region_code"`
|
|
|
- Province string `json:"province"`
|
|
|
- City string `json:"city"`
|
|
|
- ISP string `json:"isp"`
|
|
|
- Method string `json:"method"`
|
|
|
- Path string `json:"path"`
|
|
|
- Protocol string `json:"protocol"`
|
|
|
- Status int `json:"status"`
|
|
|
- BytesSent int64 `json:"bytes_sent"`
|
|
|
- Referer string `json:"referer"`
|
|
|
- UserAgent string `json:"user_agent"`
|
|
|
- Browser string `json:"browser"`
|
|
|
- BrowserVer string `json:"browser_version"`
|
|
|
- OS string `json:"os"`
|
|
|
- OSVersion string `json:"os_version"`
|
|
|
- DeviceType string `json:"device_type"`
|
|
|
- RequestTime float64 `json:"request_time"`
|
|
|
- UpstreamTime *float64 `json:"upstream_time,omitempty"`
|
|
|
- Raw string `json:"raw"`
|
|
|
+ ID string `json:"id"`
|
|
|
+ FilePath string `json:"file_path"`
|
|
|
+ Timestamp int64 `json:"timestamp"` // Unix timestamp
|
|
|
+ IP string `json:"ip"`
|
|
|
+ RegionCode string `json:"region_code"`
|
|
|
+ Province string `json:"province"`
|
|
|
+ City string `json:"city"`
|
|
|
+ ISP string `json:"isp"`
|
|
|
+ Method string `json:"method"`
|
|
|
+ Path string `json:"path"`
|
|
|
+ Protocol string `json:"protocol"`
|
|
|
+ Status int `json:"status"`
|
|
|
+ BytesSent int64 `json:"bytes_sent"`
|
|
|
+ Referer string `json:"referer"`
|
|
|
+ UserAgent string `json:"user_agent"`
|
|
|
+ Browser string `json:"browser"`
|
|
|
+ BrowserVer string `json:"browser_version"`
|
|
|
+ OS string `json:"os"`
|
|
|
+ OSVersion string `json:"os_version"`
|
|
|
+ DeviceType string `json:"device_type"`
|
|
|
+ RequestTime float64 `json:"request_time"`
|
|
|
+ UpstreamTime *float64 `json:"upstream_time,omitempty"`
|
|
|
+ Raw string `json:"raw"`
|
|
|
}
|
|
|
|
|
|
// QueryRequest represents a search query for logs
|
|
|
type QueryRequest struct {
|
|
|
- StartTime time.Time `json:"start_time"`
|
|
|
- EndTime time.Time `json:"end_time"`
|
|
|
- Query string `json:"query,omitempty"`
|
|
|
- IP string `json:"ip,omitempty"`
|
|
|
- Method string `json:"method,omitempty"`
|
|
|
- Status []int `json:"status,omitempty"`
|
|
|
- Path string `json:"path,omitempty"`
|
|
|
- UserAgent string `json:"user_agent,omitempty"`
|
|
|
- Referer string `json:"referer,omitempty"`
|
|
|
- Browser string `json:"browser,omitempty"`
|
|
|
- OS string `json:"os,omitempty"`
|
|
|
- Device string `json:"device,omitempty"`
|
|
|
- Limit int `json:"limit"`
|
|
|
- Offset int `json:"offset"`
|
|
|
- SortBy string `json:"sort_by"`
|
|
|
- SortOrder string `json:"sort_order"`
|
|
|
- LogPath string `json:"log_path,omitempty"`
|
|
|
- IncludeSummary bool `json:"include_summary,omitempty"`
|
|
|
+ StartTime int64 `json:"start_time"` // Unix timestamp
|
|
|
+ EndTime int64 `json:"end_time"` // Unix timestamp
|
|
|
+ Query string `json:"query,omitempty"`
|
|
|
+ IP string `json:"ip,omitempty"`
|
|
|
+ Method string `json:"method,omitempty"`
|
|
|
+ Status []int `json:"status,omitempty"`
|
|
|
+ Path string `json:"path,omitempty"`
|
|
|
+ UserAgent string `json:"user_agent,omitempty"`
|
|
|
+ Referer string `json:"referer,omitempty"`
|
|
|
+ Browser string `json:"browser,omitempty"`
|
|
|
+ OS string `json:"os,omitempty"`
|
|
|
+ Device string `json:"device,omitempty"`
|
|
|
+ Limit int `json:"limit"`
|
|
|
+ Offset int `json:"offset"`
|
|
|
+ SortBy string `json:"sort_by"`
|
|
|
+ SortOrder string `json:"sort_order"`
|
|
|
+ LogPath string `json:"log_path,omitempty"`
|
|
|
+ IncludeSummary bool `json:"include_summary,omitempty"`
|
|
|
}
|
|
|
|
|
|
// SummaryStats represents the summary statistics for log entries
|
|
@@ -106,7 +105,7 @@ type SummaryStats struct {
|
|
|
type QueryResult struct {
|
|
|
Entries []*AccessLogEntry `json:"entries"`
|
|
|
Total int `json:"total"`
|
|
|
- Took time.Duration `json:"took"`
|
|
|
+ Took int64 `json:"took"` // Duration in milliseconds
|
|
|
Aggregations map[string]int `json:"aggregations,omitempty"`
|
|
|
Summary *SummaryStats `json:"summary,omitempty"`
|
|
|
FromCache bool `json:"from_cache,omitempty"`
|