Skip to content

Commit

Permalink
feat: add example with processors (#111)
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolasparada authored Oct 10, 2024
1 parent 278ad25 commit dc00c3a
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package fluentbitconfig
import (
"bytes"
"encoding/json"
"fmt"
"os"
"path/filepath"
"strings"
Expand Down Expand Up @@ -415,3 +416,51 @@ func TestConfig_Validate_JSON(t *testing.T) {
})
}
}

func Example_configWithProcessors() {
conf := Config{
Pipeline: Pipeline{
Inputs: Plugins{
Plugin{
Properties: property.Properties{
{Key: "name", Value: "dummy"},
{Key: "processors", Value: property.Properties{
{Key: "logs", Value: Plugins{
Plugin{
Properties: property.Properties{
{Key: "name", Value: "calyptia"},
{Key: "actions", Value: property.Properties{
{Key: "type", Value: "block_keys"},
{Key: "opts", Value: property.Properties{
{Key: "regex", Value: "star"},
{Key: "regexEngine", Value: "pcre2"},
}},
}},
},
},
}},
}},
},
},
},
},
}
yaml, err := conf.DumpAsYAML()
if err != nil {
panic(err)
}

fmt.Println(yaml)
// Output:
// pipeline:
// inputs:
// - name: dummy
// processors:
// logs:
// - name: calyptia
// actions:
// type: block_keys
// opts:
// regex: star
// regexEngine: pcre2
}

0 comments on commit dc00c3a

Please sign in to comment.