feat: script collect support append_tags and fix timeout
This commit is contained in:
parent
754ad160dc
commit
58093eedf0
|
@ -28,7 +28,7 @@ type CollectRule struct {
|
|||
type PortConfig struct {
|
||||
Port int `json:"port"`
|
||||
Protocol string `json:"protocol"` // tcp or udp
|
||||
Timeout int `json:"timeout "` // second
|
||||
Timeout int `json:"timeout"` // second
|
||||
}
|
||||
|
||||
type ProcConfig struct {
|
||||
|
@ -41,7 +41,7 @@ type ScriptConfig struct {
|
|||
Params string `json:"params"`
|
||||
Stdin string `json:"stdin"`
|
||||
Env map[string]string `json:"env"`
|
||||
Timeout int `json:"timeout "` // second
|
||||
Timeout int `json:"timeout"` // second
|
||||
}
|
||||
|
||||
type LogConfig struct {
|
||||
|
|
|
@ -153,6 +153,11 @@ func changeCollectRule(rule *models.CollectRule) error {
|
|||
return err
|
||||
}
|
||||
|
||||
tags := strings.Fields(rule.AppendTags)
|
||||
for i := 0; i < len(tags); i++ {
|
||||
tags[i] = strings.Replace(tags[i], "=", ":", 1)
|
||||
}
|
||||
|
||||
config := ScriptCollectFormat{
|
||||
Instances: []struct {
|
||||
MinCollectionInterval int `json:"min_collection_interval,omitempty"`
|
||||
|
@ -162,6 +167,7 @@ func changeCollectRule(rule *models.CollectRule) error {
|
|||
Env map[string]string `json:"env"`
|
||||
Stdin string `json:"stdin"`
|
||||
Timeout int `json:"timeout"`
|
||||
Tags []string `json:"tags,omitempty"`
|
||||
}{{
|
||||
MinCollectionInterval: rule.Step,
|
||||
FilePath: conf.Path,
|
||||
|
@ -169,6 +175,7 @@ func changeCollectRule(rule *models.CollectRule) error {
|
|||
Env: conf.Env,
|
||||
Stdin: conf.Stdin,
|
||||
Timeout: conf.Timeout,
|
||||
Tags: tags,
|
||||
}},
|
||||
}
|
||||
|
||||
|
@ -257,6 +264,7 @@ type ScriptCollectFormat struct {
|
|||
Env map[string]string `json:"env"`
|
||||
Stdin string `json:"stdin"`
|
||||
Timeout int `json:"timeout"`
|
||||
Tags []string `json:"tags,omitempty"`
|
||||
} `json:"instances"`
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue