Traffic Stats
Introduction
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 the Traffic Monitor 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.
Software Requirements
A *nix (MacOS and Linux are most commonly used) environment
Access to a working instance of Traffic Ops
Access to a working instance of Traffic Monitor
Traffic Stats Project Tree Overview
traffic_stats/
- contains Go source files and files used to create the Traffic Stats RPM.grafana/
- contains a javascript file which is installed on the Grafana server. This allows Traffic Ops to create custom dashboards for Delivery Services, :term:cache server`s, etc.influxdb_tools/
- contains sync/sync_ts_databases.go and create/create_ts_databases.go which are helpful if you have multiple instances and they get out of sync with data.
Go Formatting Conventions
In general Go fmt is the standard for formatting Go code. It is also recommended to use Go lint.
Installing The Developer Environment
Clone the traffic_control repository using Git into a location accessible by your $GOPATH
Navigate to the
traffic_ops/v4-client
directory of your cloned repository. (This is the directory containing Traffic Ops client code used by Traffic Stats)From the
traffic_ops/v4-client
directory, rungo test
to 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 rungo mod vendor -v
to get the dependenciesOnce the tests pass, run
go install
to build and install the Traffic Ops client package. This makes it accessible to Traffic Stats.Navigate to your cloned repository under Traffic Stats
Run
go build traffic_stats.go
to build traffic_stats. You will need to rungo mod vendor -v
for any missing dependencies.