Skip to content

Commit

Permalink
[Controller] add log monitor
Browse files Browse the repository at this point in the history
  • Loading branch information
jin-xiaofeng authored and SongZhen0704 committed May 14, 2024
1 parent 29bbead commit 68c3121
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions server/agent_config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ type StaticConfig struct {
ExternalProfileIntegrationDisabled *bool `yaml:"external-profile-integration-disabled,omitempty"`
ExternalTraceIntegrationDisabled *bool `yaml:"external-trace-integration-disabled,omitempty"`
ExternalMetricIntegrationDisabled *bool `yaml:"external-metric-integration-disabled,omitempty"`
ExternalLogIntegrationDisabled *bool `yaml:"external_log_integration_disabled,omitempty"`
NtpMaxInterval *string `yaml:"ntp-max-interval,omitempty"`
NtpMinInterval *string `yaml:"ntp-min-interval,omitempty"`
DispatcherQueue *bool `yaml:"dispatcher-queue,omitempty"`
Expand Down
1 change: 1 addition & 0 deletions server/controller/common/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ const (
VTAP_LICENSE_FUNCTION_APPLICATION_MONITORING
VTAP_LICENSE_FUNCTION_INDICATOR_MONITORING
VTAP_LICENSE_FUNCTION_DATABASE_MONITORING
VTAP_LICENSE_FUNCTION_LOG_MONITORING
VTAP_LICENSE_FUNCTION_MAX
)

Expand Down
13 changes: 13 additions & 0 deletions server/controller/trisolaris/vtap/vtap_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ type VTapCache struct {
enabledFunctionMonitoring atomicbool.Bool
enabledApplicationMonitoring atomicbool.Bool
enabledIndicatorMonitoring atomicbool.Bool
enabledLogMonitoring atomicbool.Bool

cachedAt time.Time
expectedRevision *string
Expand Down Expand Up @@ -257,6 +258,7 @@ func NewVTapCache(vtap *models.VTap, vTapInfo *VTapInfo) *VTapCache {
vTapCache.enabledFunctionMonitoring = atomicbool.NewBool(false)
vTapCache.enabledApplicationMonitoring = atomicbool.NewBool(false)
vTapCache.enabledIndicatorMonitoring = atomicbool.NewBool(false)
vTapCache.enabledLogMonitoring = atomicbool.NewBool(false)

vTapCache.cachedAt = time.Now()
vTapCache.config = &atomic.Value{}
Expand Down Expand Up @@ -303,6 +305,7 @@ func (c *VTapCache) unsetLicenseFunctionEnable() {
c.enabledFunctionMonitoring.Unset()
c.enabledApplicationMonitoring.Unset()
c.enabledIndicatorMonitoring.Unset()
c.enabledLogMonitoring.Unset()
}

func (c *VTapCache) convertLicenseFunctions() {
Expand Down Expand Up @@ -343,6 +346,9 @@ func (c *VTapCache) convertLicenseFunctions() {
if Find[int](licenseFunctionsInt, VTAP_LICENSE_FUNCTION_APPLICATION_MONITORING) {
c.enabledApplicationMonitoring.Set()
}
if Find[int](licenseFunctionsInt, VTAP_LICENSE_FUNCTION_LOG_MONITORING) {
c.enabledLogMonitoring.Set()
}
if Find[int](licenseFunctionsInt, VTAP_LICENSE_FUNCTION_INDICATOR_MONITORING) {
c.enabledIndicatorMonitoring.Set()
}
Expand Down Expand Up @@ -422,6 +428,9 @@ func (c *VTapCache) modifyVTapConfigByLicense(configure *VTapConfig) {
if c.EnabledIndicatorMonitoring() == false {
yamlConfig.ExternalMetricIntegrationDisabled = proto.Bool(true)
}
if c.EnabledLogMonitoring() == false {
yamlConfig.ExternalLogIntegrationDisabled = proto.Bool(true)
}

b, err := yaml.Marshal(yamlConfig)
if err != nil {
Expand Down Expand Up @@ -455,6 +464,10 @@ func (c *VTapCache) EnabledIndicatorMonitoring() bool {
return c.enabledIndicatorMonitoring.IsSet()
}

func (c *VTapCache) EnabledLogMonitoring() bool {
return c.enabledLogMonitoring.IsSet()
}

func (c *VTapCache) updateLicenseFunctions(licenseFunctions string) {
c.licenseFunctions = proto.String(licenseFunctions)
c.convertLicenseFunctions()
Expand Down

0 comments on commit 68c3121

Please sign in to comment.