dockerdocker-composeslackfalco

Falco security and falcosidekick on docker compose


I'm trying to run falco and falcosikick container in a docker compose.

version: "3.9"
services:
  falco:
    image: falcosecurity/falco:latest
    privileged: true
    volumes:
      - /var/run/docker.sock:/host/var/run/docker.sock
      - /dev:/host/dev
      - /proc:/host/proc:ro
      - /boot:/host/boot:ro
      - /lib/modules:/host/lib/modules:ro
      - /usr:/host/usr:ro
      - /etc:/host/etc:ro
      - /var/log/falco_events.log:/var/log/falco_events.log
      - /home/ubuntu/falco.yaml:/etc/falco/falco.yaml
      - /home/ubuntu/falco_rules.yaml:/etc/falco/falco_rules.yaml
      - /home/ubuntu/falco_rules.local.yaml:/etc/falco/rules.d/custom-rules.yaml
  falcosidekick:
    image: falcosecurity/falcosidekick
    ports:
      - 2801:2801

I configured falco.yaml to send http_output to falcosidekick container:

http_output:
  enabled: true
  url: "http://falcosidekick:2801"

Then I added slack configuration to falco.yaml


debug: false 
customfields: # custom fields are added to falco events
  Akey: "AValue"
  Bkey: "BValue"
  Ckey: "CValue"
mutualtlsfilespath: "/etc/certs" # folder which will used to store client.crt, client.key and ca.crt files for mutual tls (default: "/etc/certs")

slack:
  webhookurl: "https://hooks.slack.com/services/XXX/XXXX/XXXXX"
  #footer: "" # Slack footer
  #icon: "" # Slack icon (avatar)
  #username: "" # Slack username (default: Falcosidekick)
  outputformat: "all" # all (default), text, fields
  minimumpriority: "" # minimum priority of event for using this output, order is emergency|alert|critical|error|warning|notice|informational|debug or "" (default)
  messageformat: 'Alert : rule *{{ .Rule }}* triggered by user *{{ index .OutputFields "user.name" }}*' # a Go template to format Slack Text above Attachment, displayed in addition to the output from `SLACK_OUTPUTFORMAT`, see [Slack Message Formatting](#slack-message-formatting) in the README for details. If empty, no Text is displayed before Attachment.

With this configuration I never had an alert on my slack channel. What's wrong?

Thank you


Solution

  • Configurations for falco and falcosidekick must be in 2 different files, it means you also need to mount a volume in falcosidekick container. You can also use environment variables if you prefer (but it implies your slack webhook url will be in clear text in your docker-compose file).

    version: "3.9"
    services:
      falco:
        image: falcosecurity/falco:latest
        privileged: true
        volumes:
          - /var/run/docker.sock:/host/var/run/docker.sock
          - /dev:/host/dev
          - /proc:/host/proc:ro
          - /boot:/host/boot:ro
          - /lib/modules:/host/lib/modules:ro
          - /usr:/host/usr:ro
          - /etc:/host/etc:ro
          - /var/log/falco_events.log:/var/log/falco_events.log
          - /home/ubuntu/falco.yaml:/etc/falco/falco.yaml
          - /home/ubuntu/falco_rules.yaml:/etc/falco/falco_rules.yaml
          - /home/ubuntu/falco_rules.local.yaml:/etc/falco/rules.d/custom-rules.yaml
      falcosidekick:
        image: falcosecurity/falcosidekick
        ports:
          - 2801:2801
        volumes:
          - /home/ubuntu/falcosidekick.yaml:/etc/falco/falcosidekick.yaml
        command: "-c /etc/falco/falcosidekick.yaml"