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

Unable to use Filebeat service due to hard-coded default. #280535

Closed
fifthecho opened this issue Jan 12, 2024 · 5 comments
Closed

Unable to use Filebeat service due to hard-coded default. #280535

fifthecho opened this issue Jan 12, 2024 · 5 comments
Labels
0.kind: bug Something is broken 6.topic: module system About "NixOS" module system internals

Comments

@fifthecho
Copy link

Describe the bug

The Filebeat service definition has a hardcoded default of an output to an elasticsearch instance on localhost. If I want to have a filebeat output to logstash, however, the Filebeat service only supports one output and with my configured output and the default, the service will not start.

Steps To Reproduce

Steps to reproduce the behavior:
A configuration of:

services.filebeat = {
    enable = true;
    settings = {
      output = {
        logstash = {
          hosts = ["logstash5044"];
        };
      };
    };
    inputs = {
      journald.id = "everything";
      log = {
        enabled = true;
        paths = [
          "/var/log/*.log"
        ];
      };
    };

Generates the following file:

{
  "filebeat": {
    "inputs": [
      {
        "id": "everything",
        "type": "journald"
      },
      {
        "enabled": true,
        "paths": [
          "/var/log/*.log"
        ],
        "type": "log"
      }
    ],
    "modules": []
  },
  "output": {
    "elasticsearch": {
      "hosts": [
        "127.0.0.1:9200"
      ]
    },
    "logstash": {
      "hosts": [
        "logstash:5044"
      ]
    }
  }
}

and a config of

services.filebeat = {
    enable = true;
    settings = {
      output = {
        logstash = {
          hosts = ["logstash:5044"];
        };
        elasticsearch = {
          hosts = [];
        }
      };
    };
    inputs = {
      journald.id = "everything";
      log = {
        enabled = true;
        paths = [
          "/var/log/*.log"
        ];
      };
    };
  };

generates a config of

{
  "filebeat": {
    "inputs": [
      {
        "id": "everything",
        "type": "journald"
      },
      {
        "enabled": true,
        "paths": [
          "/var/log/*.log"
        ],
        "type": "log"
      }
    ],
    "modules": []
  },
  "output": {
    "elasticsearch": {
      "hosts": []
    },
    "logstash": {
      "hosts": [
        "logstash:5044"
      ]
    }
  }
}

Neither is a config that Filebeats will accept with an error of
Exiting: error unpacking config data: more than one namespace configured accessing 'output' (source:'/var/lib/filebeat/filebeat.yml')

Expected behavior

There shouldn't be a default so that a valid config file can be generated with an output other than ElasticSearch

Metadata

Please run nix-shell -p nix-info --run "nix-info -m" and paste the result.

 - system: `"x86_64-linux"`
 - host os: `Linux 6.1.71, NixOS, 23.11 (Tapir), 23.11.2774.3dc440faeee9`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.18.1`
 - channels(root): `"nixos-23.11"`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`
@fifthecho fifthecho added the 0.kind: bug Something is broken label Jan 12, 2024
@felbinger
Copy link
Member

felbinger commented May 15, 2024

Same issue here, I tried to get it working with output = lib.mkForce { logstash = ...} but it doesn't work also...

I copied the service, renamed services.filebeat to my-services.filebeat (except for systemd.services.filebeat), removed the default option for elasticsearch completly and it's working now.

If anyone has a solution how to clear the default value please tell us :)

@SuperSandro2000 SuperSandro2000 added the 6.topic: module system About "NixOS" module system internals label May 25, 2024
@SuperSandro2000
Copy link
Member

@roberth is that intended behavior? What do we miss?

@felbinger
Copy link
Member

felbinger commented Jun 22, 2024

@SuperSandro2000
How do you normally deal with problems like this? Removing the option as I described above would be a breaking change, so that's probably not a good solution. Is it possible to customize the options in some way (e. g. output becomes submodule, which is set to this value by default, but can be overridden) to have the ability to disable this option?

@SuperSandro2000
Copy link
Member

Then it is a breaking change. Sometimes it is unavoidable. We just need to make sure to add a release notes entry.

@felbinger
Copy link
Member

felbinger commented Jun 25, 2024

Actually, no idea how I could oversee this in the first place. But it's possible to disable the output using services.filebeat.settings.output.elasticsearch.enabled = false; (@fifthecho (ping to force notification, in case you still need this)).

I am going to continue working on #322425 to improve the documentation of the module for the option search.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.kind: bug Something is broken 6.topic: module system About "NixOS" module system internals
Projects
None yet
Development

No branches or pull requests

3 participants