From 19506cccaf37c2954a96eca89433bad46c7f0788 Mon Sep 17 00:00:00 2001 From: rokatyy Date: Mon, 12 May 2025 12:59:26 +0100 Subject: [PATCH 1/3] [Dashboard] Implement elastic search client --- go.mod | 6 +++ go.sum | 15 +++++++ pkg/platform/kube/logProxier/elastic.go | 53 +++++++++++++++++++++++++ pkg/platform/kube/logProxier/types.go | 19 +++++++++ pkg/platform/kube/platform.go | 27 ++++++++----- pkg/platform/types.go | 32 +++++++++++++-- 6 files changed, 140 insertions(+), 12 deletions(-) create mode 100644 pkg/platform/kube/logProxier/elastic.go create mode 100644 pkg/platform/kube/logProxier/types.go diff --git a/go.mod b/go.mod index c9b8ae82ed6..06913b8d0f4 100644 --- a/go.mod +++ b/go.mod @@ -11,6 +11,7 @@ require ( github.com/coreos/go-semver v0.3.1 github.com/docker/distribution v2.8.2+incompatible github.com/eclipse/paho.mqtt.golang v1.4.3 + github.com/elastic/go-elasticsearch/v8 v8.18.0 github.com/fatih/color v1.15.0 github.com/fatih/structs v1.1.0 github.com/go-chi/chi/v5 v5.0.10 @@ -91,12 +92,14 @@ require ( github.com/eapache/go-resiliency v1.7.0 // indirect github.com/eapache/go-xerial-snappy v0.0.0-20230731223053-c322873962e3 // indirect github.com/eapache/queue v1.1.0 // indirect + github.com/elastic/elastic-transport-go/v8 v8.7.0 // indirect github.com/emicklei/go-restful/v3 v3.11.0 // indirect github.com/emirpasic/gods v1.18.1 // indirect github.com/evanphx/json-patch v4.12.0+incompatible // indirect github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect github.com/go-git/go-billy/v5 v5.6.1 // indirect github.com/go-logr/logr v1.4.2 // indirect + github.com/go-logr/stdr v1.2.2 // indirect github.com/go-openapi/jsonpointer v0.19.6 // indirect github.com/go-openapi/jsonreference v0.20.2 // indirect github.com/go-openapi/swag v0.22.3 // indirect @@ -165,6 +168,9 @@ require ( github.com/xdg-go/pbkdf2 v1.0.0 // indirect github.com/xdg-go/stringprep v1.0.4 // indirect go.opencensus.io v0.24.0 // indirect + go.opentelemetry.io/otel v1.30.0 // indirect + go.opentelemetry.io/otel/metric v1.30.0 // indirect + go.opentelemetry.io/otel/trace v1.30.0 // indirect go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.25.0 // indirect go4.org v0.0.0-20200411211856-f5505b9728dd // indirect diff --git a/go.sum b/go.sum index 2247a229a8d..36f8b503dc5 100644 --- a/go.sum +++ b/go.sum @@ -107,6 +107,10 @@ github.com/eapache/queue v1.1.0 h1:YOEu7KNc61ntiQlcEeUIoDTJ2o8mQznoNvUhiigpIqc= github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I= github.com/eclipse/paho.mqtt.golang v1.4.3 h1:2kwcUGn8seMUfWndX0hGbvH8r7crgcJguQNCyp70xik= github.com/eclipse/paho.mqtt.golang v1.4.3/go.mod h1:CSYvoAlsMkhYOXh/oKyxa8EcBci6dVkLCbo5tTC1RIE= +github.com/elastic/elastic-transport-go/v8 v8.7.0 h1:OgTneVuXP2uip4BA658Xi6Hfw+PeIOod2rY3GVMGoVE= +github.com/elastic/elastic-transport-go/v8 v8.7.0/go.mod h1:YLHer5cj0csTzNFXoNQ8qhtGY1GTvSqPnKWKaqQE3Hk= +github.com/elastic/go-elasticsearch/v8 v8.18.0 h1:ANNq1h7DEiPUaALb8+5w3baQzaS08WfHV0DNzp0VG4M= +github.com/elastic/go-elasticsearch/v8 v8.18.0/go.mod h1:WLqwXsJmQoYkoA9JBFeEwPkQhCfAZuUvfpdU/NvSSf0= github.com/elazarl/goproxy v1.2.3 h1:xwIyKHbaP5yfT6O9KIeYJR5549MXRQkoQMRXGztz8YQ= github.com/elazarl/goproxy v1.2.3/go.mod h1:YfEbZtqP4AetfO6d40vWchF3znWX7C7Vd6ZMfdL8z64= github.com/emicklei/go-restful/v3 v3.11.0 h1:rAQeMHw1c7zTmncogyy8VvRZwtkmkZ4FxERmMY4rD+g= @@ -145,9 +149,12 @@ github.com/go-git/go-git/v5 v5.13.1 h1:DAQ9APonnlvSWpvolXWIuV6Q6zXy2wHbN4cVlNR5Q github.com/go-git/go-git/v5 v5.13.1/go.mod h1:qryJB4cSBoq3FRoBRf5A77joojuBcmPJ0qu3XXXVixc= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= +github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/logr v1.3.0/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= +github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= +github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= github.com/go-openapi/jsonpointer v0.19.6 h1:eCs3fxoIi3Wh6vtgmLTOjdhSpiqphQ+DaPn38N2ZdrE= github.com/go-openapi/jsonpointer v0.19.6/go.mod h1:osyAmYz/mB/C3I+WsTTSgw1ONzaLJoLCyoi6/zppojs= github.com/go-openapi/jsonreference v0.20.2 h1:3sVjiK66+uXK/6oQ8xgcRKcFgQ5KXa2KvnJRumpMGbE= @@ -486,6 +493,14 @@ go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.24.0 h1:y73uSU6J157QMP2kn2r30vwW1A2W2WFwSCGnAVxeaD0= go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo= +go.opentelemetry.io/otel v1.30.0 h1:F2t8sK4qf1fAmY9ua4ohFS/K+FUuOPemHUIXHtktrts= +go.opentelemetry.io/otel v1.30.0/go.mod h1:tFw4Br9b7fOS+uEao81PJjVMjW/5fvNCbpsDIXqP0pc= +go.opentelemetry.io/otel/metric v1.30.0 h1:4xNulvn9gjzo4hjg+wzIKG7iNFEaBMX00Qd4QIZs7+w= +go.opentelemetry.io/otel/metric v1.30.0/go.mod h1:aXTfST94tswhWEb+5QjlSqG+cZlmyXy/u8jFpor3WqQ= +go.opentelemetry.io/otel/sdk v1.30.0 h1:cHdik6irO49R5IysVhdn8oaiR9m8XluDaJAs4DfOrYE= +go.opentelemetry.io/otel/sdk v1.30.0/go.mod h1:p14X4Ok8S+sygzblytT1nqG98QG2KYKv++HE0LY/mhg= +go.opentelemetry.io/otel/trace v1.30.0 h1:7UBkkYzeg3C7kQX8VAidWh2biiQbtAKjyIML8dQ9wmc= +go.opentelemetry.io/otel/trace v1.30.0/go.mod h1:5EyKqTzzmyqB9bwtCCq6pDLktPK6fmGf/Dph+8VI02o= go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= go.uber.org/goleak v1.1.12/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ= go.uber.org/goleak v1.2.0 h1:xqgm/S+aQvhWFTtR0XK3Jvg7z8kGV8P4X14IzwN3Eqk= diff --git a/pkg/platform/kube/logProxier/elastic.go b/pkg/platform/kube/logProxier/elastic.go new file mode 100644 index 00000000000..7d9e46bbbf7 --- /dev/null +++ b/pkg/platform/kube/logProxier/elastic.go @@ -0,0 +1,53 @@ +package logProxier + +import ( + "context" + "crypto/tls" + "io" + "net/http" + + "github.com/nuclio/nuclio/pkg/platform" + "github.com/nuclio/nuclio/pkg/platformconfig" + + "github.com/elastic/go-elasticsearch/v8" + "github.com/nuclio/errors" +) + +type ElasticLogProxier struct { + client *elasticsearch.TypedClient + + index string + customQueryParam string +} + +func NewElasticLogProxier(config *platformconfig.ElasticSearchConfig) (*ElasticLogProxier, error) { + esClient := &ElasticLogProxier{ + index: config.Index, + customQueryParam: config.CustomQueryParameter, + } + var err error + + tlsConfig := &tls.Config{ + // Set to true to skip TLS verification if SSLVerificationMode is "none" + InsecureSkipVerify: config.SSLVerificationMode == "none", + } + if esClient.client, err = elasticsearch.NewTypedClient(elasticsearch.Config{ + Addresses: []string{config.URL}, + Password: config.Password, + Username: config.Username, + Transport: &http.Transport{ + TLSClientConfig: tlsConfig, + }, + }); err != nil { + return nil, errors.Wrap(err, "Failed to create elasticsearch client") + } + return esClient, err +} + +func (e *ElasticLogProxier) ProxyFunctionLogs(ctx context.Context, options *platform.ProxyFunctionLogsOptions) (io.ReadCloser, error) { + return nil, nil +} + +func (e *ElasticLogProxier) GetFunctionReplicas(ctx context.Context, options *GetFunctionReplicaOptions) ([]string, error) { + return nil, nil +} diff --git a/pkg/platform/kube/logProxier/types.go b/pkg/platform/kube/logProxier/types.go new file mode 100644 index 00000000000..4fbbd2c5c4c --- /dev/null +++ b/pkg/platform/kube/logProxier/types.go @@ -0,0 +1,19 @@ +package logProxier + +import ( + "context" + "io" + + "github.com/nuclio/nuclio/pkg/platform" +) + +type LogProxier interface { + ProxyFunctionLogs(ctx context.Context, options *platform.ProxyFunctionLogsOptions) (io.ReadCloser, error) + + GetFunctionReplicas(ctx context.Context, options *GetFunctionReplicaOptions) ([]string, error) +} + +type GetFunctionReplicaOptions struct { + TimeFilter *platform.TimeFilter + FunctionName string +} diff --git a/pkg/platform/kube/platform.go b/pkg/platform/kube/platform.go index b132cc300cc..7d0dbdaf4f6 100644 --- a/pkg/platform/kube/platform.go +++ b/pkg/platform/kube/platform.go @@ -40,6 +40,7 @@ import ( nuclioio "github.com/nuclio/nuclio/pkg/platform/kube/apis/nuclio.io/v1beta1" "github.com/nuclio/nuclio/pkg/platform/kube/client" "github.com/nuclio/nuclio/pkg/platform/kube/ingress" + "github.com/nuclio/nuclio/pkg/platform/kube/logProxier" "github.com/nuclio/nuclio/pkg/platformconfig" "github.com/nuclio/errors" @@ -57,15 +58,16 @@ import ( type Platform struct { *abstract.Platform - deployer *client.Deployer - getter *client.Getter - updater *client.Updater - deleter *client.Deleter - kubeconfigPath string - consumer *client.Consumer - projectsClient project.Client - projectsCache *cache.Expiring - apiGatewayScrubber *platform.APIGatewayScrubber + deployer *client.Deployer + getter *client.Getter + updater *client.Updater + deleter *client.Deleter + kubeconfigPath string + consumer *client.Consumer + projectsClient project.Client + projectsCache *cache.Expiring + apiGatewayScrubber *platform.APIGatewayScrubber + elasticSearchClient *logProxier.ElasticLogProxier } const Mib = 1048576 @@ -142,6 +144,13 @@ func NewPlatform(ctx context.Context, return nil, errors.Wrap(err, "Failed to create an updater") } + if platformConfiguration.Kube.ElasticSearchConfig != nil { + // create elastic search client + newPlatform.elasticSearchClient, err = logProxier.NewElasticLogProxier(platformConfiguration.Kube.ElasticSearchConfig) + if err != nil { + return nil, errors.Wrap(err, "Failed to create elasticsearch client") + } + } // set kubeClientSet for Function Scrubber newPlatform.FunctionScrubber = functionconfig.NewScrubber(parentLogger, platformConfiguration.SensitiveFields.CompileSensitiveFieldsRegex(), diff --git a/pkg/platform/types.go b/pkg/platform/types.go index d0a239e8c51..49a2fcd8b66 100644 --- a/pkg/platform/types.go +++ b/pkg/platform/types.go @@ -36,10 +36,14 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) -// -// Auth -// +type ProxyLogsSource string +const ( + ProxyLogsSourceES ProxyLogsSource = "elasticsearch" + ProxyLogsSourceK8s ProxyLogsSource = "kubernetes" +) + +// Auth type AuthConfig struct { Token string } @@ -132,6 +136,28 @@ type GetFunctionsOptions struct { EnrichWithAPIGateways bool } +type ProxyFunctionLogsOptions struct { + // filtering options + TimeFilter *TimeFilter `json:"timeFilter,omitempty"` + Substring string `json:"substring,omitempty"` + Regexp string `json:"regexp,omitempty"` + ReplicaNames []string `json:"replicaNames,omitempty"` + LogLevels []string `json:"logLevels,omitempty"` + + // limit options + Size int64 `json:"size,omitempty"` + SearchAfter []string `json:"searchAfter,omitempty"` + + Source ProxyLogsSource `json:"source,omitempty"` +} + +type TimeFilter struct { + Since *time.Time `json:"since,omitempty"` + Until *time.Time `json:"until,omitempty"` + + Sort string `json:"sort,omitempty"` // desc or asc +} + // CreateFunctionInvocationOptions is the base for all platform invoke options type CreateFunctionInvocationOptions struct { Name string From d14df424f5d5bbf63d0486559b82464fb913b60f Mon Sep 17 00:00:00 2001 From: rokatyy Date: Mon, 12 May 2025 16:49:11 +0100 Subject: [PATCH 2/3] add licences --- pkg/platform/kube/logProxier/elastic.go | 16 ++++++++++++++++ pkg/platform/kube/logProxier/types.go | 16 ++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/pkg/platform/kube/logProxier/elastic.go b/pkg/platform/kube/logProxier/elastic.go index 7d9e46bbbf7..49271a5fe8c 100644 --- a/pkg/platform/kube/logProxier/elastic.go +++ b/pkg/platform/kube/logProxier/elastic.go @@ -1,3 +1,19 @@ +/* +Copyright 2025 The Nuclio Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + package logProxier import ( diff --git a/pkg/platform/kube/logProxier/types.go b/pkg/platform/kube/logProxier/types.go index 4fbbd2c5c4c..b8545778af6 100644 --- a/pkg/platform/kube/logProxier/types.go +++ b/pkg/platform/kube/logProxier/types.go @@ -1,3 +1,19 @@ +/* +Copyright 2025 The Nuclio Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + package logProxier import ( From 96b5c64d48b0daea92ab538ca77277455643667c Mon Sep 17 00:00:00 2001 From: rokatyy Date: Mon, 12 May 2025 17:39:58 +0100 Subject: [PATCH 3/3] comments --- go.mod | 11 ++++---- go.sum | 26 ++++++++++--------- .../kube/{logProxier => logProxy}/elastic.go | 14 +++++----- .../kube/{logProxier => logProxy}/types.go | 4 +-- pkg/platform/kube/platform.go | 6 ++--- pkg/platform/types.go | 17 +++++++----- 6 files changed, 42 insertions(+), 36 deletions(-) rename pkg/platform/kube/{logProxier => logProxy}/elastic.go (75%) rename pkg/platform/kube/{logProxier => logProxy}/types.go (95%) diff --git a/go.mod b/go.mod index 06913b8d0f4..31d7d8c3375 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( github.com/coreos/go-semver v0.3.1 github.com/docker/distribution v2.8.2+incompatible github.com/eclipse/paho.mqtt.golang v1.4.3 - github.com/elastic/go-elasticsearch/v8 v8.18.0 + github.com/elastic/go-elasticsearch/v9 v9.0.0 github.com/fatih/color v1.15.0 github.com/fatih/structs v1.1.0 github.com/go-chi/chi/v5 v5.0.10 @@ -19,7 +19,7 @@ require ( github.com/go-git/go-git/v5 v5.13.1 github.com/gobuffalo/flect v1.0.2 github.com/golang-jwt/jwt/v4 v4.5.2 - github.com/google/go-cmp v0.6.0 + github.com/google/go-cmp v0.7.0 github.com/google/uuid v1.6.0 github.com/heptiolabs/healthcheck v0.0.0-20211123025425-613501dd5deb github.com/icza/dyno v0.0.0-20230330125955-09f820a8d9c0 @@ -168,9 +168,10 @@ require ( github.com/xdg-go/pbkdf2 v1.0.0 // indirect github.com/xdg-go/stringprep v1.0.4 // indirect go.opencensus.io v0.24.0 // indirect - go.opentelemetry.io/otel v1.30.0 // indirect - go.opentelemetry.io/otel/metric v1.30.0 // indirect - go.opentelemetry.io/otel/trace v1.30.0 // indirect + go.opentelemetry.io/auto/sdk v1.1.0 // indirect + go.opentelemetry.io/otel v1.35.0 // indirect + go.opentelemetry.io/otel/metric v1.35.0 // indirect + go.opentelemetry.io/otel/trace v1.35.0 // indirect go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.25.0 // indirect go4.org v0.0.0-20200411211856-f5505b9728dd // indirect diff --git a/go.sum b/go.sum index 36f8b503dc5..91580fb9219 100644 --- a/go.sum +++ b/go.sum @@ -109,8 +109,8 @@ github.com/eclipse/paho.mqtt.golang v1.4.3 h1:2kwcUGn8seMUfWndX0hGbvH8r7crgcJguQ github.com/eclipse/paho.mqtt.golang v1.4.3/go.mod h1:CSYvoAlsMkhYOXh/oKyxa8EcBci6dVkLCbo5tTC1RIE= github.com/elastic/elastic-transport-go/v8 v8.7.0 h1:OgTneVuXP2uip4BA658Xi6Hfw+PeIOod2rY3GVMGoVE= github.com/elastic/elastic-transport-go/v8 v8.7.0/go.mod h1:YLHer5cj0csTzNFXoNQ8qhtGY1GTvSqPnKWKaqQE3Hk= -github.com/elastic/go-elasticsearch/v8 v8.18.0 h1:ANNq1h7DEiPUaALb8+5w3baQzaS08WfHV0DNzp0VG4M= -github.com/elastic/go-elasticsearch/v8 v8.18.0/go.mod h1:WLqwXsJmQoYkoA9JBFeEwPkQhCfAZuUvfpdU/NvSSf0= +github.com/elastic/go-elasticsearch/v9 v9.0.0 h1:krpgPeJ2lC8apkaw6B58gKDYJq5eUhP8AMwpPt01Q/U= +github.com/elastic/go-elasticsearch/v9 v9.0.0/go.mod h1:2PB5YQPpY5tWbF65MRqzEXA31PZOdXCkloQSOZtU14I= github.com/elazarl/goproxy v1.2.3 h1:xwIyKHbaP5yfT6O9KIeYJR5549MXRQkoQMRXGztz8YQ= github.com/elazarl/goproxy v1.2.3/go.mod h1:YfEbZtqP4AetfO6d40vWchF3znWX7C7Vd6ZMfdL8z64= github.com/emicklei/go-restful/v3 v3.11.0 h1:rAQeMHw1c7zTmncogyy8VvRZwtkmkZ4FxERmMY4rD+g= @@ -215,8 +215,8 @@ github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= -github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= +github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= @@ -407,8 +407,8 @@ github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs= github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro= github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= -github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8= -github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4= +github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR38lUII= +github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWNMNyH2VO9fmH0o= github.com/rs/dnscache v0.0.0-20211102005908-e0241e321417 h1:Lt9DzQALzHoDwMBGJ6v8ObDPR0dzr2a6sXTB1Fq7IHs= github.com/rs/dnscache v0.0.0-20211102005908-e0241e321417/go.mod h1:qe5TWALJ8/a1Lqznoc5BDHpYX/8HU60Hm2AwRmqzxqA= github.com/rs/xid v1.5.0 h1:mKX4bl4iPYJtEIxp6CYiUuLQ/8DYMoz0PUdtGgMFRVc= @@ -493,14 +493,16 @@ go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.24.0 h1:y73uSU6J157QMP2kn2r30vwW1A2W2WFwSCGnAVxeaD0= go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo= -go.opentelemetry.io/otel v1.30.0 h1:F2t8sK4qf1fAmY9ua4ohFS/K+FUuOPemHUIXHtktrts= -go.opentelemetry.io/otel v1.30.0/go.mod h1:tFw4Br9b7fOS+uEao81PJjVMjW/5fvNCbpsDIXqP0pc= -go.opentelemetry.io/otel/metric v1.30.0 h1:4xNulvn9gjzo4hjg+wzIKG7iNFEaBMX00Qd4QIZs7+w= -go.opentelemetry.io/otel/metric v1.30.0/go.mod h1:aXTfST94tswhWEb+5QjlSqG+cZlmyXy/u8jFpor3WqQ= +go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA= +go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A= +go.opentelemetry.io/otel v1.35.0 h1:xKWKPxrxB6OtMCbmMY021CqC45J+3Onta9MqjhnusiQ= +go.opentelemetry.io/otel v1.35.0/go.mod h1:UEqy8Zp11hpkUrL73gSlELM0DupHoiq72dR+Zqel/+Y= +go.opentelemetry.io/otel/metric v1.35.0 h1:0znxYu2SNyuMSQT4Y9WDWej0VpcsxkuklLa4/siN90M= +go.opentelemetry.io/otel/metric v1.35.0/go.mod h1:nKVFgxBZ2fReX6IlyW28MgZojkoAkJGaE8CpgeAU3oE= go.opentelemetry.io/otel/sdk v1.30.0 h1:cHdik6irO49R5IysVhdn8oaiR9m8XluDaJAs4DfOrYE= go.opentelemetry.io/otel/sdk v1.30.0/go.mod h1:p14X4Ok8S+sygzblytT1nqG98QG2KYKv++HE0LY/mhg= -go.opentelemetry.io/otel/trace v1.30.0 h1:7UBkkYzeg3C7kQX8VAidWh2biiQbtAKjyIML8dQ9wmc= -go.opentelemetry.io/otel/trace v1.30.0/go.mod h1:5EyKqTzzmyqB9bwtCCq6pDLktPK6fmGf/Dph+8VI02o= +go.opentelemetry.io/otel/trace v1.35.0 h1:dPpEfJu1sDIqruz7BHFG3c7528f6ddfSWfFDVt/xgMs= +go.opentelemetry.io/otel/trace v1.35.0/go.mod h1:WUk7DtFp1Aw2MkvqGdwiXYDZZNvA/1J8o6xRXLrIkyc= go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= go.uber.org/goleak v1.1.12/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ= go.uber.org/goleak v1.2.0 h1:xqgm/S+aQvhWFTtR0XK3Jvg7z8kGV8P4X14IzwN3Eqk= diff --git a/pkg/platform/kube/logProxier/elastic.go b/pkg/platform/kube/logProxy/elastic.go similarity index 75% rename from pkg/platform/kube/logProxier/elastic.go rename to pkg/platform/kube/logProxy/elastic.go index 49271a5fe8c..e5b1354a0b2 100644 --- a/pkg/platform/kube/logProxier/elastic.go +++ b/pkg/platform/kube/logProxy/elastic.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package logProxier +package logProxy import ( "context" @@ -25,19 +25,19 @@ import ( "github.com/nuclio/nuclio/pkg/platform" "github.com/nuclio/nuclio/pkg/platformconfig" - "github.com/elastic/go-elasticsearch/v8" + "github.com/elastic/go-elasticsearch/v9" "github.com/nuclio/errors" ) -type ElasticLogProxier struct { +type ElasticLogProxy struct { client *elasticsearch.TypedClient index string customQueryParam string } -func NewElasticLogProxier(config *platformconfig.ElasticSearchConfig) (*ElasticLogProxier, error) { - esClient := &ElasticLogProxier{ +func NewElasticLogProxy(config *platformconfig.ElasticSearchConfig) (*ElasticLogProxy, error) { + esClient := &ElasticLogProxy{ index: config.Index, customQueryParam: config.CustomQueryParameter, } @@ -60,10 +60,10 @@ func NewElasticLogProxier(config *platformconfig.ElasticSearchConfig) (*ElasticL return esClient, err } -func (e *ElasticLogProxier) ProxyFunctionLogs(ctx context.Context, options *platform.ProxyFunctionLogsOptions) (io.ReadCloser, error) { +func (e *ElasticLogProxy) ProxyFunctionLogs(ctx context.Context, options *platform.ProxyFunctionLogsOptions) (io.ReadCloser, error) { return nil, nil } -func (e *ElasticLogProxier) GetFunctionReplicas(ctx context.Context, options *GetFunctionReplicaOptions) ([]string, error) { +func (e *ElasticLogProxy) GetFunctionReplicas(ctx context.Context, options *GetFunctionReplicaOptions) ([]string, error) { return nil, nil } diff --git a/pkg/platform/kube/logProxier/types.go b/pkg/platform/kube/logProxy/types.go similarity index 95% rename from pkg/platform/kube/logProxier/types.go rename to pkg/platform/kube/logProxy/types.go index b8545778af6..67fa544a9bd 100644 --- a/pkg/platform/kube/logProxier/types.go +++ b/pkg/platform/kube/logProxy/types.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package logProxier +package logProxy import ( "context" @@ -23,7 +23,7 @@ import ( "github.com/nuclio/nuclio/pkg/platform" ) -type LogProxier interface { +type LogProxy interface { ProxyFunctionLogs(ctx context.Context, options *platform.ProxyFunctionLogsOptions) (io.ReadCloser, error) GetFunctionReplicas(ctx context.Context, options *GetFunctionReplicaOptions) ([]string, error) diff --git a/pkg/platform/kube/platform.go b/pkg/platform/kube/platform.go index 7d0dbdaf4f6..413f4a6c3db 100644 --- a/pkg/platform/kube/platform.go +++ b/pkg/platform/kube/platform.go @@ -40,7 +40,7 @@ import ( nuclioio "github.com/nuclio/nuclio/pkg/platform/kube/apis/nuclio.io/v1beta1" "github.com/nuclio/nuclio/pkg/platform/kube/client" "github.com/nuclio/nuclio/pkg/platform/kube/ingress" - "github.com/nuclio/nuclio/pkg/platform/kube/logProxier" + "github.com/nuclio/nuclio/pkg/platform/kube/logProxy" "github.com/nuclio/nuclio/pkg/platformconfig" "github.com/nuclio/errors" @@ -67,7 +67,7 @@ type Platform struct { projectsClient project.Client projectsCache *cache.Expiring apiGatewayScrubber *platform.APIGatewayScrubber - elasticSearchClient *logProxier.ElasticLogProxier + elasticSearchClient *logProxy.ElasticLogProxy } const Mib = 1048576 @@ -146,7 +146,7 @@ func NewPlatform(ctx context.Context, if platformConfiguration.Kube.ElasticSearchConfig != nil { // create elastic search client - newPlatform.elasticSearchClient, err = logProxier.NewElasticLogProxier(platformConfiguration.Kube.ElasticSearchConfig) + newPlatform.elasticSearchClient, err = logProxy.NewElasticLogProxy(platformConfiguration.Kube.ElasticSearchConfig) if err != nil { return nil, errors.Wrap(err, "Failed to create elasticsearch client") } diff --git a/pkg/platform/types.go b/pkg/platform/types.go index 49a2fcd8b66..345fbe34508 100644 --- a/pkg/platform/types.go +++ b/pkg/platform/types.go @@ -36,14 +36,10 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) -type ProxyLogsSource string - -const ( - ProxyLogsSourceES ProxyLogsSource = "elasticsearch" - ProxyLogsSourceK8s ProxyLogsSource = "kubernetes" -) - +// // Auth +// + type AuthConfig struct { Token string } @@ -136,6 +132,13 @@ type GetFunctionsOptions struct { EnrichWithAPIGateways bool } +type ProxyLogsSource string + +const ( + ProxyLogsSourceES ProxyLogsSource = "elasticsearch" + ProxyLogsSourceK8s ProxyLogsSource = "kubernetes" +) + type ProxyFunctionLogsOptions struct { // filtering options TimeFilter *TimeFilter `json:"timeFilter,omitempty"`