Fn allows you to push the function logs to a syslog endpoint. This is an example of how to configure it and test it our using Papertrail
Papertrail is a hosted log management service. You can sign up for a free account for the purposes of this tutorial
Go to Settings (top right hand corner) and click on Log Destinations. Create a log destination.
On the Papertrail Settings choose Log Destinations (from the options in the left) and copy the endpoint - you'll use this in subsequent steps
As shown below ... Settings > Log Destination > my.papertrail.com:4242 > Settings
For TCP > Unselect TLS and Select Plain Text
- Get the latest version of Fn CLI -
curl -LSs https://raw.githubusercontent.com/fnproject/cli/master/install | sh
- Create an application with
syslog
endpoint info -fn create app fn-syslog-app --annotation oracle.com/oci/subnetIds=<SUBNETS> --syslog-url tcp://<your papertrail syslog endpoint>
e.g.fn create app fn-syslog-app --syslog-url tcp://my.papertrail.com:4242
- Switch to the context for Oracle Functions -
fn use context <context-name>
.. you can just configure that to use the papertrail syslog
endpoint as well.
Using the Fn CLI
It is as simple as
fn update app <app-name> --syslog-url tcp://<your papertrail syslog endpoint>
e.g.fn update app my-existing-app --syslog-url tcp://my.papertrail.com:4242
Using the Oracle Functions console
Open your application from the Applications
page and click Edit Application
Enter the syslog
endpoint and click Save
You should now see the updated value
- Clone or download this repo
cd fn-syslog-example
fn -v deploy --app fn-syslog-app
Your function should now be deployed. Check it
fn inspect app fn-syslog-app
You will see something similar to this - notice the syslog_url
configuration
{
.....
"created_at": "2018-08-13T11:39:48.943Z",
"id": "01CMSHBGTFNG8G00GZJ0000001",
"name": "fn-syslog-app",
"syslog_url": "tcp://my.papertrailapp.com:4242",
"updated_at": "2018-08-13T11:39:48.943Z"
.....
}
Test using Fn CLI with fn invoke
command
fn invoke fn-syslog-app fn-syslog-func
echo -n 'fun with fn!' | fn invoke fn-syslog-app fn-syslog-func
You can repeat this multiple times
Hop over to your Papertrail dashboard and click Events (top right) to see the logs