Skip to content
This repository was archived by the owner on Nov 24, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
- [#7021](https://github.com/apache/trafficcontrol/issues/7021) *Cache Config* Fixed cache config for Delivery Services with IP Origins.
- [#7043](https://github.com/apache/trafficcontrol/issues/7043) Fixed cache config missing retry parameters for non-topology MSO Delivery Services going direct from edge to origin.
- [#7047](https://github.com/apache/trafficcontrol/issues/7047) *Traffic Ops* allow `apply_time` query parameters on the `servers/{id-name}/update` when the CDN is locked.
- [#7048](https://github.com/apache/trafficcontrol/issues/7048) *Traffic Stats* Add configuration value to set the client request timeout for calls to Traffic Ops.
- Updated Apache Tomcat from 9.0.43 to 9.0.67

## [7.0.0] - 2022-07-19
Expand Down
1 change: 1 addition & 0 deletions docs/source/admin/traffic_stats.rst
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ Traffic Stats's configuration file can be found in :file:`/opt/traffic_stats/con
:toUser: The username of the user as whom to connect to Traffic Ops
:toPasswd: The password to use when authenticating with Traffic Ops
:toUrl: The URL of the Traffic Ops server used by Traffic Stats
:toRequestTimeout: The time, in seconds, before a client request to Traffic Ops is canceled. Defaults to 10 if no value provided
:influxUser: Optionally specify the user to use when connecting to InfluxDB (if InfluxDB is not configured to require authentication, has no effect)
:influxPassword: Optionally specify the password to use when connecting to InfluxDB (if InfluxDB is not configured to require authentication, has no effect)
:pollingInterval: The interval in seconds for which Traffic Monitor will wait between polling for stats and storing them in InfluxDB
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ ts_install_logdir: "{{ ts_install_basedir }}/var/log/traffic_stats"
ts_toUser:
ts_toPasswd:
ts_toUrl: https://kabletown.invalid
ts_toRequestTimeout: 10

# InfluxDB credentials
ts_influxUser: influxUser
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"toUser": "{{ ts_toUser }}",
"toPasswd": "{{ ts_toPasswd }}",
"toUrl": "{{ ts_toUrl }}",
"toRequestTimeout": "{{ ts_toRequestTimeout }}",
Comment thread
tcfdev marked this conversation as resolved.
Outdated
"influxUser": "{{ ts_influxUser }}",
"influxPassword": "{{ ts_influxPassword }}",
"pollingInterval": {{ ts_pollingInterval }},
Expand Down
1 change: 1 addition & 0 deletions infrastructure/cdn-in-a-box/traffic_stats/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ cat <<-EOF >$TSCONF
"toUser": "$TO_ADMIN_USER",
"toPasswd": "$TO_ADMIN_PASSWORD",
"toUrl": "$TO_URL",
"toRequestTimeout": 10,
"influxUser": "$INFLUXDB_ADMIN_USER",
"influxPassword": "$INFLUXDB_ADMIN_PASSWORD",
"pollingInterval": 10,
Expand Down
1 change: 1 addition & 0 deletions traffic_stats/traffic_stats.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"toUser": "admin",
"toPasswd": "",
"toUrl": "https://localhost",
"toRequestTimeout": 10,
"disableInflux": false,
"influxUser": "influxUser",
"influxPassword": "",
Expand Down
11 changes: 8 additions & 3 deletions traffic_stats/traffic_stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ import (
)

const UserAgent = "traffic-stats"
const TrafficOpsRequestTimeout = time.Second * time.Duration(10)

const (
defaultTrafficOpsRequestTimeout = 10
defaultPollingInterval = 10
defaultDailySummaryPollingInterval = 60
defaultConfigInterval = 300
Expand Down Expand Up @@ -95,6 +95,7 @@ type StartupConfig struct {
ToUser string `json:"toUser"`
ToPasswd string `json:"toPasswd"`
ToURL string `json:"toUrl"`
ToRequestTimeoutSeconds int `json:"toRequestTimeout"`
DisableInflux bool `json:"disableInflux"`
InfluxUser string `json:"influxUser"`
InfluxPassword string `json:"influxPassword"`
Expand Down Expand Up @@ -516,6 +517,10 @@ func loadStartupConfig(configFile string, oldConfig StartupConfig) (StartupConfi
config.MaxPublishSize = defaultMaxPublishSize
}

if config.ToRequestTimeoutSeconds <= 0 {
config.ToRequestTimeoutSeconds = defaultTrafficOpsRequestTimeout
}

if config.LogConfig != nil {
if err = log.InitCfg(config.LogConfig); err != nil {
return config, fmt.Errorf("initializing logging configuration: %w", err)
Expand Down Expand Up @@ -721,7 +726,7 @@ func queryDB(con influx.Client, cmd string, database string) (res []influx.Resul
}

func writeSummaryStats(config StartupConfig, statsSummary tc.StatsSummary) {
to, _, err := client.LoginWithAgent(config.ToURL, config.ToUser, config.ToPasswd, true, UserAgent, false, TrafficOpsRequestTimeout)
to, _, err := client.LoginWithAgent(config.ToURL, config.ToUser, config.ToPasswd, true, UserAgent, false, time.Duration(config.ToRequestTimeoutSeconds)*time.Second)
if err != nil {
newErr := fmt.Errorf("Could not store summary stats! Error logging in to %v: %v", config.ToURL, err)
errorln(newErr)
Expand All @@ -735,7 +740,7 @@ func writeSummaryStats(config StartupConfig, statsSummary tc.StatsSummary) {

func getToData(config StartupConfig, init bool, configChan chan RunningConfig) {
var runningConfig RunningConfig
to, _, err := client.LoginWithAgent(config.ToURL, config.ToUser, config.ToPasswd, true, UserAgent, false, TrafficOpsRequestTimeout)
to, _, err := client.LoginWithAgent(config.ToURL, config.ToUser, config.ToPasswd, true, UserAgent, false, time.Duration(config.ToRequestTimeoutSeconds)*time.Second)
if err != nil {
msg := fmt.Sprintf("Error logging in to %v: %v", config.ToURL, err)
if init {
Expand Down