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