Documentation ¶
Index ¶
- Variables
- type Request
- type Statistics
- func (s *Statistics) AppendRequest(ctx context.Context, r Request)
- func (s *Statistics) GetAgents(ctx context.Context) []string
- func (s *Statistics) GetIPAddresses(ctx context.Context) []string
- func (s *Statistics) GetRequests(ctx context.Context) []Request
- func (s *Statistics) GetRequestsByIPAddress(ctx context.Context, ipAddress string) []Request
- func (s *Statistics) GetRequestsByTimeRange(ctx context.Context, start, end time.Time) []Request
- func (s *Statistics) GetRequestsByUserAgent(ctx context.Context, userAgent string) []Request
- func (s *Statistics) GetRequestsGroupedByIPAddress(ctx context.Context) map[string][]Request
- func (s *Statistics) GetRequestsGroupedByUserAgent(ctx context.Context) map[string][]Request
- func (s *Statistics) GetTotalDataSizeServed(ctx context.Context) int
- func (s *Statistics) GetTotalDataSizeServedByAgent(ctx context.Context, agent string) int
- func (s *Statistics) GetTotalDataSizeServedByIPAddress(ctx context.Context, ipAddress string) int
- func (s *Statistics) GetTotalDataSizeServedByTimeRange(ctx context.Context, start, end time.Time) int
- func (s *Statistics) GetTotalRequests(ctx context.Context) int
- func (s *Statistics) GetTotalRequestsByAgent(ctx context.Context, agent string) int
- func (s *Statistics) GetTotalRequestsByIPAddress(ctx context.Context, ipAddress string) int
- func (s *Statistics) GetTotalRobotsTxtViolators(ctx context.Context) int
- func (s *Statistics) UpdatePrompts(ctx context.Context, prompts map[string]int)
Constants ¶
This section is empty.
Variables ¶
var ( // RequestsTotal is the total number of requests. RequestTotal = promauto.NewCounter(prometheus.CounterOpts{ Name: "konterfai_requests_total", Help: "The total number of requests processed.", }) // PromptsGeneratedTotal is the total number of prompts generated. PromptsGeneratedTotal = promauto.NewCounter(prometheus.CounterOpts{ Name: "konterfai_prompts_generated_total", Help: "The total number of prompts generated.", }) // DataFedTotal is the total amount of data fed. DataFedTotal = promauto.NewCounter(prometheus.CounterOpts{ Name: "konterfai_data_fed_bytes_total", Help: "The total amount of data fed in bytes.", }) // RobotsTxtViolatorsTotal is the total number of violators of robots.txt. RobotsTxtViolatorsTotal = promauto.NewGauge(prometheus.GaugeOpts{ Name: "konterfai_robots_txt_violators", Help: "The total number of violators of robots.txt.", }) // AgentTraffic is the traffic per user agent. AgentTraffic = promauto.NewGaugeVec(prometheus.GaugeOpts{ Name: "konterfai_agent_traffic_bytes", Help: "The traffic per user agent in bytes.", }, []string{"user_agent"}) // AgentRequests is the requests per user agent. AgentRequests = promauto.NewGaugeVec(prometheus.GaugeOpts{ Name: "konterfai_agent_requests", Help: "The requests per user agent.", }, []string{"user_agent"}) // IPTraffic is the traffic per IP address. IPTraffic = promauto.NewGaugeVec(prometheus.GaugeOpts{ Name: "konterfai_ip_traffic_bytes", Help: "The traffic per IP address in bytes.", }, []string{"ip_address"}) // IPRequests is the requests per IP address. IPRequests = promauto.NewGaugeVec(prometheus.GaugeOpts{ Name: "konterfai_ip_requests", Help: "The requests per IP address.", }, []string{"ip_address"}) )
Functions ¶
This section is empty.
Types ¶
type Request ¶
type Request struct { UserAgent string `yaml:"userAgent"` IPAddress string `yaml:"ipAddress"` Timestamp time.Time `yaml:"timestamp"` IsRobotsTxt bool `yaml:"isRobotsTxt"` Size int `yaml:"size"` }
Request is the structure for the Request.
type Statistics ¶
type Statistics struct { Requests []Request StatisticsLock sync.Mutex ConfigurationInfo string Prompts map[string]int PromptsLock sync.Mutex PromptsCount int Logger *slog.Logger }
Statistics is the structure for the Statistics.
func NewStatistics ¶
NewStatistics creates a new Statistics instance.
func (*Statistics) AppendRequest ¶
func (s *Statistics) AppendRequest(ctx context.Context, r Request)
AppendRequest appends a request to the statistics.
func (*Statistics) GetAgents ¶ added in v0.3.1
func (s *Statistics) GetAgents(ctx context.Context) []string
GetAgents returns the agents.
func (*Statistics) GetIPAddresses ¶ added in v0.3.2
func (s *Statistics) GetIPAddresses(ctx context.Context) []string
GetIPAddresses returns the IP addresses.
func (*Statistics) GetRequests ¶
func (s *Statistics) GetRequests(ctx context.Context) []Request
GetRequests returns the requests.
func (*Statistics) GetRequestsByIPAddress ¶ added in v0.3.2
func (s *Statistics) GetRequestsByIPAddress(ctx context.Context, ipAddress string) []Request
GetRequestsByIPAddress returns the requests by IP address.
func (*Statistics) GetRequestsByTimeRange ¶
GetRequestsByTimeRange returns the requests by time range.
func (*Statistics) GetRequestsByUserAgent ¶
func (s *Statistics) GetRequestsByUserAgent(ctx context.Context, userAgent string) []Request
GetRequestsByUserAgent returns the requests by user agent.
func (*Statistics) GetRequestsGroupedByIPAddress ¶ added in v0.3.2
func (s *Statistics) GetRequestsGroupedByIPAddress(ctx context.Context) map[string][]Request
GetRequestsGroupedByIPAddress returns the requests grouped by IP address.
func (*Statistics) GetRequestsGroupedByUserAgent ¶
func (s *Statistics) GetRequestsGroupedByUserAgent(ctx context.Context) map[string][]Request
GetRequestsGroupedByUserAgent returns the requests grouped by user agent.
func (*Statistics) GetTotalDataSizeServed ¶ added in v0.3.0
func (s *Statistics) GetTotalDataSizeServed(ctx context.Context) int
GetTotalDataSizeServed returns the data size served.
func (*Statistics) GetTotalDataSizeServedByAgent ¶ added in v0.3.1
func (s *Statistics) GetTotalDataSizeServedByAgent(ctx context.Context, agent string) int
GetTotalDataSizeServedByAgent returns the data size served by agent.
func (*Statistics) GetTotalDataSizeServedByIPAddress ¶ added in v0.3.2
func (s *Statistics) GetTotalDataSizeServedByIPAddress(ctx context.Context, ipAddress string) int
GetTotalDataSizeServedByIPAddress returns the data size served by IP address.
func (*Statistics) GetTotalDataSizeServedByTimeRange ¶ added in v0.3.0
func (s *Statistics) GetTotalDataSizeServedByTimeRange(ctx context.Context, start, end time.Time) int
GetTotalDataSizeServedByTimeRange returns the data size served by time range.
func (*Statistics) GetTotalRequests ¶ added in v0.3.0
func (s *Statistics) GetTotalRequests(ctx context.Context) int
GetTotalRequests returns the total requests.
func (*Statistics) GetTotalRequestsByAgent ¶ added in v0.3.1
func (s *Statistics) GetTotalRequestsByAgent(ctx context.Context, agent string) int
GetTotalRequestsByAgent returns the total requests by agent.
func (*Statistics) GetTotalRequestsByIPAddress ¶ added in v0.3.2
func (s *Statistics) GetTotalRequestsByIPAddress(ctx context.Context, ipAddress string) int
GetTotalRequestsByIPAddress returns the total requests by IP address.
func (*Statistics) GetTotalRobotsTxtViolators ¶ added in v0.3.0
func (s *Statistics) GetTotalRobotsTxtViolators(ctx context.Context) int
GetTotalRobotsTxtViolators returns the total robots.txt violators.
func (*Statistics) UpdatePrompts ¶
func (s *Statistics) UpdatePrompts(ctx context.Context, prompts map[string]int)
UpdatePrompts updates the prompts.