Documentation ¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Processor ¶
type Processor interface { Process(content string) (string, map[string]interface{}, error) Keys() []*pb.FieldDefine }
Processor .
type Processors ¶
type Processors struct {
// contains filtered or unexported fields
}
Processors .
Example ¶
package main import ( "encoding/json" "fmt" "github.com/erda-project/erda-proto-go/core/monitor/metric/pb" "github.com/erda-project/erda/modules/extensions/loghub/metrics/analysis/processors" _ "github.com/erda-project/erda/modules/extensions/loghub/metrics/analysis/processors/regex" ) func main() { var ( scopeID string = "terminus" tags = map[string]string{ "dice_org_id": "1", "dice_application_id": "2", "dice_service_name": "abc", } metricName = "test_metric" ) cfg, _ := json.Marshal(map[string]interface{}{ "pattern": "(d+)", "keys": []*pb.FieldDefine{ { Key: "ip", Type: "string", }, }, }) ps := processors.New() err := ps.Add(scopeID, tags, metricName, "regexp", cfg) if err != nil { fmt.Println(err) return } list := ps.Find("", scopeID, map[string]string{ "dice_org_id": "1", "dice_application_id": "2", }) if len(list) != 0 { fmt.Println("Find error") return } list = ps.Find("", scopeID, map[string]string{ "dice_org_id": "1", "dice_application_id": "3", "dice_service_name": "abc", }) if len(list) != 0 { fmt.Println("Find error") return } list = ps.Find("", scopeID, map[string]string{ "dice_org_id": "1", "dice_application_id": "2", "dice_service_name": "abc", }) if len(list) <= 0 { fmt.Println("Find error") return } fmt.Printf("Find %d\n", len(list)) }
Output: Find 1
Click to show internal directories.
Click to hide internal directories.