Traffic Stats is a utility written in Go that is used to acquire and store statistics about CDNs controlled by Traffic Control. Traffic Stats mines metrics from Traffic Monitor’s JSON APIs and stores the data in InfluxDb. Data is typically stored in InfluxDb on a short-term basis (30 days or less) and is used to drive graphs created by Grafana which are linked from Traffic Ops. Traffic Stats also calculates daily statistics from InfluxDb and stores them in the Traffic Ops database.
To work on Traffic Stats you need a *nix (MacOS and Linux are most commonly used) environment that has the following installed:
Traffic Stats Project Tree Overview¶
- traffic_control/traffic_stats - contains Go source files and Files used to create the Traffic Stats rpm.
- traffic_control/traffic_stats/influxdb_tools/ - contains one tool to create the databases and retention policies needed by Traffic Stats as well as continuous queries to downsample data; contains another tool to sync downsampled data between influxdb instances. This is is helpful if you have multiple instances and they get out of sync with data.
Go Formatting Conventions¶
Installing The Developer Environment¶
To install the Traffic Ops Developer environment:
- Clone the traffic_control repository using Git into a location accessible by your $GOPATH
- Navigate to the traffic_ops/client directory of your cloned repository. (This is the directory containing Traffic Ops client code used by Traffic Stats)
- From the traffic_ops/client directory run
go testto test the client code. This will run all unit tests for the client and return the results. If there are missing dependencies you will need to run
go get <dependency name>to get the dependency
- Once the tests pass, run
go installto build and install the Traffic Ops client package. This makes it accessible to Traffic Stats.
- Navigate to your cloned repo under Traffic Stats
go build traffic_stats.goto build traffic_stats. You will need to run
go getfor any missing dependencies.
Currently there are no automated tests for Traffic Stats :( but pull requests are always welcome to fix this problem!