This repository was archived by the owner on Oct 7, 2025. It is now read-only.
Repository navigation
New segment mongodb - #81
Merged
Merged
Conversation
Allows exporting to an external mongoDb. By using capped collections, the disk size used by flowpipeline can be limited to a fixed size
ynHuber
force-pushed
the
mongodb_output
branch
from
November 22, 2024 09:44
6b30d4f to
2f61b06
Compare
debugloop
approved these changes
Dec 7, 2024
|
|
||
| client, err := mongo.Connect(ctx, options.Client().ApplyURI(segment.mongodbUri)) | ||
| if err != nil { | ||
| log.Panic(err) // this has already been checked in New |
Collaborator
There was a problem hiding this comment.
It could still fail though ;)
Comment on lines
+102
to
+125
| 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)") |
Collaborator
There was a problem hiding this comment.
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.
Merged
ynHuber
added a commit
that referenced
this pull request
Feb 3, 2025
New Major Version v2 ### Maintenance - Moved GitHub orgs from bwNetFlow to BelWue @9er #89 - Upgraded golang version to 1.23.2 ### Bug fixes - waitgroup in lumberjack segment. (@JustKiddingCode #79) - vacuum_interval for prometheus Export (@ynHuber #85) ### New segments - diskbuffer (@JustKiddingCode #78) - mongodb (@ynHuber #81) ### Breaking Changes: - Protobuffer upgrade to match changes [introduced in goflow2 v2.2.1](netsampler/goflow2@3326554) (@ynHuber #86)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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"