analytics

package
v0.8.5 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2020 License: MPL-2.0 Imports: 10 Imported by: 0

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 AnalyticsRecord

type AnalyticsRecord struct {
	Method        string
	Host          string
	Path          string
	RawPath       string
	ContentLength int64
	UserAgent     string
	Day           int
	Month         time.Month
	Year          int
	Hour          int
	ResponseCode  int
	APIKey        string
	TimeStamp     time.Time
	APIVersion    string
	APIName       string
	APIID         string
	OrgID         string
	OauthID       string
	RequestTime   int64
	RawRequest    string
	RawResponse   string
	IPAddress     string
	Geo           GeoData
	Network       NetworkStats
	Latency       Latency
	Tags          []string
	Alias         string
	TrackPath     bool
	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

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() bson.M

func (*AnalyticsRecordAggregate) AsTimeUpdate

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

func (AnalyticsRecordAggregate) New

func (*AnalyticsRecordAggregate) SetErrorList added in v0.8.5

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"`
	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"`
	ErrorList []ErrorData    `json:"error_list"`
}

type ErrorData added in v0.8.5

type ErrorData struct {
	Code  string
	Count int
}

type GeoData

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

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

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

type Latency

type Latency struct {
	Total    int64
	Upstream int64
}

type NetworkStats

type NetworkStats struct {
	OpenConnections  int64
	ClosedConnection int64
	BytesIn          int64
	BytesOut         int64
}

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