Skip to content

Commit 07e48bc

Browse files
committed
added decode_aws to api.md plus other reviewer comments
1 parent 4a62eb8 commit 07e48bc

File tree

4 files changed

+14
-6
lines changed

4 files changed

+14
-6
lines changed

docs/api.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,13 @@ Following is the supported API format for the netflow collector:
2525
hostName: the hostname to listen on
2626
port: the port number to listen on
2727
</pre>
28+
## Aws ingest API
29+
Following is the supported API format for Aws flow entries:
30+
31+
<pre>
32+
aws:
33+
fields: list of aws flow log fields
34+
</pre>
2835
## Transform Generic API
2936
Following is the supported API format for generic transformations:
3037

pkg/api/api.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ const TagEnum = "enum"
2626
type API struct {
2727
PromEncode PromEncode `yaml:"prom" doc:"## Prometheus encode API\nFollowing is the supported API format for prometheus encode:\n"`
2828
IngestCollector IngestCollector `yaml:"collector" doc:"## Ingest collector API\nFollowing is the supported API format for the netflow collector:\n"`
29+
EncodeAws EncodeAws `yaml:"aws" doc:"## Aws ingest API\nFollowing is the supported API format for Aws flow entries:\n"`
2930
TransformGeneric TransformGeneric `yaml:"generic" doc:"## Transform Generic API\nFollowing is the supported API format for generic transformations:\n"`
3031
TransformNetwork TransformNetwork `yaml:"network" doc:"## Transform Network API\nFollowing is the supported API format for network transformations:\n"`
3132
}

pkg/api/decode_aws.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@
1717

1818
package api
1919

20-
type EncodeAwsStruct struct {
20+
type EncodeAws struct {
2121
Fields []string `yaml:"fields" doc:"list of aws flow log fields"`
2222
}

pkg/pipeline/decode/decode_aws.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,16 +53,16 @@ func (c *decodeAws) Decode(in []interface{}) []config.GenericMap {
5353
out := make([]config.GenericMap, 0)
5454
nItems := len(in)
5555
log.Debugf("nItems = %d", nItems)
56-
for i, line := range in {
56+
for lineNum, line := range in {
5757
lineSlice := strings.Fields(line.(string))
5858
nFields := len(lineSlice)
5959
if nFields != len(c.keyTags) {
60-
log.Errorf("decodeAws Decode: wrong number of fields in line %d", i+1)
60+
log.Errorf("decodeAws Decode: wrong number of fields in line %d", lineNum+1)
6161
continue
6262
}
6363
record := make(config.GenericMap)
64-
for i := 0; i < nFields; i++ {
65-
record[c.keyTags[i]] = lineSlice[i]
64+
for fieldNum := 0; fieldNum < nFields; fieldNum++ {
65+
record[c.keyTags[fieldNum]] = lineSlice[fieldNum]
6666
}
6767
log.Debugf("record = %v", record)
6868
out = append(out, record)
@@ -78,7 +78,7 @@ func NewDecodeAws() (Decoder, error) {
7878
fieldsString := config.Opt.PipeLine.Decode.Aws
7979
log.Debugf("fieldsString = %v", fieldsString)
8080
if fieldsString != "" {
81-
var awsFields api.EncodeAwsStruct
81+
var awsFields api.EncodeAws
8282
err := json.Unmarshal([]byte(fieldsString), &awsFields)
8383
if err != nil {
8484
log.Errorf("NewDecodeAws: error in unmarshalling fields: %v", err)

0 commit comments

Comments
 (0)