Rename internal_models package to models
This commit is contained in:
parent
49988b15a3
commit
d3bb1e7010
|
@ -12,7 +12,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func NewAccumulator(
|
func NewAccumulator(
|
||||||
inputConfig *internal_models.InputConfig,
|
inputConfig *models.InputConfig,
|
||||||
metrics chan telegraf.Metric,
|
metrics chan telegraf.Metric,
|
||||||
) *accumulator {
|
) *accumulator {
|
||||||
acc := accumulator{}
|
acc := accumulator{}
|
||||||
|
@ -31,7 +31,7 @@ type accumulator struct {
|
||||||
// print every point added to the accumulator
|
// print every point added to the accumulator
|
||||||
trace bool
|
trace bool
|
||||||
|
|
||||||
inputConfig *internal_models.InputConfig
|
inputConfig *models.InputConfig
|
||||||
|
|
||||||
precision time.Duration
|
precision time.Duration
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ func TestAdd(t *testing.T) {
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
a.metrics = make(chan telegraf.Metric, 10)
|
a.metrics = make(chan telegraf.Metric, 10)
|
||||||
defer close(a.metrics)
|
defer close(a.metrics)
|
||||||
a.inputConfig = &internal_models.InputConfig{}
|
a.inputConfig = &models.InputConfig{}
|
||||||
|
|
||||||
a.Add("acctest", float64(101), map[string]string{})
|
a.Add("acctest", float64(101), map[string]string{})
|
||||||
a.Add("acctest", float64(101), map[string]string{"acc": "test"})
|
a.Add("acctest", float64(101), map[string]string{"acc": "test"})
|
||||||
|
@ -47,7 +47,7 @@ func TestAddNoPrecisionWithInterval(t *testing.T) {
|
||||||
now := time.Date(2006, time.February, 10, 12, 0, 0, 82912748, time.UTC)
|
now := time.Date(2006, time.February, 10, 12, 0, 0, 82912748, time.UTC)
|
||||||
a.metrics = make(chan telegraf.Metric, 10)
|
a.metrics = make(chan telegraf.Metric, 10)
|
||||||
defer close(a.metrics)
|
defer close(a.metrics)
|
||||||
a.inputConfig = &internal_models.InputConfig{}
|
a.inputConfig = &models.InputConfig{}
|
||||||
|
|
||||||
a.SetPrecision(0, time.Second)
|
a.SetPrecision(0, time.Second)
|
||||||
a.Add("acctest", float64(101), map[string]string{})
|
a.Add("acctest", float64(101), map[string]string{})
|
||||||
|
@ -74,7 +74,7 @@ func TestAddNoIntervalWithPrecision(t *testing.T) {
|
||||||
now := time.Date(2006, time.February, 10, 12, 0, 0, 82912748, time.UTC)
|
now := time.Date(2006, time.February, 10, 12, 0, 0, 82912748, time.UTC)
|
||||||
a.metrics = make(chan telegraf.Metric, 10)
|
a.metrics = make(chan telegraf.Metric, 10)
|
||||||
defer close(a.metrics)
|
defer close(a.metrics)
|
||||||
a.inputConfig = &internal_models.InputConfig{}
|
a.inputConfig = &models.InputConfig{}
|
||||||
|
|
||||||
a.SetPrecision(time.Second, time.Millisecond)
|
a.SetPrecision(time.Second, time.Millisecond)
|
||||||
a.Add("acctest", float64(101), map[string]string{})
|
a.Add("acctest", float64(101), map[string]string{})
|
||||||
|
@ -101,7 +101,7 @@ func TestAddDisablePrecision(t *testing.T) {
|
||||||
now := time.Date(2006, time.February, 10, 12, 0, 0, 82912748, time.UTC)
|
now := time.Date(2006, time.February, 10, 12, 0, 0, 82912748, time.UTC)
|
||||||
a.metrics = make(chan telegraf.Metric, 10)
|
a.metrics = make(chan telegraf.Metric, 10)
|
||||||
defer close(a.metrics)
|
defer close(a.metrics)
|
||||||
a.inputConfig = &internal_models.InputConfig{}
|
a.inputConfig = &models.InputConfig{}
|
||||||
|
|
||||||
a.SetPrecision(time.Second, time.Millisecond)
|
a.SetPrecision(time.Second, time.Millisecond)
|
||||||
a.DisablePrecision()
|
a.DisablePrecision()
|
||||||
|
@ -129,7 +129,7 @@ func TestDifferentPrecisions(t *testing.T) {
|
||||||
now := time.Date(2006, time.February, 10, 12, 0, 0, 82912748, time.UTC)
|
now := time.Date(2006, time.February, 10, 12, 0, 0, 82912748, time.UTC)
|
||||||
a.metrics = make(chan telegraf.Metric, 10)
|
a.metrics = make(chan telegraf.Metric, 10)
|
||||||
defer close(a.metrics)
|
defer close(a.metrics)
|
||||||
a.inputConfig = &internal_models.InputConfig{}
|
a.inputConfig = &models.InputConfig{}
|
||||||
|
|
||||||
a.SetPrecision(0, time.Second)
|
a.SetPrecision(0, time.Second)
|
||||||
a.Add("acctest", float64(101), map[string]string{"acc": "test"}, now)
|
a.Add("acctest", float64(101), map[string]string{"acc": "test"}, now)
|
||||||
|
@ -170,7 +170,7 @@ func TestAddDefaultTags(t *testing.T) {
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
a.metrics = make(chan telegraf.Metric, 10)
|
a.metrics = make(chan telegraf.Metric, 10)
|
||||||
defer close(a.metrics)
|
defer close(a.metrics)
|
||||||
a.inputConfig = &internal_models.InputConfig{}
|
a.inputConfig = &models.InputConfig{}
|
||||||
|
|
||||||
a.Add("acctest", float64(101), map[string]string{})
|
a.Add("acctest", float64(101), map[string]string{})
|
||||||
a.Add("acctest", float64(101), map[string]string{"acc": "test"})
|
a.Add("acctest", float64(101), map[string]string{"acc": "test"})
|
||||||
|
@ -196,7 +196,7 @@ func TestAddFields(t *testing.T) {
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
a.metrics = make(chan telegraf.Metric, 10)
|
a.metrics = make(chan telegraf.Metric, 10)
|
||||||
defer close(a.metrics)
|
defer close(a.metrics)
|
||||||
a.inputConfig = &internal_models.InputConfig{}
|
a.inputConfig = &models.InputConfig{}
|
||||||
|
|
||||||
fields := map[string]interface{}{
|
fields := map[string]interface{}{
|
||||||
"usage": float64(99),
|
"usage": float64(99),
|
||||||
|
@ -229,7 +229,7 @@ func TestAddInfFields(t *testing.T) {
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
a.metrics = make(chan telegraf.Metric, 10)
|
a.metrics = make(chan telegraf.Metric, 10)
|
||||||
defer close(a.metrics)
|
defer close(a.metrics)
|
||||||
a.inputConfig = &internal_models.InputConfig{}
|
a.inputConfig = &models.InputConfig{}
|
||||||
|
|
||||||
fields := map[string]interface{}{
|
fields := map[string]interface{}{
|
||||||
"usage": inf,
|
"usage": inf,
|
||||||
|
@ -257,7 +257,7 @@ func TestAddNaNFields(t *testing.T) {
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
a.metrics = make(chan telegraf.Metric, 10)
|
a.metrics = make(chan telegraf.Metric, 10)
|
||||||
defer close(a.metrics)
|
defer close(a.metrics)
|
||||||
a.inputConfig = &internal_models.InputConfig{}
|
a.inputConfig = &models.InputConfig{}
|
||||||
|
|
||||||
fields := map[string]interface{}{
|
fields := map[string]interface{}{
|
||||||
"usage": nan,
|
"usage": nan,
|
||||||
|
@ -281,7 +281,7 @@ func TestAddUint64Fields(t *testing.T) {
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
a.metrics = make(chan telegraf.Metric, 10)
|
a.metrics = make(chan telegraf.Metric, 10)
|
||||||
defer close(a.metrics)
|
defer close(a.metrics)
|
||||||
a.inputConfig = &internal_models.InputConfig{}
|
a.inputConfig = &models.InputConfig{}
|
||||||
|
|
||||||
fields := map[string]interface{}{
|
fields := map[string]interface{}{
|
||||||
"usage": uint64(99),
|
"usage": uint64(99),
|
||||||
|
@ -310,7 +310,7 @@ func TestAddUint64Overflow(t *testing.T) {
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
a.metrics = make(chan telegraf.Metric, 10)
|
a.metrics = make(chan telegraf.Metric, 10)
|
||||||
defer close(a.metrics)
|
defer close(a.metrics)
|
||||||
a.inputConfig = &internal_models.InputConfig{}
|
a.inputConfig = &models.InputConfig{}
|
||||||
|
|
||||||
fields := map[string]interface{}{
|
fields := map[string]interface{}{
|
||||||
"usage": uint64(9223372036854775808),
|
"usage": uint64(9223372036854775808),
|
||||||
|
@ -340,7 +340,7 @@ func TestAddInts(t *testing.T) {
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
a.metrics = make(chan telegraf.Metric, 10)
|
a.metrics = make(chan telegraf.Metric, 10)
|
||||||
defer close(a.metrics)
|
defer close(a.metrics)
|
||||||
a.inputConfig = &internal_models.InputConfig{}
|
a.inputConfig = &models.InputConfig{}
|
||||||
|
|
||||||
a.Add("acctest", int(101), map[string]string{})
|
a.Add("acctest", int(101), map[string]string{})
|
||||||
a.Add("acctest", int32(101), map[string]string{"acc": "test"})
|
a.Add("acctest", int32(101), map[string]string{"acc": "test"})
|
||||||
|
@ -367,7 +367,7 @@ func TestAddFloats(t *testing.T) {
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
a.metrics = make(chan telegraf.Metric, 10)
|
a.metrics = make(chan telegraf.Metric, 10)
|
||||||
defer close(a.metrics)
|
defer close(a.metrics)
|
||||||
a.inputConfig = &internal_models.InputConfig{}
|
a.inputConfig = &models.InputConfig{}
|
||||||
|
|
||||||
a.Add("acctest", float32(101), map[string]string{"acc": "test"})
|
a.Add("acctest", float32(101), map[string]string{"acc": "test"})
|
||||||
a.Add("acctest", float64(101), map[string]string{"acc": "test"}, now)
|
a.Add("acctest", float64(101), map[string]string{"acc": "test"}, now)
|
||||||
|
@ -389,7 +389,7 @@ func TestAddStrings(t *testing.T) {
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
a.metrics = make(chan telegraf.Metric, 10)
|
a.metrics = make(chan telegraf.Metric, 10)
|
||||||
defer close(a.metrics)
|
defer close(a.metrics)
|
||||||
a.inputConfig = &internal_models.InputConfig{}
|
a.inputConfig = &models.InputConfig{}
|
||||||
|
|
||||||
a.Add("acctest", "test", map[string]string{"acc": "test"})
|
a.Add("acctest", "test", map[string]string{"acc": "test"})
|
||||||
a.Add("acctest", "foo", map[string]string{"acc": "test"}, now)
|
a.Add("acctest", "foo", map[string]string{"acc": "test"}, now)
|
||||||
|
@ -411,7 +411,7 @@ func TestAddBools(t *testing.T) {
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
a.metrics = make(chan telegraf.Metric, 10)
|
a.metrics = make(chan telegraf.Metric, 10)
|
||||||
defer close(a.metrics)
|
defer close(a.metrics)
|
||||||
a.inputConfig = &internal_models.InputConfig{}
|
a.inputConfig = &models.InputConfig{}
|
||||||
|
|
||||||
a.Add("acctest", true, map[string]string{"acc": "test"})
|
a.Add("acctest", true, map[string]string{"acc": "test"})
|
||||||
a.Add("acctest", false, map[string]string{"acc": "test"}, now)
|
a.Add("acctest", false, map[string]string{"acc": "test"}, now)
|
||||||
|
@ -433,11 +433,11 @@ func TestAccFilterTags(t *testing.T) {
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
a.metrics = make(chan telegraf.Metric, 10)
|
a.metrics = make(chan telegraf.Metric, 10)
|
||||||
defer close(a.metrics)
|
defer close(a.metrics)
|
||||||
filter := internal_models.Filter{
|
filter := models.Filter{
|
||||||
TagExclude: []string{"acc"},
|
TagExclude: []string{"acc"},
|
||||||
}
|
}
|
||||||
assert.NoError(t, filter.CompileFilter())
|
assert.NoError(t, filter.CompileFilter())
|
||||||
a.inputConfig = &internal_models.InputConfig{}
|
a.inputConfig = &models.InputConfig{}
|
||||||
a.inputConfig.Filter = filter
|
a.inputConfig.Filter = filter
|
||||||
|
|
||||||
a.Add("acctest", float64(101), map[string]string{})
|
a.Add("acctest", float64(101), map[string]string{})
|
||||||
|
@ -465,7 +465,7 @@ func TestAccAddError(t *testing.T) {
|
||||||
defer log.SetOutput(os.Stderr)
|
defer log.SetOutput(os.Stderr)
|
||||||
|
|
||||||
a := accumulator{}
|
a := accumulator{}
|
||||||
a.inputConfig = &internal_models.InputConfig{}
|
a.inputConfig = &models.InputConfig{}
|
||||||
a.inputConfig.Name = "mock_plugin"
|
a.inputConfig.Name = "mock_plugin"
|
||||||
|
|
||||||
a.AddError(fmt.Errorf("foo"))
|
a.AddError(fmt.Errorf("foo"))
|
||||||
|
|
|
@ -88,7 +88,7 @@ func (a *Agent) Close() error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func panicRecover(input *internal_models.RunningInput) {
|
func panicRecover(input *models.RunningInput) {
|
||||||
if err := recover(); err != nil {
|
if err := recover(); err != nil {
|
||||||
trace := make([]byte, 2048)
|
trace := make([]byte, 2048)
|
||||||
runtime.Stack(trace, true)
|
runtime.Stack(trace, true)
|
||||||
|
@ -104,7 +104,7 @@ func panicRecover(input *internal_models.RunningInput) {
|
||||||
// reporting interval.
|
// reporting interval.
|
||||||
func (a *Agent) gatherer(
|
func (a *Agent) gatherer(
|
||||||
shutdown chan struct{},
|
shutdown chan struct{},
|
||||||
input *internal_models.RunningInput,
|
input *models.RunningInput,
|
||||||
interval time.Duration,
|
interval time.Duration,
|
||||||
metricC chan telegraf.Metric,
|
metricC chan telegraf.Metric,
|
||||||
) error {
|
) error {
|
||||||
|
@ -152,7 +152,7 @@ func (a *Agent) gatherer(
|
||||||
// over.
|
// over.
|
||||||
func gatherWithTimeout(
|
func gatherWithTimeout(
|
||||||
shutdown chan struct{},
|
shutdown chan struct{},
|
||||||
input *internal_models.RunningInput,
|
input *models.RunningInput,
|
||||||
acc *accumulator,
|
acc *accumulator,
|
||||||
timeout time.Duration,
|
timeout time.Duration,
|
||||||
) {
|
) {
|
||||||
|
@ -240,7 +240,7 @@ func (a *Agent) flush() {
|
||||||
|
|
||||||
wg.Add(len(a.Config.Outputs))
|
wg.Add(len(a.Config.Outputs))
|
||||||
for _, o := range a.Config.Outputs {
|
for _, o := range a.Config.Outputs {
|
||||||
go func(output *internal_models.RunningOutput) {
|
go func(output *models.RunningOutput) {
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
err := output.Write()
|
err := output.Write()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -351,7 +351,7 @@ func (a *Agent) Run(shutdown chan struct{}) error {
|
||||||
if input.Config.Interval != 0 {
|
if input.Config.Interval != 0 {
|
||||||
interval = input.Config.Interval
|
interval = input.Config.Interval
|
||||||
}
|
}
|
||||||
go func(in *internal_models.RunningInput, interv time.Duration) {
|
go func(in *models.RunningInput, interv time.Duration) {
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
if err := a.gatherer(shutdown, in, interv, metricC); err != nil {
|
if err := a.gatherer(shutdown, in, interv, metricC); err != nil {
|
||||||
log.Printf(err.Error())
|
log.Printf(err.Error())
|
||||||
|
|
|
@ -47,8 +47,8 @@ type Config struct {
|
||||||
OutputFilters []string
|
OutputFilters []string
|
||||||
|
|
||||||
Agent *AgentConfig
|
Agent *AgentConfig
|
||||||
Inputs []*internal_models.RunningInput
|
Inputs []*models.RunningInput
|
||||||
Outputs []*internal_models.RunningOutput
|
Outputs []*models.RunningOutput
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewConfig() *Config {
|
func NewConfig() *Config {
|
||||||
|
@ -61,8 +61,8 @@ func NewConfig() *Config {
|
||||||
},
|
},
|
||||||
|
|
||||||
Tags: make(map[string]string),
|
Tags: make(map[string]string),
|
||||||
Inputs: make([]*internal_models.RunningInput, 0),
|
Inputs: make([]*models.RunningInput, 0),
|
||||||
Outputs: make([]*internal_models.RunningOutput, 0),
|
Outputs: make([]*models.RunningOutput, 0),
|
||||||
InputFilters: make([]string, 0),
|
InputFilters: make([]string, 0),
|
||||||
OutputFilters: make([]string, 0),
|
OutputFilters: make([]string, 0),
|
||||||
}
|
}
|
||||||
|
@ -598,7 +598,7 @@ func (c *Config) addOutput(name string, table *ast.Table) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
ro := internal_models.NewRunningOutput(name, output, outputConfig,
|
ro := models.NewRunningOutput(name, output, outputConfig,
|
||||||
c.Agent.MetricBatchSize, c.Agent.MetricBufferLimit)
|
c.Agent.MetricBatchSize, c.Agent.MetricBufferLimit)
|
||||||
c.Outputs = append(c.Outputs, ro)
|
c.Outputs = append(c.Outputs, ro)
|
||||||
return nil
|
return nil
|
||||||
|
@ -639,7 +639,7 @@ func (c *Config) addInput(name string, table *ast.Table) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
rp := &internal_models.RunningInput{
|
rp := &models.RunningInput{
|
||||||
Name: name,
|
Name: name,
|
||||||
Input: input,
|
Input: input,
|
||||||
Config: pluginConfig,
|
Config: pluginConfig,
|
||||||
|
@ -650,10 +650,10 @@ func (c *Config) addInput(name string, table *ast.Table) error {
|
||||||
|
|
||||||
// buildFilter builds a Filter
|
// buildFilter builds a Filter
|
||||||
// (tagpass/tagdrop/namepass/namedrop/fieldpass/fielddrop) to
|
// (tagpass/tagdrop/namepass/namedrop/fieldpass/fielddrop) to
|
||||||
// be inserted into the internal_models.OutputConfig/internal_models.InputConfig
|
// be inserted into the models.OutputConfig/models.InputConfig
|
||||||
// to be used for glob filtering on tags and measurements
|
// to be used for glob filtering on tags and measurements
|
||||||
func buildFilter(tbl *ast.Table) (internal_models.Filter, error) {
|
func buildFilter(tbl *ast.Table) (models.Filter, error) {
|
||||||
f := internal_models.Filter{}
|
f := models.Filter{}
|
||||||
|
|
||||||
if node, ok := tbl.Fields["namepass"]; ok {
|
if node, ok := tbl.Fields["namepass"]; ok {
|
||||||
if kv, ok := node.(*ast.KeyValue); ok {
|
if kv, ok := node.(*ast.KeyValue); ok {
|
||||||
|
@ -717,7 +717,7 @@ func buildFilter(tbl *ast.Table) (internal_models.Filter, error) {
|
||||||
if subtbl, ok := node.(*ast.Table); ok {
|
if subtbl, ok := node.(*ast.Table); ok {
|
||||||
for name, val := range subtbl.Fields {
|
for name, val := range subtbl.Fields {
|
||||||
if kv, ok := val.(*ast.KeyValue); ok {
|
if kv, ok := val.(*ast.KeyValue); ok {
|
||||||
tagfilter := &internal_models.TagFilter{Name: name}
|
tagfilter := &models.TagFilter{Name: name}
|
||||||
if ary, ok := kv.Value.(*ast.Array); ok {
|
if ary, ok := kv.Value.(*ast.Array); ok {
|
||||||
for _, elem := range ary.Value {
|
for _, elem := range ary.Value {
|
||||||
if str, ok := elem.(*ast.String); ok {
|
if str, ok := elem.(*ast.String); ok {
|
||||||
|
@ -736,7 +736,7 @@ func buildFilter(tbl *ast.Table) (internal_models.Filter, error) {
|
||||||
if subtbl, ok := node.(*ast.Table); ok {
|
if subtbl, ok := node.(*ast.Table); ok {
|
||||||
for name, val := range subtbl.Fields {
|
for name, val := range subtbl.Fields {
|
||||||
if kv, ok := val.(*ast.KeyValue); ok {
|
if kv, ok := val.(*ast.KeyValue); ok {
|
||||||
tagfilter := &internal_models.TagFilter{Name: name}
|
tagfilter := &models.TagFilter{Name: name}
|
||||||
if ary, ok := kv.Value.(*ast.Array); ok {
|
if ary, ok := kv.Value.(*ast.Array); ok {
|
||||||
for _, elem := range ary.Value {
|
for _, elem := range ary.Value {
|
||||||
if str, ok := elem.(*ast.String); ok {
|
if str, ok := elem.(*ast.String); ok {
|
||||||
|
@ -793,9 +793,9 @@ func buildFilter(tbl *ast.Table) (internal_models.Filter, error) {
|
||||||
|
|
||||||
// buildInput parses input specific items from the ast.Table,
|
// buildInput parses input specific items from the ast.Table,
|
||||||
// builds the filter and returns a
|
// builds the filter and returns a
|
||||||
// internal_models.InputConfig to be inserted into internal_models.RunningInput
|
// models.InputConfig to be inserted into models.RunningInput
|
||||||
func buildInput(name string, tbl *ast.Table) (*internal_models.InputConfig, error) {
|
func buildInput(name string, tbl *ast.Table) (*models.InputConfig, error) {
|
||||||
cp := &internal_models.InputConfig{Name: name}
|
cp := &models.InputConfig{Name: name}
|
||||||
if node, ok := tbl.Fields["interval"]; ok {
|
if node, ok := tbl.Fields["interval"]; ok {
|
||||||
if kv, ok := node.(*ast.KeyValue); ok {
|
if kv, ok := node.(*ast.KeyValue); ok {
|
||||||
if str, ok := kv.Value.(*ast.String); ok {
|
if str, ok := kv.Value.(*ast.String); ok {
|
||||||
|
@ -969,14 +969,14 @@ func buildSerializer(name string, tbl *ast.Table) (serializers.Serializer, error
|
||||||
|
|
||||||
// buildOutput parses output specific items from the ast.Table,
|
// buildOutput parses output specific items from the ast.Table,
|
||||||
// builds the filter and returns an
|
// builds the filter and returns an
|
||||||
// internal_models.OutputConfig to be inserted into internal_models.RunningInput
|
// models.OutputConfig to be inserted into models.RunningInput
|
||||||
// Note: error exists in the return for future calls that might require error
|
// Note: error exists in the return for future calls that might require error
|
||||||
func buildOutput(name string, tbl *ast.Table) (*internal_models.OutputConfig, error) {
|
func buildOutput(name string, tbl *ast.Table) (*models.OutputConfig, error) {
|
||||||
filter, err := buildFilter(tbl)
|
filter, err := buildFilter(tbl)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
oc := &internal_models.OutputConfig{
|
oc := &models.OutputConfig{
|
||||||
Name: name,
|
Name: name,
|
||||||
Filter: filter,
|
Filter: filter,
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,19 +26,19 @@ func TestConfig_LoadSingleInputWithEnvVars(t *testing.T) {
|
||||||
memcached := inputs.Inputs["memcached"]().(*memcached.Memcached)
|
memcached := inputs.Inputs["memcached"]().(*memcached.Memcached)
|
||||||
memcached.Servers = []string{"192.168.1.1"}
|
memcached.Servers = []string{"192.168.1.1"}
|
||||||
|
|
||||||
filter := internal_models.Filter{
|
filter := models.Filter{
|
||||||
NameDrop: []string{"metricname2"},
|
NameDrop: []string{"metricname2"},
|
||||||
NamePass: []string{"metricname1"},
|
NamePass: []string{"metricname1"},
|
||||||
FieldDrop: []string{"other", "stuff"},
|
FieldDrop: []string{"other", "stuff"},
|
||||||
FieldPass: []string{"some", "strings"},
|
FieldPass: []string{"some", "strings"},
|
||||||
TagDrop: []internal_models.TagFilter{
|
TagDrop: []models.TagFilter{
|
||||||
internal_models.TagFilter{
|
models.TagFilter{
|
||||||
Name: "badtag",
|
Name: "badtag",
|
||||||
Filter: []string{"othertag"},
|
Filter: []string{"othertag"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
TagPass: []internal_models.TagFilter{
|
TagPass: []models.TagFilter{
|
||||||
internal_models.TagFilter{
|
models.TagFilter{
|
||||||
Name: "goodtag",
|
Name: "goodtag",
|
||||||
Filter: []string{"mytag"},
|
Filter: []string{"mytag"},
|
||||||
},
|
},
|
||||||
|
@ -46,7 +46,7 @@ func TestConfig_LoadSingleInputWithEnvVars(t *testing.T) {
|
||||||
IsActive: true,
|
IsActive: true,
|
||||||
}
|
}
|
||||||
assert.NoError(t, filter.CompileFilter())
|
assert.NoError(t, filter.CompileFilter())
|
||||||
mConfig := &internal_models.InputConfig{
|
mConfig := &models.InputConfig{
|
||||||
Name: "memcached",
|
Name: "memcached",
|
||||||
Filter: filter,
|
Filter: filter,
|
||||||
Interval: 10 * time.Second,
|
Interval: 10 * time.Second,
|
||||||
|
@ -66,19 +66,19 @@ func TestConfig_LoadSingleInput(t *testing.T) {
|
||||||
memcached := inputs.Inputs["memcached"]().(*memcached.Memcached)
|
memcached := inputs.Inputs["memcached"]().(*memcached.Memcached)
|
||||||
memcached.Servers = []string{"localhost"}
|
memcached.Servers = []string{"localhost"}
|
||||||
|
|
||||||
filter := internal_models.Filter{
|
filter := models.Filter{
|
||||||
NameDrop: []string{"metricname2"},
|
NameDrop: []string{"metricname2"},
|
||||||
NamePass: []string{"metricname1"},
|
NamePass: []string{"metricname1"},
|
||||||
FieldDrop: []string{"other", "stuff"},
|
FieldDrop: []string{"other", "stuff"},
|
||||||
FieldPass: []string{"some", "strings"},
|
FieldPass: []string{"some", "strings"},
|
||||||
TagDrop: []internal_models.TagFilter{
|
TagDrop: []models.TagFilter{
|
||||||
internal_models.TagFilter{
|
models.TagFilter{
|
||||||
Name: "badtag",
|
Name: "badtag",
|
||||||
Filter: []string{"othertag"},
|
Filter: []string{"othertag"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
TagPass: []internal_models.TagFilter{
|
TagPass: []models.TagFilter{
|
||||||
internal_models.TagFilter{
|
models.TagFilter{
|
||||||
Name: "goodtag",
|
Name: "goodtag",
|
||||||
Filter: []string{"mytag"},
|
Filter: []string{"mytag"},
|
||||||
},
|
},
|
||||||
|
@ -86,7 +86,7 @@ func TestConfig_LoadSingleInput(t *testing.T) {
|
||||||
IsActive: true,
|
IsActive: true,
|
||||||
}
|
}
|
||||||
assert.NoError(t, filter.CompileFilter())
|
assert.NoError(t, filter.CompileFilter())
|
||||||
mConfig := &internal_models.InputConfig{
|
mConfig := &models.InputConfig{
|
||||||
Name: "memcached",
|
Name: "memcached",
|
||||||
Filter: filter,
|
Filter: filter,
|
||||||
Interval: 5 * time.Second,
|
Interval: 5 * time.Second,
|
||||||
|
@ -113,19 +113,19 @@ func TestConfig_LoadDirectory(t *testing.T) {
|
||||||
memcached := inputs.Inputs["memcached"]().(*memcached.Memcached)
|
memcached := inputs.Inputs["memcached"]().(*memcached.Memcached)
|
||||||
memcached.Servers = []string{"localhost"}
|
memcached.Servers = []string{"localhost"}
|
||||||
|
|
||||||
filter := internal_models.Filter{
|
filter := models.Filter{
|
||||||
NameDrop: []string{"metricname2"},
|
NameDrop: []string{"metricname2"},
|
||||||
NamePass: []string{"metricname1"},
|
NamePass: []string{"metricname1"},
|
||||||
FieldDrop: []string{"other", "stuff"},
|
FieldDrop: []string{"other", "stuff"},
|
||||||
FieldPass: []string{"some", "strings"},
|
FieldPass: []string{"some", "strings"},
|
||||||
TagDrop: []internal_models.TagFilter{
|
TagDrop: []models.TagFilter{
|
||||||
internal_models.TagFilter{
|
models.TagFilter{
|
||||||
Name: "badtag",
|
Name: "badtag",
|
||||||
Filter: []string{"othertag"},
|
Filter: []string{"othertag"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
TagPass: []internal_models.TagFilter{
|
TagPass: []models.TagFilter{
|
||||||
internal_models.TagFilter{
|
models.TagFilter{
|
||||||
Name: "goodtag",
|
Name: "goodtag",
|
||||||
Filter: []string{"mytag"},
|
Filter: []string{"mytag"},
|
||||||
},
|
},
|
||||||
|
@ -133,7 +133,7 @@ func TestConfig_LoadDirectory(t *testing.T) {
|
||||||
IsActive: true,
|
IsActive: true,
|
||||||
}
|
}
|
||||||
assert.NoError(t, filter.CompileFilter())
|
assert.NoError(t, filter.CompileFilter())
|
||||||
mConfig := &internal_models.InputConfig{
|
mConfig := &models.InputConfig{
|
||||||
Name: "memcached",
|
Name: "memcached",
|
||||||
Filter: filter,
|
Filter: filter,
|
||||||
Interval: 5 * time.Second,
|
Interval: 5 * time.Second,
|
||||||
|
@ -150,7 +150,7 @@ func TestConfig_LoadDirectory(t *testing.T) {
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
ex.SetParser(p)
|
ex.SetParser(p)
|
||||||
ex.Command = "/usr/bin/myothercollector --foo=bar"
|
ex.Command = "/usr/bin/myothercollector --foo=bar"
|
||||||
eConfig := &internal_models.InputConfig{
|
eConfig := &models.InputConfig{
|
||||||
Name: "exec",
|
Name: "exec",
|
||||||
MeasurementSuffix: "_myothercollector",
|
MeasurementSuffix: "_myothercollector",
|
||||||
}
|
}
|
||||||
|
@ -169,7 +169,7 @@ func TestConfig_LoadDirectory(t *testing.T) {
|
||||||
pstat := inputs.Inputs["procstat"]().(*procstat.Procstat)
|
pstat := inputs.Inputs["procstat"]().(*procstat.Procstat)
|
||||||
pstat.PidFile = "/var/run/grafana-server.pid"
|
pstat.PidFile = "/var/run/grafana-server.pid"
|
||||||
|
|
||||||
pConfig := &internal_models.InputConfig{Name: "procstat"}
|
pConfig := &models.InputConfig{Name: "procstat"}
|
||||||
pConfig.Tags = make(map[string]string)
|
pConfig.Tags = make(map[string]string)
|
||||||
|
|
||||||
assert.Equal(t, pstat, c.Inputs[3].Input,
|
assert.Equal(t, pstat, c.Inputs[3].Input,
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package internal_models
|
package models
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package internal_models
|
package models
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package internal_models
|
package models
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"time"
|
"time"
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package internal_models
|
package models
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"log"
|
"log"
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package internal_models
|
package models
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
Loading…
Reference in New Issue