Skip to content

Commit

Permalink
Add a new clustering method "blank" (#372)
Browse files Browse the repository at this point in the history
Signed-off-by: Daxin Wang <daxinwang@harmonycloud.cn>
  • Loading branch information
dxsup authored Dec 1, 2022
1 parent d472fe2 commit 3fbc93e
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 12 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
### Enhancements
- Add payload for all protocols.([#375](https://github.com/KindlingProject/kindling/pull/375))
-
-
- Add a new clustering method "blank" that is used to reduce the cardinality of metrics as much as possible. ([#372](https://github.com/KindlingProject/kindling/pull/372))

### Bug fixes
-
Expand Down
3 changes: 2 additions & 1 deletion collector/docker/kindling-collector-config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,11 @@ analyzers:
protocol_parser: [ http, mysql, dns, redis, kafka, rocketmq ]
# Which URL clustering method should be used to shorten the URL of HTTP request.
# This is useful for decrease the cardinality of URLs.
# Valid values: ["noparam", "alphabet"]
# Valid values: ["noparam", "alphabet", "blank"]
# - noparam: Only trim the trailing parameters behind the character '?'
# - alphabet: Trim the trailing parameters and Convert the segments
# containing non-alphabetical characters to star(*)
# - blank: Turn endpoints to empty. This is used to reduce the cardinality as much as possible.
url_clustering_method: alphabet
# If the destination port of data is one of the followings, the protocol of such network request
# is set to the corresponding one. Note the program will try to identify the protocol automatically
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,7 @@ import (
)

func NewHttpParser(urlClusteringMethod string) *protocol.ProtocolParser {
var method urlclustering.ClusteringMethod
switch urlClusteringMethod {
case "alphabet":
method = urlclustering.NewAlphabeticalClusteringMethod()
case "noparam":
method = urlclustering.NewNoParamClusteringMethod()
default:
method = urlclustering.NewAlphabeticalClusteringMethod()
}
method := urlclustering.NewMethod(urlClusteringMethod)
requestParser := protocol.CreatePkgParser(fastfailHttpRequest(), parseHttpRequest(method))
responseParser := protocol.CreatePkgParser(fastfailHttpResponse(), parseHttpResponse())

Expand Down
14 changes: 14 additions & 0 deletions collector/pkg/urlclustering/blank.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package urlclustering

// BlankClusteringMethod removes the endpoint and return an empty string.
// This method is used to reduce the cardinality as much as possible.
type BlankClusteringMethod struct {
}

func NewBlankClusteringMethod() ClusteringMethod {
return &BlankClusteringMethod{}
}

func (m *BlankClusteringMethod) Clustering(_ string) string {
return ""
}
14 changes: 14 additions & 0 deletions collector/pkg/urlclustering/factory.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package urlclustering

func NewMethod(urlClusteringMethod string) ClusteringMethod {
switch urlClusteringMethod {
case "alphabet":
return NewAlphabeticalClusteringMethod()
case "noparam":
return NewNoParamClusteringMethod()
case "blank":
return NewBlankClusteringMethod()
default:
return NewAlphabeticalClusteringMethod()
}
}
3 changes: 2 additions & 1 deletion deploy/agent/kindling-collector-config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,11 @@ analyzers:
protocol_parser: [ http, mysql, dns, redis, kafka, rocketmq ]
# Which URL clustering method should be used to shorten the URL of HTTP request.
# This is useful for decrease the cardinality of URLs.
# Valid values: ["noparam", "alphabet"]
# Valid values: ["noparam", "alphabet", "blank"]
# - noparam: Only trim the trailing parameters behind the character '?'
# - alphabet: Trim the trailing parameters and Convert the segments
# containing non-alphabetical characters to star(*)
# - blank: Turn endpoints to empty. This is used to reduce the cardinality as much as possible.
url_clustering_method: alphabet
# If the destination port of data is one of the followings, the protocol of such network request
# is set to the corresponding one. Note the program will try to identify the protocol automatically
Expand Down

0 comments on commit 3fbc93e

Please sign in to comment.