Skip to content
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

Set up template output plugin that writes to a file. #2

Merged
merged 18 commits into from
Jun 11, 2024

Conversation

davemarco
Copy link
Contributor

@davemarco davemarco commented Jun 5, 2024

Description

Added basic file output plugin. Plugin will serve as a template onto which IR and S3 output functionality will be added.

Plugin

File plugin is based on example stdout plugin provided by fluent-bit. The main file which implements required callbacks is plugins/out_clp_s3/out_clp_s3.go. I made the following changes to enhance functionality

  1. Support for additional user-defined configuration values in config/config.go
  2. Temporary modification so writes to file instead of stdout in plugins/out_clp_s3/flush/flush.go(code will be deleted on next PR)
  3. Basic error handling in internal/utils/error.go

Development aids

In addition to plugin, I added

  • Dockerfile plugins/out_clp_s3/Dockerfile
  • Makefile plugins/out_clp_s3/Makefile

Docker

In addition to plugin, I added a dockerfile so new users/developers can test quickly. The dockerfile first builds the plugin in a go container and then copies the binary to a fluentbit container. The fluentbit container starts fluentbit with the output plugin and writes logs to the current directory using a docker volume.

The repo also contains two example fluent-bit configuration files. plugins/out_clp_s3/fluent-bit.conf is the main configuration file. plugins/out_clp_s3/plugin-config.conf provides the path to plugin binary. Both of these configuration are setup with paths that exists on the docker container, but can be modified for local use (however, modification may break docker setup)

Make

basic makefile to build plugin

Validation performed

I built plugin and tested can write to file locally, and with docker.

@davemarco
Copy link
Contributor Author

davemarco commented Jun 7, 2024

Screen Shot 2024-06-07 at 11 35 37 AM

FYI... Later on I noticed their "example stdout plugin" (which i copied the logic for this PR) can print strings as a byte array. There is no issue with cpu logs where values are ints tested with the configuration in this PR. I have looked into a solution for the next PR.

@davemarco
Copy link
Contributor Author

  • removed error.go and put error handling inline.
  • Swapped makefile with taskfile

Copy link
Member

@davidlion davidlion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try to do a pass on the doc strings + comments. Many are not formatted correctly.

config/config.go Outdated Show resolved Hide resolved
config/config.go Outdated Show resolved Hide resolved
config/config.go Outdated Show resolved Hide resolved
plugins/out_clp_s3/README.md Outdated Show resolved Hide resolved
plugins/out_clp_s3/README.md Outdated Show resolved Hide resolved
plugins/out_clp_s3/flush/flush.go Outdated Show resolved Hide resolved
plugins/out_clp_s3/flush/flush.go Outdated Show resolved Hide resolved
plugins/out_clp_s3/flush/flush.go Outdated Show resolved Hide resolved
plugins/out_clp_s3/flush/flush.go Outdated Show resolved Hide resolved
@davemarco
Copy link
Contributor Author

Try to do a pass on the doc strings + comments. Many are not formatted correctly.

Made updates to comments and doc strings for line wrapping, capitalization and periods

Copy link
Member

@davidlion davidlion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets tweak the title + commit message to:
Set up template output plugin that writes to a file. (#2)

@davemarco davemarco changed the title Setup template output plugin that writes to file Set up template output plugin that writes to a file. Jun 10, 2024
@davidlion davidlion merged commit 6ccee05 into y-scope:main Jun 11, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants