diff --git a/auth/ldap.go b/auth/ldap.go index bb401bc..1410050 100644 --- a/auth/ldap.go +++ b/auth/ldap.go @@ -29,7 +29,7 @@ var ldapAdminPassword string func initLdap(config *LdapConfig) error { ldapAdminPassword = os.Getenv("LDAP_ADMIN_PASSWORD") if ldapAdminPassword == "" { - log.Println("warning: environment variable 'LDAP_ADMIN_PASSWORD' not set") + log.Println("warning: environment variable 'LDAP_ADMIN_PASSWORD' not set (ldap sync or authentication will not work)") } ldapConfig = config diff --git a/metricdata/cc-metric-store.go b/metricdata/cc-metric-store.go index 2d18a79..1d3c193 100644 --- a/metricdata/cc-metric-store.go +++ b/metricdata/cc-metric-store.go @@ -6,6 +6,7 @@ import ( "encoding/json" "errors" "fmt" + "log" "net/http" "os" "time" @@ -50,7 +51,7 @@ func (ccms *CCMetricStore) Init(url string) error { ccms.url = url // os.Getenv("CCMETRICSTORE_URL") ccms.jwt = os.Getenv("CCMETRICSTORE_JWT") if ccms.jwt == "" { - return errors.New("environment variable 'CCMETRICSTORE_JWT' not set") + log.Println("warning: environment variable 'CCMETRICSTORE_JWT' not set") } return nil @@ -73,7 +74,9 @@ func (ccms *CCMetricStore) doRequest(job *model.Job, suffix string, metrics []st if err != nil { return nil, err } - req.Header.Add("Authorization", fmt.Sprintf("Bearer %s", ccms.jwt)) + if ccms.jwt != "" { + req.Header.Add("Authorization", fmt.Sprintf("Bearer %s", ccms.jwt)) + } return ccms.client.Do(req) } @@ -174,14 +177,16 @@ func (ccms *CCMetricStore) LoadNodeData(clusterId string, metrics, nodes []strin var req *http.Request if nodes == nil { - req, err = http.NewRequestWithContext(ctx, http.MethodPost, fmt.Sprintf("%s/api/%d/%d/all-nodes", ccms.url, from, to), bytes.NewReader(reqBodyBytes)) + req, err = http.NewRequestWithContext(ctx, http.MethodPost, fmt.Sprintf("%s/api/%s/%d/%d/all-nodes", ccms.url, clusterId, from, to), bytes.NewReader(reqBodyBytes)) } else { req, err = http.NewRequestWithContext(ctx, http.MethodPost, fmt.Sprintf("%s/api/%d/%d/timeseries", ccms.url, from, to), bytes.NewReader(reqBodyBytes)) } if err != nil { return nil, err } - req.Header.Add("Authorization", fmt.Sprintf("Bearer %s", ccms.jwt)) + if ccms.jwt != "" { + req.Header.Add("Authorization", fmt.Sprintf("Bearer %s", ccms.jwt)) + } res, err := ccms.client.Do(req) if err != nil { return nil, err diff --git a/metricdata/influxdb-v2.go b/metricdata/influxdb-v2.go index 1719ab3..5c1ade0 100644 --- a/metricdata/influxdb-v2.go +++ b/metricdata/influxdb-v2.go @@ -2,8 +2,8 @@ package metricdata import ( "context" - "errors" "fmt" + "log" "os" "strings" "time" @@ -24,7 +24,7 @@ type InfluxDBv2DataRepository struct { func (idb *InfluxDBv2DataRepository) Init(url string) error { token := os.Getenv("INFLUXDB_V2_TOKEN") if token == "" { - return errors.New("warning: environment variable 'INFLUXDB_V2_TOKEN' not set") + log.Println("warning: environment variable 'INFLUXDB_V2_TOKEN' not set") } idb.client = influxdb2.NewClient(url, token)