InfluxDB configuration string template builder helper
Signed-off-by: Lorenzo Fontana <lo@linux.com>
This commit is contained in:
parent
93be8db612
commit
d434583b53
2 changed files with 26 additions and 3 deletions
|
@ -38,6 +38,7 @@ import (
|
|||
"k8s.io/apimachinery/pkg/util/sets"
|
||||
"k8s.io/ingress-nginx/internal/file"
|
||||
"k8s.io/ingress-nginx/internal/ingress"
|
||||
"k8s.io/ingress-nginx/internal/ingress/annotations/influxdb"
|
||||
"k8s.io/ingress-nginx/internal/ingress/annotations/ratelimit"
|
||||
"k8s.io/ingress-nginx/internal/ingress/controller/config"
|
||||
ing_net "k8s.io/ingress-nginx/internal/net"
|
||||
|
@ -153,6 +154,7 @@ var (
|
|||
"buildOpentracingLoad": buildOpentracingLoad,
|
||||
"buildOpentracing": buildOpentracing,
|
||||
"proxySetHeader": proxySetHeader,
|
||||
"buildInfluxDB": buildInfluxDB,
|
||||
}
|
||||
)
|
||||
|
||||
|
@ -897,6 +899,29 @@ func buildOpentracing(input interface{}) string {
|
|||
return buf.String()
|
||||
}
|
||||
|
||||
// buildInfluxDB produces the single line configuration
|
||||
// needed by the InfluxDB module to send request's metrics
|
||||
// for the current resource
|
||||
func buildInfluxDB(input interface{}) string {
|
||||
cfg, ok := input.(influxdb.Config)
|
||||
if !ok {
|
||||
glog.Errorf("expected an 'influxdb.Config' type but %T was returned", input)
|
||||
return ""
|
||||
}
|
||||
|
||||
if !cfg.InfluxDBEnabled {
|
||||
return ""
|
||||
}
|
||||
|
||||
return fmt.Sprintf(
|
||||
"influxdb server_name=%s host=%s port=%s measurement=%s enabled=true;",
|
||||
cfg.InfluxDBServerName,
|
||||
cfg.InfluxDBHost,
|
||||
cfg.InfluxDBPort,
|
||||
cfg.InfluxDBMeasurement,
|
||||
)
|
||||
}
|
||||
|
||||
func proxySetHeader(loc interface{}) string {
|
||||
location, ok := loc.(*ingress.Location)
|
||||
if !ok {
|
||||
|
|
|
@ -980,9 +980,7 @@ stream {
|
|||
{{ template "CORS" $location }}
|
||||
{{ end }}
|
||||
|
||||
{{ if $location.InfluxDB.InfluxDBEnabled }}
|
||||
influxdb server_name=$location.InfluxDB.InfluxDBServerName host=$location.InfluxDB.InfluxDBHost port=$location.InfluxDB.InfluxDBPort measurement=$location.InfluxDB.InfluxDBMeasurement enabled=true;
|
||||
{{ end }}
|
||||
{{ buildInfluxDB $location.InfluxDB }}
|
||||
|
||||
{{ if not (empty $location.Redirect.URL) }}
|
||||
if ($uri ~* {{ $path }}) {
|
||||
|
|
Loading…
Reference in a new issue