File tree Expand file tree Collapse file tree 2 files changed +58
-0
lines changed
Expand file tree Collapse file tree 2 files changed +58
-0
lines changed Original file line number Diff line number Diff line change 1+ # go-ingest-node
2+
3+ ` go-ingest-node ` provides a [ Go data model] [ godoc ] and JSON Schema for
4+ Elasticsearch [ Ingest Node] [ ingest ] pipelines. The model is generated from the
5+ [ elasticsearch-specification] [ spec ] .
6+
7+ [ godoc ] : https://pkg.go.dev/github.com/andrewkroh/go-ingest-node
8+ [ ingest ] : https://www.elastic.co/guide/en/elasticsearch/reference/current/processors.html
9+ [ spec ] : https://github.com/elastic/elasticsearch-specification
10+
11+ The Go types can be used for marshaling to/from JSON and YAML.
12+
13+ The JSON Schema file can be imported into popular editors and IDEs to provide
14+ validation and autocompletion when developing Elasticsearh ingest node
15+ pipelines.
Original file line number Diff line number Diff line change @@ -86,3 +86,46 @@ func TestPipelineJSONUnmarshal(t *testing.T) {
8686 t .Fatal ("expected grok processor" )
8787 }
8888}
89+
90+ func TestPipelineJSONMarshal (t * testing.T ) {
91+ p := & Pipeline {
92+ Description : ptrTo ("Parse Common Log Format." ),
93+ Processors : []ProcessorContainer {
94+ {
95+ Grok : & GrokProcessor {
96+ Description : ptrTo ("Extract fields from 'message'" ),
97+ Field : "message" ,
98+ Patterns : []GrokPattern {
99+ "%{IPORHOST:source.ip}" ,
100+ },
101+ },
102+ },
103+ },
104+ }
105+
106+ want := `{
107+ "description": "Parse Common Log Format.",
108+ "processors": [
109+ {
110+ "grok": {
111+ "description": "Extract fields from 'message'",
112+ "field": "message",
113+ "patterns": [
114+ "%{IPORHOST:source.ip}"
115+ ]
116+ }
117+ }
118+ ]
119+ }`
120+
121+ got , err := json .MarshalIndent (p , "" , " " )
122+ if err != nil {
123+ t .Fatal (err )
124+ }
125+
126+ if string (got ) != want {
127+ t .Fatalf ("want:\n %s got:\n %s" , want , string (got ))
128+ }
129+ }
130+
131+ func ptrTo [T any ](v T ) * T { return & v }
You can’t perform that action at this time.
0 commit comments