analytics

package
v1.3.0-rc2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 10, 2021 License: MPL-2.0 Imports: 11 Imported by: 4

Documentation

Index

Constants

View Source
const (
	AgggregateMixedCollectionName = "tyk_analytics_aggregates"
	MongoAggregatePrefix          = "mongo-pump-aggregate"
)

Variables

This section is empty.

Functions

func AggregateData

func AggregateData(data []interface{}, trackAllPaths bool, ignoreTagPrefixList []string, storeAnalyticPerMinute bool) map[string]AnalyticsRecordAggregate

AggregateData calculates aggregated data, returns map orgID => aggregated analytics data

Types

type AnalyticsFilters added in v1.0.0

type AnalyticsFilters struct {
	OrgsIDs              []string `json:"org_ids"`
	APIIDs               []string `json:"api_ids"`
	ResponseCodes        []int    `json:"response_codes"`
	SkippedOrgsIDs       []string `json:"skip_org_ids"`
	SkippedAPIIDs        []string `json:"skip_api_ids"`
	SkippedResponseCodes []int    `json:"skip_response_codes"`
}

func (AnalyticsFilters) HasFilter added in v1.0.0

func (filters AnalyticsFilters) HasFilter() bool

func (AnalyticsFilters) ShouldFilter added in v1.0.0

func (filters AnalyticsFilters) ShouldFilter(record AnalyticsRecord) bool

type AnalyticsRecord

type AnalyticsRecord struct {
	Method        string       `json:"method"`
	Host          string       `json:"host"`
	Path          string       `json:"path"`
	RawPath       string       `json:"raw_path" gorm:"column:rawpath"`
	ContentLength int64        `json:"content_length" gorm:"column:contentlength"`
	UserAgent     string       `json:"user_agent" gorm:"column:useragent"`
	Day           int          `json:"day" gorm:"-"`
	Month         time.Month   `json:"month" gorm:"-"`
	Year          int          `json:"year" gorm:"-"`
	Hour          int          `json:"hour" gorm:"-"`
	ResponseCode  int          `json:"response_code" gorm:"column:responsecode;index"`
	APIKey        string       `json:"api_key" gorm:"column:apikey;index"`
	TimeStamp     time.Time    `json:"timestamp" gorm:"column:timestamp;index"`
	APIVersion    string       `json:"api_version" gorm:"column:apiversion"`
	APIName       string       `json:"api_name" gorm:"-"`
	APIID         string       `json:"api_id" gorm:"column:apiid;index"`
	OrgID         string       `json:"org_id" gorm:"column:orgid;index"`
	OauthID       string       `json:"oauth_id" gorm:"column:oauthid;index"`
	RequestTime   int64        `json:"request_time" gorm:"column:requesttime"`
	RawRequest    string       `json:"raw_request" gorm:"column:rawrequest"`
	RawResponse   string       `json:"raw_response" gorm:"column:rawresponse"`
	IPAddress     string       `json:"ip_address" gorm:"column:ipaddress"`
	Geo           GeoData      `json:"geo" gorm:"embedded"`
	Network       NetworkStats `json:"network"`
	Latency       Latency      `json:"latency"`
	Tags          []string     `json:"tags"`
	Alias         string       `json:"alias"`
	TrackPath     bool         `json:"track_path" gorm:"column:trackpath"`
	ExpireAt      time.Time    `bson:"expireAt" json:"expireAt"`
}

AnalyticsRecord encodes the details of a request

func (*AnalyticsRecord) GetFieldNames

func (a *AnalyticsRecord) GetFieldNames() []string

func (*AnalyticsRecord) GetLineValues

func (a *AnalyticsRecord) GetLineValues() []string

func (*AnalyticsRecord) TableName added in v1.5.0

func (ar *AnalyticsRecord) TableName() string

type AnalyticsRecordAggregate

type AnalyticsRecordAggregate struct {
	TimeStamp time.Time
	OrgID     string
	TimeID    struct {
		Year  int
		Month int
		Day   int
		Hour  int
	}

	APIKeys map[string]*Counter
	Errors  map[string]*Counter

	Versions map[string]*Counter
	APIID    map[string]*Counter
	OauthIDs map[string]*Counter
	Geo      map[string]*Counter
	Tags     map[string]*Counter

	Endpoints map[string]*Counter

	Lists struct {
		APIKeys       []Counter
		APIID         []Counter
		OauthIDs      []Counter
		Geo           []Counter
		Tags          []Counter
		Errors        []Counter
		Endpoints     []Counter
		KeyEndpoint   map[string][]Counter `bson:"keyendpoints"`
		OauthEndpoint map[string][]Counter `bson:"oauthendpoints"`
		APIEndpoint   []Counter            `bson:"apiendpoints"`
	}

	KeyEndpoint   map[string]map[string]*Counter `bson:"keyendpoints"`
	OauthEndpoint map[string]map[string]*Counter `bson:"oauthendpoints"`
	ApiEndpoint   map[string]*Counter            `bson:"apiendpoints"`

	Total Counter

	ExpireAt time.Time `bson:"expireAt" json:"expireAt"`
	LastTime time.Time
}

func (*AnalyticsRecordAggregate) AsChange

func (f *AnalyticsRecordAggregate) AsChange() (newUpdate bson.M)

func (*AnalyticsRecordAggregate) AsTimeUpdate

func (f *AnalyticsRecordAggregate) AsTimeUpdate() bson.M

func (*AnalyticsRecordAggregate) Dimensions added in v1.5.0

func (f *AnalyticsRecordAggregate) Dimensions() (dimensions []Dimension)

func (*AnalyticsRecordAggregate) DiscardAggregations added in v1.2.0

func (f *AnalyticsRecordAggregate) DiscardAggregations(fields []string)

DiscardAggregations this method discard the aggregations of X field specified in the aggregated pump configuration

func (AnalyticsRecordAggregate) New

func (*AnalyticsRecordAggregate) SetErrorList added in v1.0.0

func (f *AnalyticsRecordAggregate) SetErrorList(parent, thisUnit string, counter *Counter, newUpdate bson.M)

type Counter

type Counter struct {
	Hits              int       `json:"hits"`
	Success           int       `json:"success"`
	ErrorTotal        int       `json:"error"`
	RequestTime       float64   `json:"request_time"`
	TotalRequestTime  float64   `json:"total_request_time"`
	Identifier        string    `json:"identifier" gorm:"-"`
	HumanIdentifier   string    `json:"human_identifier"`
	LastTime          time.Time `json:"last_time"`
	OpenConnections   int64     `json:"open_connections"`
	ClosedConnections int64     `json:"closed_connections"`
	BytesIn           int64     `json:"bytes_in"`
	BytesOut          int64     `json:"bytes_out"`

	MaxUpstreamLatency   int64   `json:"max_upstream_latency"`
	MinUpstreamLatency   int64   `json:"min_upstream_latency"`
	TotalUpstreamLatency int64   `json:"total_upstream_latency"`
	UpstreamLatency      float64 `json:"upstream_latency"`

	MaxLatency   int64   `json:"max_latency"`
	MinLatency   int64   `json:"min_latency"`
	TotalLatency int64   `json:"total_latency"`
	Latency      float64 `json:"latency"`

	ErrorMap  map[string]int `json:"error_map" gorm:"-"`
	ErrorList []ErrorData    `json:"error_list" gorm:"-"`
}

type Dimension added in v1.5.0

type Dimension struct {
	Name    string
	Value   string
	Counter *Counter
}

type ErrorData added in v1.0.0

type ErrorData struct {
	Code  string
	Count int
}

type GeoData

type GeoData struct {
	Country struct {
		ISOCode string `maxminddb:"iso_code" json:"iso_code"`
	} `maxminddb:"country" json:"country"`

	City struct {
		GeoNameID uint              `maxminddb:"geoname_id" json:"geoname_id"`
		Names     map[string]string `maxminddb:"names" json:"names"`
	} `maxminddb:"city" json:"city"`

	Location struct {
		Latitude  float64 `maxminddb:"latitude" json:"latitude"`
		Longitude float64 `maxminddb:"longitude" json:"longitude"`
		TimeZone  string  `maxminddb:"time_zone" json:"time_zone"`
	} `maxminddb:"location" json:"location"`
}

type Latency

type Latency struct {
	Total    int64 `json:"total"`
	Upstream int64 `json:"upstream"`
}

type NetworkStats

type NetworkStats struct {
	OpenConnections  int64 `json:"open_conn"`
	ClosedConnection int64 `json:"close_conn"`
	BytesIn          int64 `json:"bytes_in"`
	BytesOut         int64 `json:"bytes_out"`
}

type SQLAnalyticsRecordAggregate added in v1.5.0

type SQLAnalyticsRecordAggregate struct {
	Counter `json:"counter"`

	TimeStamp      int64  `json:"timestamp" gorm:"index:dimension, priority:1"`
	OrgID          string `json:"org_id" gorm:"index:dimension, priority:2"`
	Dimension      string `json:"dimension" gorm:"index:dimension, priority:3"`
	DimensionValue string `json:"dimension_value" gorm:"index:dimension, priority:4"`

	Code1x  int `json:"code_1x"`
	Code200 int `json:"code_200"`
	Code201 int `json:"code_201"`
	Code2x  int `json:"code_2x"`
	Code301 int `json:"code_301"`
	Code302 int `json:"code_302"`
	Code303 int `json:"code_303"`
	Code304 int `json:"code_304"`
	Code3x  int `json:"code_3x"`
	Code400 int `json:"code_400"`
	Code401 int `json:"code_401"`
	Code403 int `json:"code_403"`
	Code404 int `json:"code_404"`
	Code429 int `json:"code_429"`
	Code4x  int `json:"code_4x"`
	Code500 int `json:"code_500"`
	Code501 int `json:"code_501"`
	Code502 int `json:"code_502"`
	Code503 int `json:"code_503"`
	Code504 int `json:"code_504"`
	Code5x  int `json:"code_5x"`
}

func (*SQLAnalyticsRecordAggregate) ProcessStatusCodes

func (a *SQLAnalyticsRecordAggregate) ProcessStatusCodes()

func (*SQLAnalyticsRecordAggregate) TableName added in v1.5.0

func (ar *SQLAnalyticsRecordAggregate) TableName() string

type UptimeReportData

type UptimeReportData struct {
	URL          string
	RequestTime  int64
	ResponseCode int
	TCPError     bool
	ServerError  bool
	Day          int
	Month        time.Month
	Year         int
	Hour         int
	Minute       int
	TimeStamp    time.Time
	ExpireAt     time.Time `bson:"expireAt" json:"expireAt"`
	APIID        string
	OrgID        string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL