Graylog2 / docker-compose

A set of Docker Compose files that allow you to quickly spin up a Graylog instance for testing or demo purposes.
Apache License 2.0
395 stars 138 forks source link

Add example Forwarder configuration #29

Closed bernd closed 1 year ago

bernd commented 1 year ago

Fixes #28

drewmiranda-gl commented 1 year ago

Looks great! The only thing i might add is setting the node-id. I'm certainly not a docker expert, i did this using a read_only bind volume, but not sure if there is a better way:

    volumes:
      - type: bind
        source: ./node-id
        target: /data/node-id
        read_only: true

Change to suite taste (e.g. to cooincide with GRAYLOG_NODE_ID_FILE)

It would be killer to be able to set this as an env var (vs a file) but maybe that should be opened as a feature req? :)

bernd commented 1 year ago

Looks great! The only thing i might add is setting the node-id. I'm certainly not a docker expert, i did this using a read_only bind volume, but not sure if there is a better way:

    volumes:
      - type: bind
        source: ./node-id
        target: /data/node-id
        read_only: true

Change to suite taste (e.g. to cooincide with GRAYLOG_NODE_ID_FILE)

It would be killer to be able to set this as an env var (vs a file) but maybe that should be opened as a feature req? :)

Why would you want to set the node ID explicitly? The container generates and stores the node ID on the persistent volume so it doesn't change between service restarts.

drewmiranda-gl commented 1 year ago

Great point. It may be too much of an edge case. In some examples where i've seen this used it was couple with container automation. Setting the explicit fwd node id made the behavior more predictable and automatable (if thats a word).

grownuphacker commented 1 year ago

Unless I've misconfigured, I've had to set the node ID on every forwarder or it is registered as a new forwarder every time it restarts or you upgrade.

I actually thought it was intended behaviour.


From: Drew Miranda @.> Sent: Friday, June 23, 2023 11:58:08 AM To: Graylog2/docker-compose @.> Cc: Subscribed @.***> Subject: Re: [Graylog2/docker-compose] Add example Forwarder configuration (PR #29)

Great point. It may be too much of an edge case. In some examples where i've seen this used it was couple with container automation. Setting the explicit fwd node id made the behavior more predictable and automatable (if thats a word).

— Reply to this email directly, view it on GitHubhttps://github.com/Graylog2/docker-compose/pull/29#issuecomment-1604483009, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AAONW36VTJIZYM5CX7MT2TLXMW4JBANCNFSM6AAAAAAZRIGQQ4. You are receiving this because you are subscribed to this thread.Message ID: @.***>

drewmiranda-gl commented 1 year ago

That was exactly the behavior i observed in testing. BUT It appears the way to address is the super secret GRAYLOG_NODE_ID_FILE: "/var/lib/graylog-forwarder/node-id" environment. (Why i opened the issue for a refernece file to begin with, learning the official way! insert 'this is the way' gif.)

Coupled with

volumes:
  - "forwarder-data:/var/lib/graylog-forwarder"

so i guess its a question of are we doing it right or are we fixing a "problem" in the wrong way?

bernd commented 1 year ago

That was exactly the behavior i observed in testing. BUT It appears the way to address is the super secret GRAYLOG_NODE_ID_FILE: "/var/lib/graylog-forwarder/node-id" environment. (Why i opened the issue for a refernece file to begin with, learning the official way! insert 'this is the way' gif.)

Coupled with

volumes:
  - "forwarder-data:/var/lib/graylog-forwarder"

so i guess its a question of are we doing it right or are we fixing a "problem" in the wrong way?

We didn't have a good default value for GRAYLOG_NODE_ID_FILE. I fixed that here and it will be part of the next release of the Forwarder image.

The volume needs to be set, yet. Otherwise, your journal and node ID wouldn't be persisted across restarts of the container.

bernd commented 1 year ago

A new graylog-forwarder image containing the fix is pushed.