Allow to define datadogs metrics endpoint with env vars

This commit is contained in:
Sylvain Rabot 2021-03-23 17:48:04 +01:00 committed by GitHub
parent 8947f85ddd
commit 31a5f3591f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,6 +1,8 @@
package types
import (
"net"
"os"
"time"
"github.com/traefik/paerser/types"
@ -41,7 +43,16 @@ type Datadog struct {
// SetDefaults sets the default values.
func (d *Datadog) SetDefaults() {
d.Address = "localhost:8125"
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)
d.PushInterval = types.Duration(10 * time.Second)
d.AddEntryPointsLabels = true
d.AddServicesLabels = true