Wendelin Home Wendelin

    Wendelin - HowTo setup Fluentd on Sensor

    HowTo setup Fluentd on Streaming Device
    • Last Update:2025-05-27
    • Version:006
    • Language:

    Agenda

    • Request Fluentd instance for IOT Sensor
    • Learn configuration parameters for Fluentd

    This tutorial teaches how to setup Fluentd on IOT Sensor. 

    Prerequisites

    Before doing this tutorial make sure you have read and completed the following tutorials:

    IMPORTANT: In order to successfully request a Fluentd instance, you will need to have a validated Allocation Supply in your project with the following configuration:

    • Software Product: The latest Fluentd software release with the expert software type.
    • Compute Node: the Node corresponding to your Olimex Sensor

    The Software Product should already be ready for you to use, no need to create it.

    If you wish to know more about the configuration of Fluentd, you can find the official documentation here: Fluentd Configuration File.

    Request Fluentd instance for IOT Sensor

    Step 1: Request instance

    Please click on "Request" menu at left side of the page as shown on image below.

    This will redirect you to your project page where you will have to select the appropriate project.

    After selecting the project will will be given option to choose the product you want to install. In this case it is fluentd.

    Finally you will be redirected to your new instance where you will need to specify the needed instance parameters.

    The following actions need to be performed:

    1. Set an instance title in the Title field (in this example it is Olimex.Sensor).
    2. Choose the Expert software type from the corresponding dropdown menu.
    3. In the Parameter Form, fill in the Configuration parameter with the fluentd configuration XML given below and fill in the parameters marked as <PARAMETER> with the appropriate value from the parameter table:
      <source>
          @type exec
          tag sensor_1.sample-environment-raw-data
          command /usr/bin/python3 /srv/slapgrid/kbme280-sim.py
          run_interval 30s
          <parse>
              keys pressure, humidity, temperature
          </parse>
      </source>
      
      <match *.sample-environment-raw-data>
          @type forward
          <server>
              name fluentd-gw
                  host <FLUENTD-GATEWAY-IPv4>
                  port 24224
          </server>
      </match>

      Parameter table:

      <FLUENTD-GATEWAY-IPv4> The IPv4 address which the fluentd gateway will bind to, usually something like 192.168.x.x
    4. In the Computer dropdown list, choose the COMP identifier that corresponds to your Olimex Sensor Node.
    5. Click on the Request button at the bottom of the page. Your instance will be created automatically and its status will be visible from the Service tab on the left side of the screen.

    Step 2: Monitor instantiation of your instance

    You can monitor the instantiation process by running

    tail -f /opt/slapos/log/slapos-node-instance.log

    on the corresponding machine.

    Fluentd Instance

    This step can take some time.

    In your SlapOS dashboard you can see your newly requested instance, which will be ready when the the Monitoring Status goes from red to green.

    NOTE: the Fluentd configuration parameters we defined earlier can be viewed and edited through the Update Parameter action in the panel on the left of the screen.

    Step 3: Setup additional packages and adjust permissions

    You will now need to further install additional packages and adjust security permissions for your sensor to work, see below:

    # add Python's packages for reading environment data from MOD-ENV
    root@t20:~# pip install bme280 smbus

    # download script to read environment data from MOD-ENV (Note: please place it in "/srv/slapgrid"as this is where fluentd expects it!)
    root@t20:/srv/slapgrid# wget https://lab.nexedi.com/nexedi/wendelin/-/raw/master/tutorial/kbme280-sim.py

    # make sure that downloaded script is executable by all system users
    root@t20:/srv/slapgrid# chmod a+x kbme280-sim.py

    # make sure that the user running fluentd service on your IOT sensor can access I2C bus to read data from MOD-ENV
    # you can see the user running the fluentd by executing "slapos node" command. If your fluentd's instance is "slappart4:fluentd-service-on-watch"
    # then it is owned and run by "slapuser4". Thus adjust accordingly command below.
    root@t20:/srv/slapgrid# usermod -a -G i2c slapuserX

    # test that script is executable for slapuserX (adjust accordingly!)

    root@t20:/srv/slapgrid# su slapuserX
    $ /usr/bin/python3 /srv/slapgrid/kbme280-sim.py
    998.8597649764879    33.679160017867545    21.115451616437735

    Step 4: Control (start / stop) IOT Sensor

    Login to your IOT Sensor and run the following command :

    sudo slapos node status

    You see that a new service for Fluentd is added.

    And the generated fluentd configuration file is located here :

    /srv/slapgrid/slappartX/etc/fluentd-agent.conf

    Your IOT Sensor is now ready to read data and forward it through the Fluentd IOT Gateway to Wendelin.