Skip to content

Commit

Permalink
[Server] fix agent config prometheus_http_api_addresses
Browse files Browse the repository at this point in the history
  • Loading branch information
roryye committed Aug 17, 2023
1 parent 0134563 commit 98fd630
Show file tree
Hide file tree
Showing 13 changed files with 32 additions and 18 deletions.
2 changes: 1 addition & 1 deletion cli/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions cli/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
1 change: 0 additions & 1 deletion message/trident.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
4 changes: 2 additions & 2 deletions server/controller/common/vtap_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ var DefaultVTapGroupConfig = &mysql.VTapGroupConfiguration{
HTTPLogXRequestID: &DefaultHTTPLogXRequestID,
ExternalAgentHTTPProxyEnabled: &DefaultExternalAgentHTTPProxyEnabled,
ExternalAgentHTTPProxyPort: &DefaultExternalAgentHTTPProxyPort,
PrometheusHttpAPIAddress: &DefaultPrometheusHttpAPIAddress,
PrometheusHttpAPIAddresses: &DefaultPrometheusHttpAPIAddresses,
AnalyzerPort: &DefaultAnalyzerPort,
ProxyControllerPort: &DefaultProxyControllerPort,
ProxyControllerIP: &DefaultProxyControllerIP,
Expand Down Expand Up @@ -142,7 +142,7 @@ var (
DefaultHTTPLogXRequestID = "X-Request-ID"
DefaultExternalAgentHTTPProxyEnabled = 1
DefaultExternalAgentHTTPProxyPort = 38086
DefaultPrometheusHttpAPIAddress = ""
DefaultPrometheusHttpAPIAddresses = ""
DefaultAnalyzerPort = 30033
DefaultProxyControllerPort = 30035
DefaultProxyControllerIP = ""
Expand Down
2 changes: 1 addition & 1 deletion server/controller/db/mysql/migration/rawsql/init.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
4 changes: 4 additions & 0 deletions server/controller/db/mysql/migration/rawsql/issu/6.3.1.40.sql
Original file line number Diff line number Diff line change
@@ -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';

2 changes: 1 addition & 1 deletion server/controller/db/mysql/migration/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
4 changes: 2 additions & 2 deletions server/controller/db/mysql/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down Expand Up @@ -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"`
Expand Down
15 changes: 13 additions & 2 deletions server/controller/http/service/vtap_group_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion server/controller/model/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)),
// 调整后采集器配置信息
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion server/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions server/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down

0 comments on commit 98fd630

Please sign in to comment.