# Can filebeat's callback method \`Publish(\_ context.Context, batch publisher.Batch) error\` batch events belong to one file

**URL:** <https://discuss.elastic.co/t/can-filebeats-callback-method-publish-context-context-batch-publisher-batch-error-batch-events-belong-to-one-file/279687>\
**Category:** Beats\
**Tags:** filebeat\
**Created:** [July 27, 2021, 6:37am UTC](https://discuss.elastic.co/t/can-filebeats-callback-method-publish-context-context-batch-publisher-batch-error-batch-events-belong-to-one-file/279687 "2021-07-27T06:37:17Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![shoothzj](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/shoothzj/32/88813_2.png) [@shoothzj](https://discuss.elastic.co/u/shoothzj)\
**Post date:** [July 27, 2021, 6:37am UTC](https://discuss.elastic.co/t/can-filebeats-callback-method-publish-context-context-batch-publisher-batch-error-batch-events-belong-to-one-file/279687/1 "2021-07-27T06:37:17Z")

</div>

Can filebeat's callback method `Publish(_ context.Context, batch publisher.Batch) error` batch events belong to one file.  
For example, harvesting three log `a.log`, `b.log`, `c.log`.Call the method with param `Batch` only file contents that belong to one of `a.log`, `b.log` and `c.log`

---

<div class="post-metadata">

**Author:** ![ChrsMark](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/chrsmark/32/55858_2.png) [@ChrsMark](https://discuss.elastic.co/u/ChrsMark)\
**Post date:** [July 27, 2021, 9:03am UTC](https://discuss.elastic.co/t/can-filebeats-callback-method-publish-context-context-batch-publisher-batch-error-batch-events-belong-to-one-file/279687/2 "2021-07-27T09:03:40Z")

</div>

Filbeat creates inputs/streams per file, so events will be grouped/batched per file.

---

<div class="post-metadata">

**Author:** ![shoothzj](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/shoothzj/32/88813_2.png) [@shoothzj](https://discuss.elastic.co/u/shoothzj)\
**Post date:** [July 27, 2021, 10:57am UTC](https://discuss.elastic.co/t/can-filebeats-callback-method-publish-context-context-batch-publisher-batch-error-batch-events-belong-to-one-file/279687/3 "2021-07-27T10:57:45Z")

</div>

Thanks for your reply. Did you mean that although the Event in `Publish(_ context.Context, batch publisher.Batch)`'s batch, both have their own metadata.  
But they are exactly from one file?

Thank you very much.

---

<div class="post-metadata">

**Author:** ![shoothzj](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/shoothzj/32/88813_2.png) [@shoothzj](https://discuss.elastic.co/u/shoothzj)\
**Post date:** [August 11, 2021, 12:22am UTC](https://discuss.elastic.co/t/can-filebeats-callback-method-publish-context-context-batch-publisher-batch-error-batch-events-belong-to-one-file/279687/4 "2021-08-11T00:22:21Z")

</div>

@ChrsMark Could you please take a look, thank you

---

<div class="post-metadata">

**Author:** ![ChrsMark](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/chrsmark/32/55858_2.png) [@ChrsMark](https://discuss.elastic.co/u/ChrsMark)\
**Post date:** [September 3, 2021, 8:42am UTC](https://discuss.elastic.co/t/can-filebeats-callback-method-publish-context-context-batch-publisher-batch-error-batch-events-belong-to-one-file/279687/5 "2021-09-03T08:42:13Z")

</div>

Hey,

filebeat internally uses an internal queue ([Configure the internal queue | Filebeat Reference [7.14] | Elastic](https://www.elastic.co/guide/en/beats/filebeat/current/configuring-internal-queue.html)), however I don't think that you can access the `batch` variable through configuration.

To the best of my knowledge the queue is common for a filebeat's process and hence once the queue has enough events to send the batch will be sent. Hope that helps. If you have a more specific problem to solve then maybe we can help.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [October 1, 2021, 10:42am UTC](https://discuss.elastic.co/t/can-filebeats-callback-method-publish-context-context-batch-publisher-batch-error-batch-events-belong-to-one-file/279687/6 "2021-10-01T10:42:54Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
