An open API service indexing awesome lists of open source software.

https://github.com/abhirockzz/fn-syslog-example

Exporting Fn function logs to remote syslog service
https://github.com/abhirockzz/fn-syslog-example

faas fnproject functions orafunc-la serverless workshop

Last synced: 6 months ago
JSON representation

Exporting Fn function logs to remote syslog service

Awesome Lists containing this project

README

          

# Exporting function logs to remote syslog service

Fn allows you to push the [function logs to a syslog endpoint](https://github.com/fnproject/docs/blob/master/fn/operate/logging.md#remote-syslog-for-functions). This is an example of how to configure it and test it our using [Papertrail](https://papertrailapp.com)

## step 0

### create a Papertrail account

Papertrail is a hosted log management service. You can sign up for a [free account](https://papertrailapp.com/signup?plan=free) for the purposes of this tutorial

### create log destination

Go to Settings (top right hand corner) and click on Log Destinations. Create a log destination.

### make a note of your *destination*

On the Papertrail [**Settings**](https://papertrailapp.com/account) choose **Log Destinations** (from the options in the left) and copy the endpoint - you'll use this in subsequent steps

![](settings.jpg)

### For TCP, unselect TLS and select Plain Text

As shown below ... Settings > Log Destination > my.papertrail.com:4242 > Settings

For TCP > Unselect TLS and Select Plain Text

![](unselect-TLS.png)

## Create application

- 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= --syslog-url tcp://` 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 `

### If you already have an existing application...

.. 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 --syslog-url tcp://` 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`

![](console-1.png)

Enter the `syslog` endpoint and click `Save`

![](console-2.png)

You should now see the updated value

![](console-3.png)

## Deploy

- 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

Test using Fn CLI with `fn invoke` command

### Invoke

- `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

### Check your Papertrail a/c

Hop over to your Papertrail [dashboard](https://papertrailapp.com/dashboard) and click **Events** (top right) to see the logs

![](events.jpg)