{"id":42462836,"url":"https://github.com/chronosphereio/calyptia-plugin","last_synced_at":"2026-01-28T09:30:13.736Z","repository":{"id":38457988,"uuid":"470906512","full_name":"chronosphereio/calyptia-plugin","owner":"chronosphereio","description":"A Golang Package to build fluent-bit input plugins","archived":false,"fork":false,"pushed_at":"2025-09-23T22:17:13.000Z","size":404,"stargazers_count":9,"open_issues_count":7,"forks_count":2,"subscribers_count":9,"default_branch":"main","last_synced_at":"2025-09-24T00:15:04.469Z","etag":null,"topics":["fluentbit","golang","golang-library","plugins"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/chronosphereio.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2022-03-17T08:25:12.000Z","updated_at":"2025-09-23T22:17:16.000Z","dependencies_parsed_at":"2023-10-11T06:57:20.814Z","dependency_job_id":"874c4461-9f52-4094-8d44-21d64aa7ad56","html_url":"https://github.com/chronosphereio/calyptia-plugin","commit_stats":null,"previous_names":["calyptia/fluent-bit-go","chronosphereio/calyptia-plugin","calyptia/plugin"],"tags_count":23,"template":false,"template_full_name":null,"purl":"pkg:github/chronosphereio/calyptia-plugin","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chronosphereio%2Fcalyptia-plugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chronosphereio%2Fcalyptia-plugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chronosphereio%2Fcalyptia-plugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chronosphereio%2Fcalyptia-plugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chronosphereio","download_url":"https://codeload.github.com/chronosphereio/calyptia-plugin/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chronosphereio%2Fcalyptia-plugin/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28843917,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-28T07:39:25.367Z","status":"ssl_error","status_checked_at":"2026-01-28T07:39:24.487Z","response_time":57,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["fluentbit","golang","golang-library","plugins"],"created_at":"2026-01-28T09:30:10.803Z","updated_at":"2026-01-28T09:30:13.730Z","avatar_url":"https://github.com/chronosphereio.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Fluent-bit plugin\n\n[![Go Reference](https://pkg.go.dev/badge/github.com/calyptia/plugin.svg)](https://pkg.go.dev/github.com/calyptia/plugin)\n[![codecov](https://codecov.io/gh/calyptia/plugin/branch/main/graph/badge.svg?token=VP4Y8DAHGZ)](https://app.codecov.io/gh/chronosphereio/calyptia-plugin)\n\nThis repository contains the required Golang interfaces and data types\nrequired to create [Fluent bit](https://fluentbit.io) Golang plugins.\n\n## Architectural overview\n\nPlugins are implemented via proxy callbacks, fluent-bit implements a generic proxy\napproach that can be used to load and invoke DSO object callbacks.\n\nThe following is the state machine of callbacks.\n\n```mermaid\nstateDiagram-v2\n    state \"fluent-bit engine starts\" as start\n    start --\u003e FLBPluginRegister\n    FLBPluginRegister --\u003e FLBPluginInit : Locate configured plugins\n    FLBPluginInit --\u003e FLB_ERR\n    FLB_ERR --\u003e FLBPluginUnregister\n    FLBPluginInit --\u003e FLB_OK\n    FLB_OK --\u003e instance\n\n    state \"plugin instance\" as instance\n    instance --\u003e FLBPluginInputCallback: collect() data\n    FLBPluginInputCallback --\u003e WriteMsgPack\n\n    instance --\u003e FLBPluginOutputCallback : Flush(data)\n    FLBPluginOutputCallback --\u003e WriteMsgPack\n    WriteMsgPack --\u003e [*]\n```\n\n## Writing a plugin\n\nPlugins can be written for output and input processing.\n\nAs an example, the following are the minimum steps for writing an input plugin.\nDeclaring a plugin requires to implement the [InputPlugin interface](./plugin.go).\nExplicitly defining the 2 methods *Init* and *Collect*:\n\n```go\npackage main\n\nimport (\n \"context\"\n \"errors\"\n \"time\"\n\n \"github.com/calyptia/plugin\"\n)\n\n// Plugin needs to be registered as an input type plugin in the initialisation phase\nfunc init() {\n plugin.RegisterInput(\"go-test-input-plugin\", \"Golang input plugin for testing\", \u0026dummyPlugin{})\n}\n\ntype dummyPlugin struct {\n foo string\n}\n\n// Init An instance of the configuration loader will be passed to the Init method so all the required\n// configuration entries can be retrieved within the plugin context.\nfunc (plug *dummyPlugin) Init(ctx context.Context, fbit *plugin.Fluentbit) error {\n plug.foo = fbit.Conf.String(\"foo\")\n return nil\n}\n\n// Collect this method will be invoked by the fluent-bit engine after the initialisation is successful\n// this method can lock as each plugin its implemented in its own thread. Be aware that the main context\n// can be cancelled at any given time, so handle the context properly within this method.\n// The *ch* channel parameter, is a channel handled by the runtime that will receive messages from the plugin\n// collection, make sure to validate channel closure and to follow the `plugin.Message` struct for messages\n// generated by plugins.\nfunc (plug dummyPlugin) Collect(ctx context.Context, ch chan\u003c- plugin.Message) error {\n tick := time.NewTicker(time.Second)\n\n for {\n  select {\n  case \u003c-ctx.Done():\n   err := ctx.Err()\n   if err != nil \u0026\u0026 !errors.Is(err, context.Canceled) {\n    return err\n   }\n\n   return nil\n  case \u003c-tick.C:\n   ch \u003c- plugin.Message{\n    Time: time.Now(),\n    Record: map[string]string{\n     \"message\": \"hello from go-test-input-plugin\",\n     \"foo\":     plug.foo,\n    },\n   }\n  }\n }\n}\n\nfunc main() {}\n\n```\n\n## Adding metrics\n\nPlugin can share their metrics over fluent-bit proxy interface.\nAs an example, the following are the minimum steps for sharing plugin's metrics,\nUsing a [metric interface](./metric/metric.go) to implement the plugin's metrics.\n\n```go\npackage main\n\nimport (\n \"context\"\n \"errors\"\n \"time\"\n\n \"github.com/calyptia/plugin\"\n \"github.com/calyptia/plugin/metric\"\n)\n\ntype dummyPlugin struct {\n counterExample metric.Counter\n}\n\nfunc (plug *dummyPlugin) Init(ctx context.Context, fbit *plugin.Fluentbit) error {\n plug.counterExample = fbit.Metrics.NewCounter(\"example_metric_total\", \"Total number of example metrics\", \"go-test-input-plugin\")\n return nil\n}\n\nfunc (plug dummyPlugin) Collect(ctx context.Context, ch chan\u003c- plugin.Message) error {\n tick := time.NewTicker(time.Second)\n\n for {\n  select {\n  case \u003c-ctx.Done():\n   err := ctx.Err()\n   if err != nil \u0026\u0026 !errors.Is(err, context.Canceled) {\n    return err\n   }\n\n   return nil\n  case \u003c-tick.C:\n   plug.counterExample.Add(1)\n\n   ch \u003c- plugin.Message{\n    Time: time.Now(),\n    Record: map[string]string{\n     \"message\": \"hello from go-test-input-plugin\",\n     \"foo\":     plug.foo,\n    },\n   }\n  }\n }\n}\n\nfunc main() {}\n```\n\n### Building a plugin\n\nA plugin can be built locally using go build as:\n\n```bash\ngo build -trimpath -buildmode c-shared -o ./bin/go-test-input-plugin.so .\n```\n\nOr compiled to linux/amd64 from another machine using [zig](https://ziglang.org/learn/overview/#zig-is-also-a-c-compiler)\n*(Example working on darwin/arm64)*.\n\n```bash\nCGO_ENABLED=1 \\\nGOOS=linux \\\nGOARCH=amd64 \\\nCC=\"zig cc -target x86_64-linux-gnu -isystem /usr/include -L/usr/lib/x86_64-linux-gnu\" \\\nCXX=\"zig c++ -target x86_64-linux-gnu -isystem /usr/include -L/usr/lib/x86_64-linux-gnu\" \\\ngo build -buildmode=c-shared -trimpath -o ./my-plugin-linux-amd64.so ./...\n```\n\nOr using a Dockerfile as follows:\n\n```dockerfile\nFROM golang:latest AS builder\n\nWORKDIR /fluent-bit\n\nCOPY go.mod .\nCOPY go.sum .\n\nRUN go mod download\nRUN go mod verify\n\nCOPY . .\n\nRUN go build -trimpath -buildmode c-shared -o ./bin/go-test-input-plugin.so .\n\nFROM ghcr.io/calyptia/enterprise/advanced:main\n\nCOPY --from=builder /fluent-bit/bin/go-test-input-plugin.so /fluent-bit/etc/\n\nENTRYPOINT [ \"/fluent-bit/bin/fluent-bit\" ]\nCMD [ \"/fluent-bit/bin/fluent-bit\", \"-c\", \"/fluent-bit/etc/fluent-bit.conf\" ]\n```\n\nThen create a fluent-bit.conf as follows:\n\n```ini\n[SERVICE]\n    flush           1\n    log_level       info\n    plugins_file    /fluent-bit/etc/plugins.conf\n\n[INPUT]\n    Name go-test-input-plugin\n    Tag  test-input\n    foo  bar\n```\n\nAlso a plugins.conf definition has to be provided, as follows:\n\n```ini\n[PLUGINS]\n    Path /fluent-bit/etc/go-test-input-plugin.so\n```\n\nRun the docker container as follows:\n\n```shell\ndocker build -t my-fluent-bit-plugin:main .\ndocker run --platform=linux/amd64 -v $(pwd)/fluent-bit.conf:/fluent-bit/etc/fluent-bit.conf:ro -v $(pwd)/plugins.conf:/fluent-bit/etc/plugins.conf:ro my-fluent-bit-plugin:main\n```\n\nFor further examples, please check the [examples](./examples) or [testdata](./testdata) folders.\n\n## Running tests\n\nRunning the local tests must be doable with:\n\n```shell\ngo test -v ./...\n```\n\n## Contributing\n\nPlease feel free to open PR(s) on this repository and to report any bugs of feature requests\non the GitHub issues page.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchronosphereio%2Fcalyptia-plugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchronosphereio%2Fcalyptia-plugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchronosphereio%2Fcalyptia-plugin/lists"}