Skip to content

Commit 195f5f2

Browse files
authored
Merge pull request #232 from fnproject/marleung/update-syslog-doc
Update doc for testing with syslog
2 parents 5be81f7 + 3b4dcd4 commit 195f5f2

9 files changed

Lines changed: 57 additions & 36 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
_site/
2+
**/target/

Troubleshooting/README.md

Lines changed: 56 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -297,37 +297,64 @@ app or after it's been created.
297297
When creating a new app you can specify the URL using the `--syslog-url` option
298298
as in:
299299
300-
```sh
301-
fn create app tutorial --syslog-url tcp://mysyslogserver.com
300+
![user input](images/userinput.png)
301+
>```sh
302+
>fn create app tutorial --syslog-url tcp://mysyslogserver.com
303+
>```
304+
305+
**Note:** As of the time of writing, Podman Desktop does not support syslog log driver. The syslog option is only supported when you are running Fn Server in Docker Desktop and Rancher Desktop.
306+
307+
308+
If you have already created an app, you will have to update it using
309+
`fn update app`. But before you do that you will need a syslog server ready to receive log data.
310+
311+
There are multiple options to setup a syslog server for testing. The easiest way is to start up a local syslog server.
312+
313+
### Run local syslog docker container
314+
315+
The steps are for Linux/MacOS but the steps on Windows should be similar. The syslog container works for both.
316+
317+
**Note:** We are using rsyslog/rsyslog container here. For detailed documentation, please check here: https://www.rsyslog.com/doc/getting_started/index.html
318+
319+
1. Create a local directory to host the config and log files
320+
321+
![user input](images/userinput.png)
322+
>```
323+
>mkdir mysyslog
324+
>cd mysyslog
325+
>mkdir logs
326+
>```
327+
2. Prepare the syslog config file
328+
- Create a file called `my-syslog.conf` under `mysyslog` with the following content
302329
```
330+
# Load module
331+
module(load="imtcp")
332+
input(type="imtcp" port="601")
303333
304-
Since we've already created the 'tutorial' app, we'll have to update it using
305-
`fn update app`. But before we do that we'll need
306-
a syslog server ready to receive log data. For the purposes of this
307-
tutorial we'll setup and use a free [Papertrail](https://papertrailapp.com/)
308-
account. Papertrail is a cloud log management service. To get setup:
309-
310-
1. Sign up for a [free Papertrail account](https://papertrailapp.com/signup?plan=free)
311-
2. On the Papertrail website, go to 'Settings' (top right hand corner), click on
312-
'Log Destinations', and click 'Create a Log Destination'.
313-
![Settings Dialog](images/settings.jpg)
314-
3. In the create dialog, under TCP unselect 'TLS' and under both TCP and UDP
315-
select 'Plain Text'
316-
![Create Dialog](images/createdialog.jpg)
317-
4. Click 'Create'
318-
5. You'll see the address of your log destination displayed at the top of the
319-
page looking something like `logs7.papertrailapp.com:<PORT>`. Copy this value
320-
to your clipboard for use in a minute.
321-
![Log Destination](images/logdestination.jpg)
322-
323-
Ok, now that we have a log destination we can update the syslog url of our
324-
application:
334+
# Ensure directory exists
335+
$WorkDirectory /var/log
336+
337+
# Log all UDP messages to /var/log/syslog/syslog.log
338+
action(type="omfile" file="/var/log/syslog")
339+
```
340+
3. Run the rsyslog docker container
325341
326342
![user input](images/userinput.png)
327343
>```sh
328-
> fn update app tutorial --syslog-url tcp://[your Papertrail destination]
344+
>docker run --rm -it -v /<your path to mysyslog>/my-syslog.conf:/etc/rsyslog.d/my-syslog.conf -v /<your path to mysyslog>/logs:/var/log -p 601:601 --name=syslogng rsyslog/rsyslog:latest
329345
>```
346+
You should have the container up and running
347+
![Syslog container](images/syslogcontainer.jpg)
348+
349+
4. Update app with the syslog url
330350
351+
Check your host IP and run the following.
352+
![user input](images/userinput.png)
353+
>```sh
354+
>fn update app tutorial --syslog-url tcp://<your host ip>:601
355+
>```
356+
357+
You could see that the app is updated.
331358
```sh
332359
app tutorial updated
333360
```
@@ -347,28 +374,21 @@ Which will return JSON looking something like:
347374
"created_at": "2019-10-13T14:54:45.459Z",
348375
"id": "01CT1QZFJ7NG8G00GZJ0000001",
349376
"name": "tutorial",
350-
"syslog_url": "tcp://logs7.papertrailapp.com:NNNN",
377+
"syslog_url": "tcp://<your host ip>:601",
351378
"updated_at": "2019-10-13T15:55:50.628Z"
352379
}
353380
```
354381
355-
`syslog_url` looks to be pointing to Papertrail so let's rerun our failing
356-
function:
382+
`syslog_url` is now pointing to our syslog container so let's rerun our failing function:
357383
358384
![user input](images/userinput.png)
359385
>```sh
360386
> fn invoke tutorial trouble
361387
>```
362388
363-
Of course it still fails. Let's go over to the Papertrail Dashboard and
364-
click on our "System" to open a page with the log showing our exception.
365-
366-
![Dashboard](images/dashboard.jpg)
367-
368-
![Logs](images/logs.jpg)
389+
Of course it still fails. Let's check the syslog container log under `/<your path to mysyslog>/logs`.
369390
370-
You can leave the Papertrail log view open while debugging to monitor the log
371-
output in near realtime. Give it a try!
391+
![Log](images/log.jpg)
372392
373393
374394
## Viewing HTTP Headers with DEBUG=1
@@ -402,7 +422,7 @@ Content-Type: application/json; charset=utf-8
402422
Date: Sun, 13 Oct 2019 16:45:56 GMT
403423
404424
405-
{"items":[{"id":"01DQ2STN6KNG8G00GZJ000001Q","name":"tutorial","syslog_url":"tcp://logs3.papertrailapp.com:NNNN","created_at":"2019-10-13T14:54:45.459Z","updated_at":"2019-10-13T15:55:50.628Z"}]}
425+
{"items":[{"id":"01DQ2STN6KNG8G00GZJ000001Q","name":"tutorial","syslog_url":"tcp://xxx.xxx.xxx.xxx:NNNN","created_at":"2019-10-13T14:54:45.459Z","updated_at":"2019-10-13T15:55:50.628Z"}]}
406426
NAME ID
407427
tutorial 01DQ2STN6KNG8G00GZJ000001Q
408428
```
-150 KB
Binary file not shown.
-64.3 KB
Binary file not shown.

Troubleshooting/images/log.jpg

114 KB
Loading
-45 KB
Binary file not shown.

Troubleshooting/images/logs.jpg

-67.3 KB
Binary file not shown.
-133 KB
Binary file not shown.
68.6 KB
Loading

0 commit comments

Comments
 (0)