cloudflare-log-collector

cloudflare

import "github.com/afreidah/cloudflare-log-collector/internal/cloudflare"

Index

type Client

Client talks to the Cloudflare GraphQL Analytics API.

type Client struct {
    // contains filtered or unexported fields
}

func NewClient

func NewClient(apiToken string) *Client

NewClient creates a Cloudflare GraphQL client.

func NewTestClient

func NewTestClient(endpoint, apiToken string) *Client

NewTestClient creates a client pointing at a custom endpoint for testing.

func (*Client) QueryFirewallEvents

func (c *Client) QueryFirewallEvents(ctx context.Context, zoneID string, since, until time.Time) ([]FirewallEvent, error)

QueryFirewallEvents fetches firewall events for the given zone and time range.

func (*Client) QueryHTTPRequests

func (c *Client) QueryHTTPRequests(ctx context.Context, zoneID string, since, until time.Time) ([]HTTPRequestGroup, error)

QueryHTTPRequests fetches aggregated HTTP traffic stats for the given zone and time range.

type FirewallEvent

FirewallEvent represents a single firewall/WAF event from Cloudflare.

type FirewallEvent struct {
    Action                      string `json:"action"`
    ClientIP                    string `json:"clientIP"`
    ClientRequestHTTPHost       string `json:"clientRequestHTTPHost"`
    ClientRequestHTTPMethodName string `json:"clientRequestHTTPMethodName"`
    ClientRequestPath           string `json:"clientRequestPath"`
    ClientRequestQuery          string `json:"clientRequestQuery"`
    Datetime                    string `json:"datetime"`
    RayName                     string `json:"rayName"`
    RuleID                      string `json:"ruleId"`
    Source                      string `json:"source"`
    UserAgent                   string `json:"userAgent"`
    ClientCountryName           string `json:"clientCountryName"`
}

type HTTPRequestDimensions

HTTPRequestDimensions holds the grouping dimensions for HTTP traffic.

type HTTPRequestDimensions struct {
    Datetime                    string `json:"datetime"`
    ClientRequestHTTPMethodName string `json:"clientRequestHTTPMethodName"`
    EdgeResponseStatus          int    `json:"edgeResponseStatus"`
    ClientCountryName           string `json:"clientCountryName"`
}

type HTTPRequestGroup

HTTPRequestGroup represents an aggregated HTTP traffic data point.

type HTTPRequestGroup struct {
    Count      int                   `json:"count"`
    Dimensions HTTPRequestDimensions `json:"dimensions"`
    Sum        HTTPRequestSum        `json:"sum"`
}

type HTTPRequestSum

HTTPRequestSum holds the aggregated byte counts for HTTP traffic.

type HTTPRequestSum struct {
    EdgeResponseBytes int64 `json:"edgeResponseBytes"`
}

Generated by gomarkdoc