-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New segment mongodb #81
base: master
Are you sure you want to change the base?
Conversation
Allows exporting to an external mongoDb. By using capped collections, the disk size used by flowpipeline can be limited to a fixed size
6b30d4f
to
2f61b06
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀
|
||
client, err := mongo.Connect(ctx, options.Client().ApplyURI(segment.mongodbUri)) | ||
if err != nil { | ||
log.Panic(err) // this has already been checked in New |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It could still fail though ;)
if config == nil { | ||
return newsegment, errors.New("missing configuration for segment mongodb") | ||
} | ||
|
||
if config["mongodb_uri"] == "" { | ||
return newsegment, errors.New("mongoDB: mongodb_uri not defined") | ||
} | ||
newsegment.mongodbUri = config["mongodb_uri"] | ||
|
||
if config["database"] == "" { | ||
log.Println("[INFO] mongoDB: no database defined - using default value (flowdata)") | ||
config["database"] = "flowdata" | ||
} | ||
newsegment.databaseName = config["database"] | ||
|
||
if config["collection"] == "" { | ||
log.Println("[INFO] mongoDB: no collection defined - using default value (ringbuffer)") | ||
config["collection"] = "ringbuffer" | ||
} | ||
newsegment.collectionName = config["collection"] | ||
|
||
var ringbufferSize int64 = 10737418240 | ||
if config["max_disk_usage"] == "" { | ||
log.Println("[INFO] mongoDB: no ring buffer size defined - using default value (10GB)") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be time to rethink config parsing or even add some config parsing library in the future. I did not know enough about Go back in the day, but this sure is a lot of manual work.
Allows exporting to an external mongoDb.
By using capped collections, the disk size used by the flowpipeline output can be limited to a fixed size.
Example usage:
config:
mongodb_uri: "mongodb://localhost:27017/"
max_disk_usage: 1 GB
database: "flowmonitoring"
collection: "flowdata"
fields: "SrcAddr,DstAddr"