From a776641afbddbc796ede233de60962c3ec852690 Mon Sep 17 00:00:00 2001 From: Greg Furman <31275503+gregfurman@users.noreply.github.com> Date: Sun, 1 Sep 2024 21:04:52 +0200 Subject: [PATCH] mongodb: Update docs to reflect input metadata and string interpolation for collections (#109) --- internal/impl/mongodb/input.go | 17 ++++++++++++++++- internal/impl/mongodb/output.go | 2 +- internal/impl/mongodb/processor.go | 2 +- website/docs/components/inputs/mongodb.md | 14 ++++++++++++++ website/docs/components/outputs/mongodb.md | 1 + website/docs/components/processors/mongodb.md | 1 + 6 files changed, 34 insertions(+), 3 deletions(-) diff --git a/internal/impl/mongodb/input.go b/internal/impl/mongodb/input.go index f4b801d88..1bf009e95 100644 --- a/internal/impl/mongodb/input.go +++ b/internal/impl/mongodb/input.go @@ -24,7 +24,22 @@ func mongoConfigSpec() *service.ConfigSpec { Version("1.0.0"). Categories("Services"). Summary("Executes a query and creates a message for each document received."). - Description(`Once the documents from the query are exhausted, this input shuts down, allowing the pipeline to gracefully terminate (or the next input in a [sequence](/docs/components/inputs/sequence) to execute).`). + Description(` +Once the documents from the query are exhausted, this input shuts down, allowing the pipeline to gracefully terminate (or the next input in a [sequence](/docs/components/inputs/sequence) to execute). + +### Metadata + +This input adds the following metadata fields to each message: + +` + "```text" + ` +- mongo_database +- mongo_collection +` + "```" + ` + +You can access these metadata fields using +[function interpolation](/docs/configuration/interpolation#bloblang-queries). + +`). Fields(clientFields()...). Field(service.NewStringField("collection").Description("The collection to select from.")). Field(service.NewStringEnumField("operation", FindInputOperation, AggregateInputOperation). diff --git a/internal/impl/mongodb/output.go b/internal/impl/mongodb/output.go index 0d4a57734..97ca79f64 100644 --- a/internal/impl/mongodb/output.go +++ b/internal/impl/mongodb/output.go @@ -27,7 +27,7 @@ func outputSpec() *service.ConfigSpec { Description(service.OutputPerformanceDocs(true, true)). Fields(clientFields()...). Fields( - service.NewStringField(moFieldCollection). + service.NewInterpolatedStringField(moFieldCollection). Description("The name of the target collection."), outputOperationDocs(OperationUpdateOne), writeConcernDocs(), diff --git a/internal/impl/mongodb/processor.go b/internal/impl/mongodb/processor.go index b9a09a42a..aa299cb09 100644 --- a/internal/impl/mongodb/processor.go +++ b/internal/impl/mongodb/processor.go @@ -28,7 +28,7 @@ func ProcessorSpec() *service.ConfigSpec { Description(""). Fields(clientFields()...). Fields( - service.NewStringField(mpFieldCollection). + service.NewInterpolatedStringField(mpFieldCollection). Description("The name of the target collection."), processorOperationDocs(OperationInsertOne), writeConcernDocs(), diff --git a/website/docs/components/inputs/mongodb.md b/website/docs/components/inputs/mongodb.md index e755478cf..02979f4b2 100644 --- a/website/docs/components/inputs/mongodb.md +++ b/website/docs/components/inputs/mongodb.md @@ -78,6 +78,20 @@ input: Once the documents from the query are exhausted, this input shuts down, allowing the pipeline to gracefully terminate (or the next input in a [sequence](/docs/components/inputs/sequence) to execute). +### Metadata + +This input adds the following metadata fields to each message: + +```text +- mongo_database +- mongo_collection +``` + +You can access these metadata fields using +[function interpolation](/docs/configuration/interpolation#bloblang-queries). + + + ## Fields ### `url` diff --git a/website/docs/components/outputs/mongodb.md b/website/docs/components/outputs/mongodb.md index a96c69e87..d5eb5b07c 100644 --- a/website/docs/components/outputs/mongodb.md +++ b/website/docs/components/outputs/mongodb.md @@ -142,6 +142,7 @@ Default: `""` ### `collection` The name of the target collection. +This field supports [interpolation functions](/docs/configuration/interpolation#bloblang-queries). Type: `string` diff --git a/website/docs/components/processors/mongodb.md b/website/docs/components/processors/mongodb.md index 79e352927..dc944bec4 100644 --- a/website/docs/components/processors/mongodb.md +++ b/website/docs/components/processors/mongodb.md @@ -121,6 +121,7 @@ Default: `""` ### `collection` The name of the target collection. +This field supports [interpolation functions](/docs/configuration/interpolation#bloblang-queries). Type: `string`