{"id":19534395,"url":"https://github.com/kube-logging/fluent-plugin-label-router","last_synced_at":"2025-04-26T14:35:00.256Z","repository":{"id":39674700,"uuid":"190592043","full_name":"kube-logging/fluent-plugin-label-router","owner":"kube-logging","description":"Fluentd plugin to route records based on Kubernetes labels and namespace","archived":false,"fork":false,"pushed_at":"2024-12-02T12:04:19.000Z","size":49,"stargazers_count":13,"open_issues_count":0,"forks_count":15,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-04-04T14:11:12.062Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Ruby","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/kube-logging.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":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-06-06T14:05:34.000Z","updated_at":"2024-12-02T09:37:52.000Z","dependencies_parsed_at":"2024-06-13T01:19:59.955Z","dependency_job_id":"1674a575-ef24-4560-81c7-1921d99bca91","html_url":"https://github.com/kube-logging/fluent-plugin-label-router","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kube-logging%2Ffluent-plugin-label-router","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kube-logging%2Ffluent-plugin-label-router/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kube-logging%2Ffluent-plugin-label-router/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kube-logging%2Ffluent-plugin-label-router/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kube-logging","download_url":"https://codeload.github.com/kube-logging/fluent-plugin-label-router/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251001334,"owners_count":21520930,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":[],"created_at":"2024-11-11T02:14:13.407Z","updated_at":"2025-04-26T14:35:00.215Z","avatar_url":"https://github.com/kube-logging.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# fluent-plugin-label-router\n\n[Fluentd](https://fluentd.org/) output plugin to route records based on their Kubernetes metadata.\n\n## Installation\n\n### RubyGems\n\n```\n$ gem install fluent-plugin-label-router\n```\n\n### Specific install\n\n```\n$ gem install specific_install \u0026\u0026 gem specific_install -l https://github.com/banzaicloud/fluent-plugin-label-router.git\n```\n\n### Bundler\n\nAdd following line to your Gemfile:\n\n```ruby\ngem \"fluent-plugin-label-router\"\n```\n\nAnd then execute:\n\n```\n$ bundle\n```\n\n## Configuration\n\nThe configuration builds from `\u003croute\u003e` sections. Each `route` section\ncan have several `\u003cmatch\u003e` statement. These statements computed in order and\npositive (or in case of *negate true* negative) results break the evaluation.\nWe can say that the sections are coupled in a **lazy evaluation OR**.\n\n```\n\u003cmatch example.tag**\u003e\n  @type label_router\n  \u003croute\u003e\n     ...\n  \u003c/route\u003e\n  \u003croute\u003e\n    \u003cmatch\u003e\n      ...\n    \u003c/match\u003e\n    \u003cmatch\u003e #Exclude\n      negate true\n      ...\n    \u003c/match\u003e\n  \u003c/route\u003e\n\u003c/match\u003e\n```\n\nConfiguration reference\n\n| Parameter     | Description                                                                                            | Type    | Default |\n|---------------|--------------------------------------------------------------------------------------------------------|---------|---------|\n| emit_mode     | Emit mode. If `batch`, the plugin will emit events per labels matched. Enum: record, batch             | enum    | batch   |\n| sticky_tags   | Sticky tags will match only one record from an event stream. The same tag will be treated the same way | bool    | true    |\n| default_route | If defined all non-matching record passes to this label.                                               | string  |  \"\"     |\n| default_tag   | If defined all non-matching record rewrited to this tag. (Can be used with label simoultanesly)        | string  |  \"\"     |\n| \\\u003croute\\\u003e     | Route the log if match with parameters defined                                                         | []route | nil     |\n\n#### \\\u003croute\\\u003e\n| Parameter     | Description                                                                                            | Type    | Default |\n|---------------|--------------------------------------------------------------------------------------------------------|---------|---------|\n| @label        | Route the matching record to the given `label`                                                         | string  | \"\"      |\n| tag           | Tag the matching record to the given `tag`                                                             | string  | \"\"      |\n| \\\u003cmatch\\\u003e     | List of match statements. Repeatable.                                                                  | []match | nil     |\n\n\n#### \\\u003cmatch\\\u003e\n| Parameter        | Description                                                                                           | Type     | Default  |\n|------------------|-------------------------------------------------------------------------------------------------------|----------|----------|\n| labels           | Label definition to match record. Example: `app:nginx`                                                | Hash     | nil      |\n| namespaces       | Comma separated list of namespaces. Ignored if left empty.                                            | []string | nil      |\n| namespaces_regex | Comma separated list of regex for namespaces match. Ignored if left empty.                            | []string | nil      |\n| namespace_labels | Label definition of the namespace a record originates. Example: `kubernetes.io/metadata.name=default` | Hash     | nil      |\n| hosts            | Comma separated list of hosts. Ignored if left empty.                                                 | []string | nil      |\n| container_names  | Comma separated list of container names. Ignored if left empty.                                       | []string | nil      |\n| negate           | Negate the selector meaning to exclude matches                                                        | bool     | false    |\n\n## Rules of thumb\n\n1. Defining more than one namespace in `namespaces` inside a `match` statement\nwill check whether any of that namespaces matches.\n\n2. Using `sticky_tags` means that only the **first** record will be analysed per `tag`.\nKeep that in mind if you are ingesting traffic that is not unique on a per tag bases.\nFluentd and fluent-bit tail logs from Kubernetes are unique per container.\n\n3. The plugin does not check if the configuration is valid so be careful to not define\n statements like identical `match` statement with negate because the negate rule will never\n be evaluated.\n\n## Examples\n\n### 1. Route specific `labels` and `namespaces` to `@label` and new `tag`\nConfiguration to re-tag and re-label all logs from `default` namespace with label `app=nginx` and `env=dev`.\n```\n\u003cmatch example.tag**\u003e\n  @type label_router\n  \u003croute\u003e\n    @label @NGINX\n    tag new_tag\n    \u003cmatch\u003e\n      labels app:nginx,env:dev\n      namespaces default\n    \u003c/match\u003e\n  \u003c/route\u003e\n\u003c/match\u003e\n```\n\n### 2. Exclude specific `labels` and `namespaces`\nConfiguration to re-tag and re-label all logs that **not** from `default` namespace **and not** have labels `app=nginx` and `env=dev`\n```\n\u003cmatch example.tag**\u003e\n  @type label_router\n  \u003croute\u003e\n    @label @NGINX\n    tag new_tag\n    \u003cmatch\u003e\n      negate true\n      labels app:nginx,env:dev\n      namespaces default\n    \u003c/match\u003e\n  \u003c/route\u003e\n\u003c/match\u003e\n```\n\n#### Example records\n\nInput\n```ruby\n@label = \"\"; tag = \"raw.input\"; {\"log\" =\u003e \"\", \"kubernetes\" =\u003e { \"namespace_name\" =\u003e \"default\", \"labels\" =\u003e  {\"app\" =\u003e \"nginx\", \"env\" =\u003e \"dev\" } } }\n@label = \"\"; tag = \"raw.input\"; {\"log\" =\u003e \"\", \"kubernetes\" =\u003e { \"namespace_name\" =\u003e \"kube-system\", \"labels\" =\u003e  {\"app\" =\u003e \"tiller\" } } }\n\n```\n\nOutput\n```ruby\n@label = \"@NGINX\"; tag = \"new_tag\"; {\"log\" =\u003e \"\", \"kubernetes\" =\u003e { \"namespace_name\" =\u003e \"default\", \"labels\" =\u003e  {\"app\" =\u003e \"nginx\" } } }\nnil\n```\n### 3. Both `labels` and `namespace` are optional\nOnly `labels`\n```\n\u003cmatch example.tag**\u003e\n  @type label_router\n  \u003croute\u003e\n    @label @NGINX\n    tag new_tag\n    \u003cmatch\u003e\n      labels app:nginx\n    \u003c/match\u003e\n  \u003c/route\u003e\n\u003c/match\u003e\n```\nOnly `namespace`\n```\n\u003cmatch example.tag**\u003e\n  @type label_router\n  \u003croute\u003e\n    @label @NGINX\n    tag new_tag\n    \u003cmatch\u003e\n      namespaces default\n    \u003c/match\u003e\n  \u003c/route\u003e\n\u003c/match\u003e\n```\nRewrite all\n```\n\u003cmatch example.tag**\u003e\n  @type label_router\n  \u003cmatch\u003e\n    @label @NGINX\n    tag new_tag\n  \u003c/match\u003e\n\u003c/match\u003e\n```\n\n### 4. One of `@label` or `tag` configuration should be specified\nIf you don't rewrite either of them fluent will **likely to crash** because it will reprocess the same messages again.\n\n### 5. Default route/tag\n\nUse `default_label` and/or `default_tag` to route non matching records.\n\n```\n\u003cmatch example.tag**\u003e\n  @type label_router\n  default_route @default_sink\n  \u003croute\u003e\n     ...\n  \u003c/route\u003e\n\u003c/match\u003e\n```\n\n### 6. Use of namespaces_regex\n\nConfiguration to re-tag and re-label all logs from namespaces_regex which match regex .*-system$\n\n```\n\u003cmatch example.tag**\u003e\n  @type label_router\n  \u003croute\u003e\n    @label SYSTEM_NAMESPACE\n    tag new_tag\n    \u003cmatch\u003e\n      namespaces_regex .*-system$\n    \u003c/match\u003e\n  \u003c/route\u003e\n\u003c/match\u003e\n```\n\n## Copyright\n\n* Copyright(c) 2019- Banzai Cloud\n* License\n  * Apache License, Version 2.0\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkube-logging%2Ffluent-plugin-label-router","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkube-logging%2Ffluent-plugin-label-router","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkube-logging%2Ffluent-plugin-label-router/lists"}