2018-11-14 09:18:03 +00:00
package types
import (
2021-03-23 16:48:04 +00:00
"net"
"os"
2019-06-17 09:48:05 +00:00
"time"
2020-08-17 16:04:03 +00:00
"github.com/traefik/paerser/types"
2018-11-14 09:18:03 +00:00
)
2019-07-18 19:36:05 +00:00
// Metrics provides options to expose and send Traefik metrics to different third party monitoring systems.
2018-11-14 09:18:03 +00:00
type Metrics struct {
2020-10-30 11:44:05 +00:00
Prometheus * Prometheus ` description:"Prometheus metrics exporter type." json:"prometheus,omitempty" toml:"prometheus,omitempty" yaml:"prometheus,omitempty" label:"allowEmpty" file:"allowEmpty" export:"true" `
Datadog * Datadog ` description:"Datadog metrics exporter type." json:"datadog,omitempty" toml:"datadog,omitempty" yaml:"datadog,omitempty" label:"allowEmpty" file:"allowEmpty" export:"true" `
StatsD * Statsd ` description:"StatsD metrics exporter type." json:"statsD,omitempty" toml:"statsD,omitempty" yaml:"statsD,omitempty" label:"allowEmpty" file:"allowEmpty" export:"true" `
InfluxDB * InfluxDB ` description:"InfluxDB metrics exporter type." json:"influxDB,omitempty" toml:"influxDB,omitempty" yaml:"influxDB,omitempty" label:"allowEmpty" file:"allowEmpty" export:"true" `
2022-02-09 14:32:12 +00:00
InfluxDB2 * InfluxDB2 ` description:"InfluxDB v2 metrics exporter type." json:"influxDB2,omitempty" toml:"influxDB2,omitempty" yaml:"influxDB2,omitempty" label:"allowEmpty" file:"allowEmpty" export:"true" `
2018-11-14 09:18:03 +00:00
}
2019-07-18 19:36:05 +00:00
// Prometheus can contain specific configuration used by the Prometheus Metrics exporter.
2018-11-14 09:18:03 +00:00
type Prometheus struct {
2019-07-18 19:36:05 +00:00
Buckets [ ] float64 ` description:"Buckets for latency metrics." json:"buckets,omitempty" toml:"buckets,omitempty" yaml:"buckets,omitempty" export:"true" `
AddEntryPointsLabels bool ` description:"Enable metrics on entry points." json:"addEntryPointsLabels,omitempty" toml:"addEntryPointsLabels,omitempty" yaml:"addEntryPointsLabels,omitempty" export:"true" `
2021-04-30 08:22:04 +00:00
AddRoutersLabels bool ` description:"Enable metrics on routers." json:"addRoutersLabels,omitempty" toml:"addRoutersLabels,omitempty" yaml:"addRoutersLabels,omitempty" export:"true" `
2019-07-18 19:36:05 +00:00
AddServicesLabels bool ` description:"Enable metrics on services." json:"addServicesLabels,omitempty" toml:"addServicesLabels,omitempty" yaml:"addServicesLabels,omitempty" export:"true" `
2022-01-24 10:08:05 +00:00
EntryPoint string ` description:"EntryPoint" json:"entryPoint,omitempty" toml:"entryPoint,omitempty" yaml:"entryPoint,omitempty" export:"true" `
2020-10-30 11:44:05 +00:00
ManualRouting bool ` description:"Manual routing" json:"manualRouting,omitempty" toml:"manualRouting,omitempty" yaml:"manualRouting,omitempty" export:"true" `
2019-06-17 09:48:05 +00:00
}
// SetDefaults sets the default values.
func ( p * Prometheus ) SetDefaults ( ) {
p . Buckets = [ ] float64 { 0.1 , 0.3 , 1.2 , 5 }
2019-07-18 19:36:05 +00:00
p . AddEntryPointsLabels = true
p . AddServicesLabels = true
2019-09-06 13:08:04 +00:00
p . EntryPoint = "traefik"
2018-11-14 09:18:03 +00:00
}
2019-09-02 10:18:04 +00:00
// Datadog contains address and metrics pushing interval configuration.
type Datadog struct {
2020-08-17 16:04:03 +00:00
Address string ` description:"Datadog's address." json:"address,omitempty" toml:"address,omitempty" yaml:"address,omitempty" `
PushInterval types . Duration ` description:"Datadog push interval." json:"pushInterval,omitempty" toml:"pushInterval,omitempty" yaml:"pushInterval,omitempty" export:"true" `
AddEntryPointsLabels bool ` description:"Enable metrics on entry points." json:"addEntryPointsLabels,omitempty" toml:"addEntryPointsLabels,omitempty" yaml:"addEntryPointsLabels,omitempty" export:"true" `
2021-04-30 08:22:04 +00:00
AddRoutersLabels bool ` description:"Enable metrics on routers." json:"addRoutersLabels,omitempty" toml:"addRoutersLabels,omitempty" yaml:"addRoutersLabels,omitempty" export:"true" `
2020-08-17 16:04:03 +00:00
AddServicesLabels bool ` description:"Enable metrics on services." json:"addServicesLabels,omitempty" toml:"addServicesLabels,omitempty" yaml:"addServicesLabels,omitempty" export:"true" `
2021-10-06 15:34:07 +00:00
Prefix string ` description:"Prefix to use for metrics collection." json:"prefix,omitempty" toml:"prefix,omitempty" yaml:"prefix,omitempty" export:"true" `
2019-06-17 09:48:05 +00:00
}
// SetDefaults sets the default values.
2019-09-02 10:18:04 +00:00
func ( d * Datadog ) SetDefaults ( ) {
2021-03-23 16:48:04 +00:00
host , ok := os . LookupEnv ( "DD_AGENT_HOST" )
if ! ok {
host = "localhost"
}
port , ok := os . LookupEnv ( "DD_DOGSTATSD_PORT" )
if ! ok {
port = "8125"
}
d . Address = net . JoinHostPort ( host , port )
2020-08-17 16:04:03 +00:00
d . PushInterval = types . Duration ( 10 * time . Second )
2019-07-18 19:36:05 +00:00
d . AddEntryPointsLabels = true
d . AddServicesLabels = true
2021-10-06 15:34:07 +00:00
d . Prefix = "traefik"
2018-11-14 09:18:03 +00:00
}
2019-07-18 19:36:05 +00:00
// Statsd contains address and metrics pushing interval configuration.
2018-11-14 09:18:03 +00:00
type Statsd struct {
2020-08-17 16:04:03 +00:00
Address string ` description:"StatsD address." json:"address,omitempty" toml:"address,omitempty" yaml:"address,omitempty" `
PushInterval types . Duration ` description:"StatsD push interval." json:"pushInterval,omitempty" toml:"pushInterval,omitempty" yaml:"pushInterval,omitempty" export:"true" `
AddEntryPointsLabels bool ` description:"Enable metrics on entry points." json:"addEntryPointsLabels,omitempty" toml:"addEntryPointsLabels,omitempty" yaml:"addEntryPointsLabels,omitempty" export:"true" `
2021-04-30 08:22:04 +00:00
AddRoutersLabels bool ` description:"Enable metrics on routers." json:"addRoutersLabels,omitempty" toml:"addRoutersLabels,omitempty" yaml:"addRoutersLabels,omitempty" export:"true" `
2020-08-17 16:04:03 +00:00
AddServicesLabels bool ` description:"Enable metrics on services." json:"addServicesLabels,omitempty" toml:"addServicesLabels,omitempty" yaml:"addServicesLabels,omitempty" export:"true" `
Prefix string ` description:"Prefix to use for metrics collection." json:"prefix,omitempty" toml:"prefix,omitempty" yaml:"prefix,omitempty" export:"true" `
2019-06-17 09:48:05 +00:00
}
// SetDefaults sets the default values.
func ( s * Statsd ) SetDefaults ( ) {
s . Address = "localhost:8125"
2020-08-17 16:04:03 +00:00
s . PushInterval = types . Duration ( 10 * time . Second )
2019-07-18 19:36:05 +00:00
s . AddEntryPointsLabels = true
s . AddServicesLabels = true
2019-11-12 17:18:04 +00:00
s . Prefix = "traefik"
2018-11-14 09:18:03 +00:00
}
2019-07-18 19:36:05 +00:00
// InfluxDB contains address, login and metrics pushing interval configuration.
2018-11-14 09:18:03 +00:00
type InfluxDB struct {
2021-09-17 07:08:07 +00:00
Address string ` description:"InfluxDB address." json:"address,omitempty" toml:"address,omitempty" yaml:"address,omitempty" `
Protocol string ` description:"InfluxDB address protocol (udp or http)." json:"protocol,omitempty" toml:"protocol,omitempty" yaml:"protocol,omitempty" `
PushInterval types . Duration ` description:"InfluxDB push interval." json:"pushInterval,omitempty" toml:"pushInterval,omitempty" yaml:"pushInterval,omitempty" export:"true" `
Database string ` description:"InfluxDB database used when protocol is http." json:"database,omitempty" toml:"database,omitempty" yaml:"database,omitempty" export:"true" `
RetentionPolicy string ` description:"InfluxDB retention policy used when protocol is http." json:"retentionPolicy,omitempty" toml:"retentionPolicy,omitempty" yaml:"retentionPolicy,omitempty" export:"true" `
2022-01-24 10:08:05 +00:00
Username string ` description:"InfluxDB username (only with http)." json:"username,omitempty" toml:"username,omitempty" yaml:"username,omitempty" loggable:"false" `
Password string ` description:"InfluxDB password (only with http)." json:"password,omitempty" toml:"password,omitempty" yaml:"password,omitempty" loggable:"false" `
2021-09-17 07:08:07 +00:00
AddEntryPointsLabels bool ` description:"Enable metrics on entry points." json:"addEntryPointsLabels,omitempty" toml:"addEntryPointsLabels,omitempty" yaml:"addEntryPointsLabels,omitempty" export:"true" `
AddRoutersLabels bool ` description:"Enable metrics on routers." json:"addRoutersLabels,omitempty" toml:"addRoutersLabels,omitempty" yaml:"addRoutersLabels,omitempty" export:"true" `
AddServicesLabels bool ` description:"Enable metrics on services." json:"addServicesLabels,omitempty" toml:"addServicesLabels,omitempty" yaml:"addServicesLabels,omitempty" export:"true" `
2022-02-21 11:10:08 +00:00
AdditionalLabels map [ string ] string ` description:"Additional labels (influxdb tags) on all metrics" json:"additionalLabels,omitempty" toml:"additionalLabels,omitempty" yaml:"additionalLabels,omitempty" export:"true" `
2018-11-14 09:18:03 +00:00
}
2019-06-17 09:48:05 +00:00
// SetDefaults sets the default values.
func ( i * InfluxDB ) SetDefaults ( ) {
i . Address = "localhost:8089"
i . Protocol = "udp"
2020-08-17 16:04:03 +00:00
i . PushInterval = types . Duration ( 10 * time . Second )
2019-07-18 19:36:05 +00:00
i . AddEntryPointsLabels = true
i . AddServicesLabels = true
2018-11-14 09:18:03 +00:00
}
2022-02-09 14:32:12 +00:00
// InfluxDB2 contains address, token and metrics pushing interval configuration.
type InfluxDB2 struct {
Address string ` description:"InfluxDB v2 address." json:"address,omitempty" toml:"address,omitempty" yaml:"address,omitempty" `
Token string ` description:"InfluxDB v2 access token." json:"token,omitempty" toml:"token,omitempty" yaml:"token,omitempty" loggable:"false" `
PushInterval types . Duration ` description:"InfluxDB v2 push interval." json:"pushInterval,omitempty" toml:"pushInterval,omitempty" yaml:"pushInterval,omitempty" export:"true" `
Org string ` description:"InfluxDB v2 org ID." json:"org,omitempty" toml:"org,omitempty" yaml:"org,omitempty" export:"true" `
Bucket string ` description:"InfluxDB v2 bucket ID." json:"bucket,omitempty" toml:"bucket,omitempty" yaml:"bucket,omitempty" export:"true" `
AddEntryPointsLabels bool ` description:"Enable metrics on entry points." json:"addEntryPointsLabels,omitempty" toml:"addEntryPointsLabels,omitempty" yaml:"addEntryPointsLabels,omitempty" export:"true" `
AddRoutersLabels bool ` description:"Enable metrics on routers." json:"addRoutersLabels,omitempty" toml:"addRoutersLabels,omitempty" yaml:"addRoutersLabels,omitempty" export:"true" `
AddServicesLabels bool ` description:"Enable metrics on services." json:"addServicesLabels,omitempty" toml:"addServicesLabels,omitempty" yaml:"addServicesLabels,omitempty" export:"true" `
2022-02-21 13:05:28 +00:00
AdditionalLabels map [ string ] string ` description:"Additional labels (influxdb tags) on all metrics" json:"additionalLabels,omitempty" toml:"additionalLabels,omitempty" yaml:"additionalLabels,omitempty" export:"true" `
2022-02-09 14:32:12 +00:00
}
// SetDefaults sets the default values.
func ( i * InfluxDB2 ) SetDefaults ( ) {
i . Address = "http://localhost:8086"
i . PushInterval = types . Duration ( 10 * time . Second )
i . AddEntryPointsLabels = true
i . AddServicesLabels = true
}
2019-07-18 19:36:05 +00:00
// Statistics provides options for monitoring request and response stats.
2019-06-17 09:48:05 +00:00
type Statistics struct {
2019-07-01 09:30:05 +00:00
RecentErrors int ` description:"Number of recent errors logged." json:"recentErrors,omitempty" toml:"recentErrors,omitempty" yaml:"recentErrors,omitempty" export:"true" `
2018-11-14 09:18:03 +00:00
}
2019-06-17 09:48:05 +00:00
// SetDefaults sets the default values.
func ( s * Statistics ) SetDefaults ( ) {
s . RecentErrors = 10
2018-11-14 09:18:03 +00:00
}