Skip to content

Commit

Permalink
[Querier] auto custom tag config support display_name and description
Browse files Browse the repository at this point in the history
  • Loading branch information
Ericsssss authored and xiaochaoren1 committed Dec 8, 2023
1 parent b3b9b60 commit 1214fc6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
6 changes: 4 additions & 2 deletions server/querier/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,10 @@ type Clickhouse struct {
MaxConnection int `default:"20" yaml:"max-connection"`
}
type AutoCustomTags struct {
TagName string `default:"" yaml:"tag-name"`
TagFields []string `yaml:"tag-fields" binding:"omitempty,dive"`
TagName string `default:"" yaml:"tag-name"`
TagFields []string `yaml:"tag-fields" binding:"omitempty,dive"`
DisplayName string `default:"" yaml:"display_name"`
Description string `default:"" yaml:"description"`
}

func (c *Config) expendEnv() {
Expand Down
13 changes: 9 additions & 4 deletions server/querier/engine/clickhouse/tag/description.go
Original file line number Diff line number Diff line change
Expand Up @@ -740,15 +740,20 @@ func GetTagDescriptions(db, table, rawSql string, ctx context.Context) (response
if len(config.Cfg.AutoCustomTags) != 0 {
for _, AutoCustomTag := range config.Cfg.AutoCustomTags {
tagName := AutoCustomTag.TagName
tagDisplayName := tagName
if AutoCustomTag.DisplayName != "" {
tagDisplayName = AutoCustomTag.DisplayName
}
if db == ckcommon.DB_NAME_EXT_METRICS || db == ckcommon.DB_NAME_EVENT || db == ckcommon.DB_NAME_PROFILE || db == ckcommon.DB_NAME_PROMETHEUS || table == "vtap_flow_port" || table == "vtap_app_port" {

response.Values = append(response.Values, []interface{}{
tagName, tagName, tagName, tagName, "auto_custom_tag",
"Custom Tag", []string{}, []bool{true, true, true}, AutoCustomTag.TagFields, "",
tagName, tagName, tagName, tagDisplayName, "auto_custom_tag",
"Custom Tag", []string{}, []bool{true, true, true}, AutoCustomTag.Description, AutoCustomTag.TagFields,
})
} else if db != "deepflow_system" && table != "vtap_acl" && table != "l4_packet" && table != "l7_packet" {
response.Values = append(response.Values, []interface{}{
tagName, tagName + "_0", tagName + "_1", tagName, "auto_custom_tag",
"Custom Tag", []string{}, []bool{true, true, true}, AutoCustomTag.TagFields, "",
tagName, tagName + "_0", tagName + "_1", tagDisplayName, "auto_custom_tag",
"Custom Tag", []string{}, []bool{true, true, true}, AutoCustomTag.Description, AutoCustomTag.TagFields,
})
}
}
Expand Down

0 comments on commit 1214fc6

Please sign in to comment.