diff --git a/cli/go.mod b/cli/go.mod index 6cf63a9156d..8ad895a0eae 100644 --- a/cli/go.mod +++ b/cli/go.mod @@ -4,7 +4,7 @@ go 1.18 require ( github.com/bitly/go-simplejson v0.5.0 - github.com/deepflowio/deepflow/message v0.0.0-20230815052508-4df8a3b357c2 + github.com/deepflowio/deepflow/message v0.0.0-20230816091740-5ceff2582d9a github.com/deepflowio/deepflow/server v0.0.0-20230815065845-7ac50b3813a0 github.com/golang/protobuf v1.5.2 github.com/mattn/go-runewidth v0.0.14 diff --git a/cli/go.sum b/cli/go.sum index f14b50a4b1c..1bb44763612 100644 --- a/cli/go.sum +++ b/cli/go.sum @@ -89,8 +89,8 @@ github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ3 github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/deepflowio/deepflow/message v0.0.0-20230815052508-4df8a3b357c2 h1:luJfWKzjCDRlLij/J6SFG94ARBFpxjC3m5UZoWvUTrY= -github.com/deepflowio/deepflow/message v0.0.0-20230815052508-4df8a3b357c2/go.mod h1:e+1lUMMlycCvFRKvlwt/y/0vxJnF8wVss3GyR1ARXY0= +github.com/deepflowio/deepflow/message v0.0.0-20230816091740-5ceff2582d9a h1:jYejDxLs8F2GfpZO+ggpLMjs/Iuu735lUFfpQ+jyDhM= +github.com/deepflowio/deepflow/message v0.0.0-20230816091740-5ceff2582d9a/go.mod h1:e+1lUMMlycCvFRKvlwt/y/0vxJnF8wVss3GyR1ARXY0= github.com/deepflowio/deepflow/server v0.0.0-20230815065845-7ac50b3813a0 h1:Od5pJCiQm8Kx/SFfFZ0/23szh5kUxgMlxD+lmxZoV+I= github.com/deepflowio/deepflow/server v0.0.0-20230815065845-7ac50b3813a0/go.mod h1:b+6fxzwFrdgNGxYt/lvGkerQhSBNoPHbyOoBtci/GSY= github.com/docker/go-units v0.4.0 h1:3uh0PgVws3nIA0Q+MwDC8yjEPf9zjRfZZWXZYDct3Tw= diff --git a/message/trident.proto b/message/trident.proto index 454de27bb8d..e82bdbd8b55 100644 --- a/message/trident.proto +++ b/message/trident.proto @@ -268,7 +268,6 @@ message Config { optional bool external_agent_http_proxy_enabled = 406 [default = false]; // 外部Agent数据HTTP代理开关 optional uint32 external_agent_http_proxy_port = 407 [default = 38086]; // 外部Agent数据HTTP代理端口 // _ = 408; // deprecated. 408 was once occupied by prometheus_http_api_address. - optional string prometheus_http_api_address = 408 [default = ""]; // TODO(weiqiang): deprecated. repeated string prometheus_http_api_addresses = 409; optional uint32 packet_sequence_flag = 410 [default = 0]; diff --git a/server/controller/common/vtap_config.go b/server/controller/common/vtap_config.go index a9012167e72..e8afce2634f 100644 --- a/server/controller/common/vtap_config.go +++ b/server/controller/common/vtap_config.go @@ -77,7 +77,7 @@ var DefaultVTapGroupConfig = &mysql.VTapGroupConfiguration{ HTTPLogXRequestID: &DefaultHTTPLogXRequestID, ExternalAgentHTTPProxyEnabled: &DefaultExternalAgentHTTPProxyEnabled, ExternalAgentHTTPProxyPort: &DefaultExternalAgentHTTPProxyPort, - PrometheusHttpAPIAddress: &DefaultPrometheusHttpAPIAddress, + PrometheusHttpAPIAddresses: &DefaultPrometheusHttpAPIAddresses, AnalyzerPort: &DefaultAnalyzerPort, ProxyControllerPort: &DefaultProxyControllerPort, ProxyControllerIP: &DefaultProxyControllerIP, @@ -142,7 +142,7 @@ var ( DefaultHTTPLogXRequestID = "X-Request-ID" DefaultExternalAgentHTTPProxyEnabled = 1 DefaultExternalAgentHTTPProxyPort = 38086 - DefaultPrometheusHttpAPIAddress = "" + DefaultPrometheusHttpAPIAddresses = "" DefaultAnalyzerPort = 30033 DefaultProxyControllerPort = 30035 DefaultProxyControllerIP = "" diff --git a/server/controller/db/mysql/migration/rawsql/init.sql b/server/controller/db/mysql/migration/rawsql/init.sql index a06c0c36f8c..7da49b4431e 100644 --- a/server/controller/db/mysql/migration/rawsql/init.sql +++ b/server/controller/db/mysql/migration/rawsql/init.sql @@ -1634,7 +1634,7 @@ CREATE TABLE IF NOT EXISTS vtap_group_configuration( log_file_size INTEGER DEFAULT NULL COMMENT 'unit: MB', external_agent_http_proxy_enabled TINYINT(1) COMMENT '0: disabled 1:enabled', external_agent_http_proxy_port INTEGER DEFAULT NULL, - prometheus_http_api_address VARCHAR(128), + prometheus_http_api_addresses VARCHAR(1024), proxy_controller_port INTEGER DEFAULT NULL, analyzer_port INTEGER DEFAULT NULL, proxy_controller_ip VARCHAR(128), diff --git a/server/controller/db/mysql/migration/rawsql/issu/6.3.1.40.sql b/server/controller/db/mysql/migration/rawsql/issu/6.3.1.40.sql new file mode 100644 index 00000000000..bd1c4930537 --- /dev/null +++ b/server/controller/db/mysql/migration/rawsql/issu/6.3.1.40.sql @@ -0,0 +1,4 @@ +ALTER TABLE vtap_group_configuration CHANGE prometheus_http_api_address prometheus_http_api_addresses VARCHAR(1024); + +UPDATE db_version SET version='6.3.1.40'; + diff --git a/server/controller/db/mysql/migration/version.go b/server/controller/db/mysql/migration/version.go index 3da4137fc0a..3940be0f67a 100644 --- a/server/controller/db/mysql/migration/version.go +++ b/server/controller/db/mysql/migration/version.go @@ -18,5 +18,5 @@ package migration const ( DB_VERSION_TABLE = "db_version" - DB_VERSION_EXPECTED = "6.3.1.39" + DB_VERSION_EXPECTED = "6.3.1.40" ) diff --git a/server/controller/db/mysql/model.go b/server/controller/db/mysql/model.go index 569d02fa9e8..5b8d6a970f6 100644 --- a/server/controller/db/mysql/model.go +++ b/server/controller/db/mysql/model.go @@ -1092,7 +1092,7 @@ type VTapGroupConfiguration struct { HTTPLogXRequestID *string `gorm:"column:http_log_x_request_id;type:char(64);default:null" json:"HTTP_LOG_X_REQUEST_ID"` ExternalAgentHTTPProxyEnabled *int `gorm:"column:external_agent_http_proxy_enabled;type:tinyint(1);default:null" json:"EXTERNAL_AGENT_HTTP_PROXY_ENABLED"` ExternalAgentHTTPProxyPort *int `gorm:"column:external_agent_http_proxy_port;type:int;default:null" json:"EXTERNAL_AGENT_HTTP_PROXY_PORT"` - PrometheusHttpAPIAddress *string `gorm:"column:prometheus_http_api_address;type:string;default:null" json:"PROMETHEUS_HTTP_API_ADDRESS"` // ip:port + PrometheusHttpAPIAddresses *string `gorm:"column:prometheus_http_api_addresses;type:string;default:null" json:"PROMETHEUS_HTTP_API_ADDRESSES"` // ip:port, separate by "," AnalyzerPort *int `gorm:"column:analyzer_port;type:int;default:null" json:"ANALYZER_PORT"` ProxyControllerPort *int `gorm:"column:proxy_controller_port;type:int;default:null" json:"PROXY_CONTROLLER_PORT"` ProxyControllerIP *string `gorm:"column:proxy_controller_ip;type:varchar(512);default:null" json:"PROXY_CONTROLLER_IP"` @@ -1166,7 +1166,7 @@ type RVTapGroupConfiguration struct { HTTPLogXRequestID string `gorm:"column:http_log_x_request_id;type:char(64);default:null" json:"HTTP_LOG_X_REQUEST_ID"` ExternalAgentHTTPProxyEnabled int `gorm:"column:external_agent_http_proxy_enabled;type:tinyint(1);default:null" json:"EXTERNAL_AGENT_HTTP_PROXY_ENABLED"` ExternalAgentHTTPProxyPort int `gorm:"column:external_agent_http_proxy_port;type:int;default:null" json:"EXTERNAL_AGENT_HTTP_PROXY_PORT"` - PrometheusHttpAPIAddress string `gorm:"column:prometheus_http_api_address;type:string;default:null" json:"PROMETHEUS_HTTP_API_ADDRESS"` // ip:port + PrometheusHttpAPIAddresses string `gorm:"column:prometheus_http_api_addresses;type:string;default:null" json:"PROMETHEUS_HTTP_API_ADDRESSES"` // ip:port, separate by "," AnalyzerPort int `gorm:"column:analyzer_port;type:int;default:null" json:"ANALYZER_PORT"` ProxyControllerPort int `gorm:"column:proxy_controller_port;type:int;default:null" json:"PROXY_CONTROLLER_PORT"` ProxyControllerIP string `gorm:"column:proxy_controller_ip;type:varchar(512);default:null" json:"PROXY_CONTROLLER_IP"` diff --git a/server/controller/http/service/vtap_group_config.go b/server/controller/http/service/vtap_group_config.go index 4d964b1bb1f..4b27b1cc44b 100644 --- a/server/controller/http/service/vtap_group_config.go +++ b/server/controller/http/service/vtap_group_config.go @@ -248,7 +248,9 @@ func convertDBToJson( func convertDBToYaml(sData *mysql.VTapGroupConfiguration, tData *model.VTapGroupConfiguration) { ignoreName := []string{"ID", "VTapGroupLcuuid", "VTapGroupID", "Lcuuid", "YamlConfig", "L4LogTapTypes", "L4LogIgnoreTapSides", "L7LogIgnoreTapSides", - "L7LogStoreTapTypes", "DecapType", "Domains", "MaxCollectPps", "MaxNpbBps", "MaxTxBandwidth"} + "L7LogStoreTapTypes", "DecapType", "Domains", "MaxCollectPps", "MaxNpbBps", "MaxTxBandwidth", + "PrometheusHttpAPIAddresses", + } copyStruct(sData, tData, ignoreName) if sData.YamlConfig != nil { yamlConfig := &model.StaticConfig{} @@ -317,6 +319,7 @@ func convertDBToYaml(sData *mysql.VTapGroupConfiguration, tData *model.VTapGroup } } } + tData.PrometheusHttpAPIAddresses = strings.Split(*sData.PrometheusHttpAPIAddresses, ",") if sData.MaxCollectPps != nil { cMaxCollectPps := *sData.MaxCollectPps / 1000 tData.MaxCollectPps = &cMaxCollectPps @@ -354,7 +357,9 @@ func convertYamlToDb(sData *model.VTapGroupConfiguration, tData *mysql.VTapGroup func convertToDb(sData *model.VTapGroupConfiguration, tData *mysql.VTapGroupConfiguration) { ignoreName := []string{"ID", "YamlConfig", "Lcuuid", "VTapGroupLcuuid", "VTapGroupID", "L4LogTapTypes", "L4LogIgnoreTapSides", "L7LogIgnoreTapSides", - "L7LogStoreTapTypes", "DecapType", "Domains", "MaxCollectPps", "MaxNpbBps", "MaxTxBandwidth"} + "L7LogStoreTapTypes", "DecapType", "Domains", "MaxCollectPps", "MaxNpbBps", "MaxTxBandwidth", + "PrometheusHttpAPIAddresses", + } copyStruct(sData, tData, ignoreName) if len(sData.L4LogTapTypes) > 0 { cL4LogTapTypes := convertIntSliceToString(sData.L4LogTapTypes) @@ -392,6 +397,12 @@ func convertToDb(sData *model.VTapGroupConfiguration, tData *mysql.VTapGroupConf } else { tData.Domains = nil } + if len(sData.PrometheusHttpAPIAddresses) > 0 { + cAddrs := strings.Join(sData.PrometheusHttpAPIAddresses, ",") + tData.PrometheusHttpAPIAddresses = &cAddrs + } else { + tData.PrometheusHttpAPIAddresses = nil + } if sData.MaxCollectPps != nil { cMaxCollectPps := *sData.MaxCollectPps * 1000 tData.MaxCollectPps = &cMaxCollectPps diff --git a/server/controller/model/model.go b/server/controller/model/model.go index 907bcd7d034..03255da0624 100644 --- a/server/controller/model/model.go +++ b/server/controller/model/model.go @@ -509,7 +509,7 @@ type VTapGroupConfiguration struct { HTTPLogXRequestID *string `json:"HTTP_LOG_X_REQUEST_ID" yaml:"http_log_x_request_id,omitempty"` ExternalAgentHTTPProxyEnabled *int `json:"EXTERNAL_AGENT_HTTP_PROXY_ENABLED" yaml:"external_agent_http_proxy_enabled,omitempty"` ExternalAgentHTTPProxyPort *int `json:"EXTERNAL_AGENT_HTTP_PROXY_PORT" yaml:"external_agent_http_proxy_port,omitempty"` - PrometheusHttpAPIAddress *string `json:"PROMETHEUS_HTTP_API_ADDRESS" yaml:"prometheus_http_api_address,omitempty"` // ip:port + PrometheusHttpAPIAddresses []string `json:"PROMETHEUS_HTTP_API_ADDRESSES" yaml:"prometheus_http_api_addresses,omitempty"` // ip:port AnalyzerPort *int `json:"ANALYZER_PORT" yaml:"analyzer_port,omitempty"` ProxyControllerPort *int `json:"PROXY_CONTROLLER_PORT" yaml:"proxy_controller_port,omitempty"` ProxyControllerIP *string `json:"PROXY_CONTROLLER_IP" yaml:"proxy_controller_ip,omitempty"` diff --git a/server/controller/trisolaris/services/grpc/synchronize/vtap.go b/server/controller/trisolaris/services/grpc/synchronize/vtap.go index 94abf478a3a..897d816cb36 100644 --- a/server/controller/trisolaris/services/grpc/synchronize/vtap.go +++ b/server/controller/trisolaris/services/grpc/synchronize/vtap.go @@ -137,7 +137,7 @@ func (e *VTapEvent) generateConfigInfo(c *vtap.VTapCache, clusterID string) *api LogFileSize: proto.Uint32(uint32(vtapConfig.LogFileSize)), ExternalAgentHttpProxyEnabled: proto.Bool(Int2Bool(c.GetExternalAgentHTTPProxyEnabledConfig(gVTapInfo))), ExternalAgentHttpProxyPort: proto.Uint32(uint32(vtapConfig.ExternalAgentHTTPProxyPort)), - PrometheusHttpApiAddress: proto.String(vtapConfig.PrometheusHttpAPIAddress), + PrometheusHttpApiAddresses: strings.Split(vtapConfig.PrometheusHttpAPIAddresses, ","), AnalyzerPort: proto.Uint32(uint32(vtapConfig.AnalyzerPort)), ProxyControllerPort: proto.Uint32(uint32(vtapConfig.ProxyControllerPort)), // 调整后采集器配置信息 @@ -490,7 +490,7 @@ func (e *VTapEvent) generateNoVTapCacheConfig(groupID string) *api.Config { LogFileSize: proto.Uint32(uint32(vtapConfig.LogFileSize)), ExternalAgentHttpProxyEnabled: proto.Bool(Int2Bool(vtapConfig.ExternalAgentHTTPProxyEnabled)), ExternalAgentHttpProxyPort: proto.Uint32(uint32(vtapConfig.ExternalAgentHTTPProxyPort)), - PrometheusHttpApiAddress: proto.String(vtapConfig.PrometheusHttpAPIAddress), + PrometheusHttpApiAddresses: strings.Split(vtapConfig.PrometheusHttpAPIAddresses, ","), AnalyzerPort: proto.Uint32(uint32(vtapConfig.AnalyzerPort)), ProxyControllerPort: proto.Uint32(uint32(vtapConfig.ProxyControllerPort)), TapMode: &tapMode, diff --git a/server/go.mod b/server/go.mod index 20ca8d65abd..4ede8141a7f 100644 --- a/server/go.mod +++ b/server/go.mod @@ -33,7 +33,7 @@ require ( github.com/cornelk/hashmap v1.0.8 github.com/deckarep/golang-set v1.8.0 github.com/deckarep/golang-set/v2 v2.1.0 - github.com/deepflowio/deepflow/message v0.0.0-20230815052508-4df8a3b357c2 + github.com/deepflowio/deepflow/message v0.0.0-20230816091740-5ceff2582d9a github.com/deepflowio/deepflow/server/controller/cloud/kubernetes_gather/expand v0.0.0-00010101000000-000000000000 github.com/deepflowio/deepflow/server/controller/cloud/platform v0.0.0-00010101000000-000000000000 github.com/deepflowio/deepflow/server/controller/db/mysql/migrator v0.0.0-00010101000000-000000000000 diff --git a/server/go.sum b/server/go.sum index f043db26b8e..0b20f7b3bae 100644 --- a/server/go.sum +++ b/server/go.sum @@ -153,8 +153,8 @@ github.com/deckarep/golang-set v1.8.0 h1:sk9/l/KqpunDwP7pSjUg0keiOOLEnOBHzykLrsP github.com/deckarep/golang-set v1.8.0/go.mod h1:5nI87KwE7wgsBU1F4GKAw2Qod7p5kyS383rP6+o6qqo= github.com/deckarep/golang-set/v2 v2.1.0 h1:g47V4Or+DUdzbs8FxCCmgb6VYd+ptPAngjM6dtGktsI= github.com/deckarep/golang-set/v2 v2.1.0/go.mod h1:VAky9rY/yGXJOLEDv3OMci+7wtDpOF4IN+y82NBOac4= -github.com/deepflowio/deepflow/message v0.0.0-20230815052508-4df8a3b357c2 h1:luJfWKzjCDRlLij/J6SFG94ARBFpxjC3m5UZoWvUTrY= -github.com/deepflowio/deepflow/message v0.0.0-20230815052508-4df8a3b357c2/go.mod h1:e+1lUMMlycCvFRKvlwt/y/0vxJnF8wVss3GyR1ARXY0= +github.com/deepflowio/deepflow/message v0.0.0-20230816091740-5ceff2582d9a h1:jYejDxLs8F2GfpZO+ggpLMjs/Iuu735lUFfpQ+jyDhM= +github.com/deepflowio/deepflow/message v0.0.0-20230816091740-5ceff2582d9a/go.mod h1:e+1lUMMlycCvFRKvlwt/y/0vxJnF8wVss3GyR1ARXY0= github.com/deepflowio/tempopb v0.0.0-20230215110519-15853baf3a79 h1:erRwXyZiUZxxZX/Q1QHesZXgxjiunZUFy+ggCRimkD4= github.com/deepflowio/tempopb v0.0.0-20230215110519-15853baf3a79/go.mod h1:h2rkZ319TExIUGuK8a2dlcGd8qc6wdhsrcpXWaJQaQE= github.com/dennwc/varint v1.0.0 h1:kGNFFSSw8ToIy3obO/kKr8U9GZYUAxQEVuix4zfDWzE=