Colonies offers built-in logging functionality, allowing executors to add log messages to processes, e.g. stdout ot stderr logs. These logs are stored in a PostgreSQL database. If TimescaleDB is used, the logs will be stored in a timeseries hypertable; otherwise, they will be indexed and stored in a regular PostgreSQL table. If retention is enabled, log data will be automatically purged upon reaching its expiration date. This automated process ensures that logs are systematically removed from the server once they become outdated.
The logging feature can be tested using the Colonies CLI. The initial step involves submitting a function specification and assigning the process to the CLI. Note that it is only possible to to add logs to running processes, and only executors assigned to the respective process have the privilege to add logs to it.
colonies function submit --spec examples/functions/cli.json
colonies process assign
INFO[0000] Assigned process to executor (oldest) ExecutorID=3fc05cf3df4b494e95d6a3d297a34f19938f7daa7422ab0d4f794454133341ac ProcessID=65def7d4ac4065bf72500497515b2010177f6d1c5a788a6d4ebb2534322f1ed0Now, we can add a log to the process:
colonies log add -p 65def7d4ac4065bf72500497515b2010177f6d1c5a788a6d4ebb2534322f1ed0 -m "helloworld"
INFO[0000] Starting a Colonies client Insecure=true ServerHost=localhost ServerPort=50080
INFO[0000] Adding log LogMsg=helloworld ProcessID=65def7d4ac4065bf72500497515b2010177f6d1c5a788a6d4ebb2534322f1ed0To get the logs:
colonies log get -p 65def7d4ac4065bf72500497515b2010177f6d1c5a788a6d4ebb2534322f1ed0
INFO[0000] Starting a Colonies client Insecure=true ServerHost=localhost ServerPort=50080
helloworld⏎To follow the logs as the process executes.
colonies log get -p 65def7d4ac4065bf72500497515b2010177f6d1c5a788a6d4ebb2534322f1ed0 --followAdditionally, it is also possible to retrieve logs for a specific executor, not limited to a specific process. This functionality allows access to all logs generated by processes executed by an executor. This feature provides a comprehensive overview of the executor's activities and facilitates monitoring and analysis of their performance and output.
colonies executor ls
INFO[0000] Starting a Colonies client Insecure=true ServerHost=localhost ServerPort=50080
+------------------------------------------------------------------+------------+------+
| ID | NAME | TYPE |
+------------------------------------------------------------------+------------+------+
| 3fc05cf3df4b494e95d6a3d297a34f19938f7daa7422ab0d4f794454133341ac | myexecutor | cli |
+------------------------------------------------------------------+------------+------+
colonies log get -e 3fc05cf3df4b494e95d6a3d297a34f19938f7daa7422ab0d4f794454133341acTo follow the executor:
colonies log get -e 3fc05cf3df4b494e95d6a3d297a34f19938f7daa7422ab0d4f794454133341ac --follow