Live: array for Processor, Outputter and Subscriber in channel rule top level (#39677)
This commit is contained in:
@@ -99,27 +99,31 @@ type DevRuleBuilder struct {
|
||||
func (f *DevRuleBuilder) BuildRules(_ context.Context, _ int64) ([]*LiveChannelRule, error) {
|
||||
return []*LiveChannelRule{
|
||||
{
|
||||
Pattern: "plugin/testdata/random-20Hz-stream",
|
||||
Subscriber: NewMultipleSubscriber(
|
||||
NewBuiltinSubscriber(f.ChannelHandlerGetter),
|
||||
NewManagedStreamSubscriber(f.ManagedStream),
|
||||
),
|
||||
Pattern: "plugin/testdata/random-20Hz-stream",
|
||||
Converter: NewJsonFrameConverter(JsonFrameConverterConfig{}),
|
||||
Outputter: NewMultipleOutput(
|
||||
NewManagedStreamOutput(f.ManagedStream),
|
||||
NewRemoteWriteOutput(RemoteWriteConfig{
|
||||
FrameOutputters: []FrameOutputter{
|
||||
NewManagedStreamFrameOutput(f.ManagedStream),
|
||||
NewRemoteWriteFrameOutput(RemoteWriteConfig{
|
||||
Endpoint: os.Getenv("GF_LIVE_REMOTE_WRITE_ENDPOINT"),
|
||||
User: os.Getenv("GF_LIVE_REMOTE_WRITE_USER"),
|
||||
Password: os.Getenv("GF_LIVE_REMOTE_WRITE_PASSWORD"),
|
||||
}),
|
||||
),
|
||||
},
|
||||
Subscribers: []Subscriber{
|
||||
NewBuiltinSubscriber(f.ChannelHandlerGetter),
|
||||
NewManagedStreamSubscriber(f.ManagedStream),
|
||||
},
|
||||
},
|
||||
{
|
||||
Pattern: "stream/testdata/random-20Hz-stream",
|
||||
Processor: NewKeepFieldsProcessor(KeepFieldsProcessorConfig{
|
||||
FieldNames: []string{"Time", "Min", "Max"},
|
||||
}),
|
||||
Outputter: NewManagedStreamOutput(f.ManagedStream),
|
||||
FrameProcessors: []FrameProcessor{
|
||||
NewKeepFieldsFrameProcessor(KeepFieldsFrameProcessorConfig{
|
||||
FieldNames: []string{"Time", "Min", "Max"},
|
||||
}),
|
||||
},
|
||||
FrameOutputters: []FrameOutputter{
|
||||
NewManagedStreamFrameOutput(f.ManagedStream),
|
||||
},
|
||||
},
|
||||
{
|
||||
OrgId: 1,
|
||||
@@ -129,9 +133,11 @@ func (f *DevRuleBuilder) BuildRules(_ context.Context, _ int64) ([]*LiveChannelR
|
||||
}),
|
||||
},
|
||||
{
|
||||
OrgId: 1,
|
||||
Pattern: "stream/influx/input/:rest",
|
||||
Outputter: NewManagedStreamOutput(f.ManagedStream),
|
||||
OrgId: 1,
|
||||
Pattern: "stream/influx/input/:rest",
|
||||
FrameOutputters: []FrameOutputter{
|
||||
NewManagedStreamFrameOutput(f.ManagedStream),
|
||||
},
|
||||
},
|
||||
{
|
||||
OrgId: 1,
|
||||
@@ -140,29 +146,31 @@ func (f *DevRuleBuilder) BuildRules(_ context.Context, _ int64) ([]*LiveChannelR
|
||||
// since there are cases when labels attached to a field, and cases where labels
|
||||
// set in a first frame column (in Influx converter). For example, this will allow
|
||||
// to leave only "total-cpu" data while dropping individual CPUs.
|
||||
Processor: NewKeepFieldsProcessor(KeepFieldsProcessorConfig{
|
||||
FieldNames: []string{"labels", "time", "usage_user"},
|
||||
}),
|
||||
Outputter: NewMultipleOutput(
|
||||
NewManagedStreamOutput(f.ManagedStream),
|
||||
FrameProcessors: []FrameProcessor{
|
||||
NewKeepFieldsFrameProcessor(KeepFieldsFrameProcessorConfig{
|
||||
FieldNames: []string{"labels", "time", "usage_user"},
|
||||
}),
|
||||
},
|
||||
FrameOutputters: []FrameOutputter{
|
||||
NewManagedStreamFrameOutput(f.ManagedStream),
|
||||
NewConditionalOutput(
|
||||
NewNumberCompareCondition("usage_user", "gte", 50),
|
||||
NewRedirectOutput(RedirectOutputConfig{
|
||||
NewFrameNumberCompareCondition("usage_user", "gte", 50),
|
||||
NewRedirectFrameOutput(RedirectOutputConfig{
|
||||
Channel: "stream/influx/input/cpu/spikes",
|
||||
}),
|
||||
),
|
||||
),
|
||||
},
|
||||
},
|
||||
{
|
||||
OrgId: 1,
|
||||
Pattern: "stream/influx/input/cpu/spikes",
|
||||
Outputter: NewManagedStreamOutput(f.ManagedStream),
|
||||
OrgId: 1,
|
||||
Pattern: "stream/influx/input/cpu/spikes",
|
||||
FrameOutputters: []FrameOutputter{NewManagedStreamFrameOutput(f.ManagedStream)},
|
||||
},
|
||||
{
|
||||
OrgId: 1,
|
||||
Pattern: "stream/json/auto",
|
||||
Converter: NewAutoJsonConverter(AutoJsonConverterConfig{}),
|
||||
Outputter: NewManagedStreamOutput(f.ManagedStream),
|
||||
OrgId: 1,
|
||||
Pattern: "stream/json/auto",
|
||||
Converter: NewAutoJsonConverter(AutoJsonConverterConfig{}),
|
||||
FrameOutputters: []FrameOutputter{NewManagedStreamFrameOutput(f.ManagedStream)},
|
||||
},
|
||||
{
|
||||
OrgId: 1,
|
||||
@@ -179,10 +187,14 @@ func (f *DevRuleBuilder) BuildRules(_ context.Context, _ int64) ([]*LiveChannelR
|
||||
},
|
||||
},
|
||||
}),
|
||||
Processor: NewDropFieldsProcessor(DropFieldsProcessorConfig{
|
||||
FieldNames: []string{"value2"},
|
||||
}),
|
||||
Outputter: NewManagedStreamOutput(f.ManagedStream),
|
||||
FrameProcessors: []FrameProcessor{
|
||||
NewDropFieldsFrameProcessor(DropFieldsFrameProcessorConfig{
|
||||
FieldNames: []string{"value2"},
|
||||
}),
|
||||
},
|
||||
FrameOutputters: []FrameOutputter{
|
||||
NewManagedStreamFrameOutput(f.ManagedStream),
|
||||
},
|
||||
},
|
||||
{
|
||||
OrgId: 1,
|
||||
@@ -274,28 +286,28 @@ func (f *DevRuleBuilder) BuildRules(_ context.Context, _ int64) ([]*LiveChannelR
|
||||
},
|
||||
},
|
||||
}),
|
||||
Outputter: NewMultipleOutput(
|
||||
NewManagedStreamOutput(f.ManagedStream),
|
||||
NewRemoteWriteOutput(RemoteWriteConfig{
|
||||
FrameOutputters: []FrameOutputter{
|
||||
NewManagedStreamFrameOutput(f.ManagedStream),
|
||||
NewRemoteWriteFrameOutput(RemoteWriteConfig{
|
||||
Endpoint: os.Getenv("GF_LIVE_REMOTE_WRITE_ENDPOINT"),
|
||||
User: os.Getenv("GF_LIVE_REMOTE_WRITE_USER"),
|
||||
Password: os.Getenv("GF_LIVE_REMOTE_WRITE_PASSWORD"),
|
||||
}),
|
||||
NewChangeLogOutput(f.FrameStorage, ChangeLogOutputConfig{
|
||||
NewChangeLogFrameOutput(f.FrameStorage, ChangeLogOutputConfig{
|
||||
FieldName: "value3",
|
||||
Channel: "stream/json/exact/value3/changes",
|
||||
}),
|
||||
NewChangeLogOutput(f.FrameStorage, ChangeLogOutputConfig{
|
||||
NewChangeLogFrameOutput(f.FrameStorage, ChangeLogOutputConfig{
|
||||
FieldName: "annotation",
|
||||
Channel: "stream/json/exact/annotation/changes",
|
||||
}),
|
||||
NewConditionalOutput(
|
||||
NewMultipleConditionChecker(
|
||||
NewMultipleFrameConditionChecker(
|
||||
ConditionAll,
|
||||
NewNumberCompareCondition("value1", "gte", 3.0),
|
||||
NewNumberCompareCondition("value2", "gte", 3.0),
|
||||
NewFrameNumberCompareCondition("value1", "gte", 3.0),
|
||||
NewFrameNumberCompareCondition("value2", "gte", 3.0),
|
||||
),
|
||||
NewRedirectOutput(RedirectOutputConfig{
|
||||
NewRedirectFrameOutput(RedirectOutputConfig{
|
||||
Channel: "stream/json/exact/condition",
|
||||
}),
|
||||
),
|
||||
@@ -303,34 +315,40 @@ func (f *DevRuleBuilder) BuildRules(_ context.Context, _ int64) ([]*LiveChannelR
|
||||
FieldName: "value4",
|
||||
Channel: "stream/json/exact/value4/state",
|
||||
}),
|
||||
),
|
||||
},
|
||||
},
|
||||
{
|
||||
OrgId: 1,
|
||||
Pattern: "stream/json/exact/value3/changes",
|
||||
Outputter: NewMultipleOutput(
|
||||
NewManagedStreamOutput(f.ManagedStream),
|
||||
NewRemoteWriteOutput(RemoteWriteConfig{
|
||||
FrameOutputters: []FrameOutputter{
|
||||
NewManagedStreamFrameOutput(f.ManagedStream),
|
||||
NewRemoteWriteFrameOutput(RemoteWriteConfig{
|
||||
Endpoint: os.Getenv("GF_LIVE_REMOTE_WRITE_ENDPOINT"),
|
||||
User: os.Getenv("GF_LIVE_REMOTE_WRITE_USER"),
|
||||
Password: os.Getenv("GF_LIVE_REMOTE_WRITE_PASSWORD"),
|
||||
}),
|
||||
),
|
||||
},
|
||||
},
|
||||
{
|
||||
OrgId: 1,
|
||||
Pattern: "stream/json/exact/annotation/changes",
|
||||
Outputter: NewManagedStreamOutput(f.ManagedStream),
|
||||
OrgId: 1,
|
||||
Pattern: "stream/json/exact/annotation/changes",
|
||||
FrameOutputters: []FrameOutputter{
|
||||
NewManagedStreamFrameOutput(f.ManagedStream),
|
||||
},
|
||||
},
|
||||
{
|
||||
OrgId: 1,
|
||||
Pattern: "stream/json/exact/condition",
|
||||
Outputter: NewManagedStreamOutput(f.ManagedStream),
|
||||
OrgId: 1,
|
||||
Pattern: "stream/json/exact/condition",
|
||||
FrameOutputters: []FrameOutputter{
|
||||
NewManagedStreamFrameOutput(f.ManagedStream),
|
||||
},
|
||||
},
|
||||
{
|
||||
OrgId: 1,
|
||||
Pattern: "stream/json/exact/value4/state",
|
||||
Outputter: NewManagedStreamOutput(f.ManagedStream),
|
||||
OrgId: 1,
|
||||
Pattern: "stream/json/exact/value4/state",
|
||||
FrameOutputters: []FrameOutputter{
|
||||
NewManagedStreamFrameOutput(f.ManagedStream),
|
||||
},
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user