About Edge

Introduction

In the ABEJA Platform, it is also possible to run model handler functions not only on the cloud, but also on so-called Edge environments such as IoT Device and x86 PC. You can also use fluent-bit to view device metrics and logs in the cloud.

To use the edge features, install the following two software on the device - abeja-device-agent: A program to synchronize deployment in the cloud with the device. - fluent-bit / fluent-bit-plugin-out-abeja-platform: A program to collect device metrics and logs.

Installation.

device Creating a device resource

Register the device and register the public key in ABEJA Platform. You can create a device from the following API endpoints - Create Device](https://api-spec.abeja.io/#tag/Device) - Public Key Registration

The following information is required - Organization ID - device ID - public key ID - A private key that corresponds to a public key

abeja-device-agent

Follow these steps to install.

$ sudo mkdir -p /opt/abeja-device-agent/bin/

## For x86_64 machine
ARCH=amd64
## For arm machine
ARCH=arm64

AGENT_URL=https://abeja-device-resources.s3-ap-northeast-1.amazonaws.com/v2/abeja-device-agent/0.2.1/abeja-device-agent_linux_${ARCH}.tar.gz
$ curl -fsSL ${AGENT_URL} | sudo tar -zx -C /opt/abeja-device-agent/bin/
$ sudo chmod 755 /opt/abeja-device-agent/bin/abeja-device-agent

SYSTEM_CONFIG_URL=https://abeja-device-resources.s3-ap-northeast-1.amazonaws.com/v2/abeja-device-agent/0.2.1/abeja-device-agent.service
$ sudo curl ${SYSTEM_CONFIG_URL} -o /usr/lib/systemd/system/abeja-device-agent.service

$ sudo mkdir -p /etc/abeja-device-agent
$ sudo vim /etc/abeja-device-agent/abeja-device-agent.conf
# Please edit config as below and replace abeja-device resource information

$ sudo systemctl status abeja-device-agent
$ sudo systemctl start abeja-device-agent
$ sudo journalctl -f -u  abeja-device-agent

Add the following configuration to /etc/abeja-device-agent/abeja-device-agent.conf and set the information of the device.

organization-id = {organization-id}
device-id = {device-id}
private-key = {device-key}
public-key-id = {public-key-id}

fluent-bit

Follow these steps to install. - fluent-bit installation requirements - fluent-bit download source code - fluent-bit build and install

After installation, run the following command

# setup config files
$ sudo cp -r /usr/local/etc/fluent-bit /etc/

# Modify systemd configuration
$ sudo vim /lib/systemd/system/fluent-bit.service
> etc/fluent-bit/fluent-bit.conf -> /etc/fluent-bit/fluent-bit.conf

# check status and restart
$ sudo systemctl status fluent-bit
$ sudo systemctl start fluent-bit
$ sudo journalctl -f -u fluent-bit
$ sudo systemctl stop fluent-bit

fluent-bit-plugin-out-abeja-platform

Follow these steps to install.

# Install plugin
## For x86_64 machine
ARCH=amd64
## For arm machine
ARCH=arm64

PLUGIN_URL=https://abeja-device-resources.s3-ap-northeast-1.amazonaws.com/v2/fluentbit-plugin-out-abeja-platform/0.1.1/out_abejaplatform_linux_${ARCH}.tar.gz
curl -fsSL ${PLUGIN_URL} | sudo tar -zx -C /usr/local/lib/fluent-bit

# Update configs
sudo bash -c 'echo  "    Path /usr/local/lib/fluent-bit/out_abejaplatform.so" >> /etc/fluent-bit/plugins.conf'
sudo vim /etc/fluent-bit/fluent-bit.conf
# Please append config as below and replace abeja-device resource information
# Organization_Id, Device_Id, Credential_Path, Public_Key_Id

$ sudo systemctl start fluent-bit
$ sudo journalctl -f -u fluent-bit

Add the following configuration to /etc/fluent-bit/fluent-bit.conf and set the information of the device.

################
# For Service
################

# [INPUT]
#     Name        tail
#     Tag         abeja.io.device.metric.service.http*
#     Parser      json
#     Path        /var/abeja-device-agent/logs/services/*/json_access.log
#     DB          /etc/fluent-bit/tail.db
#     Path_Key    filepath

# [INPUT]
#     Name        tail
#     Tag         abeja.io.device.metric.service.http*
#     Parser      apache
#     Path        /var/abeja-device-agent/logs/services/*/access.log
#     DB          /etc/fluent-bit/tail.db
#     Path_Key    filepath


[INPUT]
    Name        tail
    Tag         abeja.io.device.log.service*
    Path        /var/abeja-device-agent/logs/services/*/*
    DB          /etc/fluent-bit/tail.db
    Path_Key    filepath

################
# For device
################

[INPUT]
    Name cpu
    Tag  abeja.io.device.metric.system.cpu

[INPUT]
    Name   mem
    Tag    abeja.io.device.metric.system.memory

[INPUT]
    Name          disk
    Tag           abeja.io.device.metric.system.disk.io
    Interval_Sec  1
    Interval_NSec 0

[INPUT]
    Name          netif
    Tag           abeja.io.device.metric.system.netif
    Interval_Sec  1
    Interval_NSec 0
    Interface     eth0

[INPUT]
    Name        tail
    Tag         abeja.io.device.log.system*
    Path        /var/log/*
    Exclude_Path /var/log/btmp
    DB          /etc/fluent-bit/tail.db
    Path_Key    filepath

##############
# Output
#############

[OUTPUT]
    Name abejaplatform
    Match abeja.io.device.*
    Organization_Id {Organization_Id}
    Device_Id {Device_Id}
    Credential_Path {Credential_Path}
    Public_Key_Id {Public_Key_Id}
    Log_Service_Id_Regexp ^abeja\.io\.device\.log\.service\.var\.abeja-device-agent\.logs\.services\.(?P<serviceId>[^.]+)\..+$
    Access_Log_Service_Id_Regexp ^abeja\.io\.device\.metric\.service\.http\.var\.abeja-device-agent\.logs\.services\.(?P<serviceId>[^.]+)\.[^.]*access[^.]*\.log$