Viewing call logs with MyAdmin

With MySQL as the central Log Store, we can simply access MySQL with any tool to query or event analyze the logs. In this example, we use a simple MyAdmin UI to connect to the MySQL backend. Here's the docker run command to start MyAdmin.

We just simply attach an instance of MyAdmin to the same network and tell MyAdmin to connect to mysql, the service name of the backend DB:

$ docker run --detach 
--name myadmin
--network fn_net
--network-alias myadmin
-p 9000:80
-e PMA_HOST=mysql
phpmyadmin/phpmyadmin

Browse to the exposed port, in this example port number 9000 , and log in using Username and Password, set during the setup of MySQL (func/funcpass). The following screenshot shows the login page of phpMyAdmin:

Figure 5.9: The login page of phpMyAdmin that will connect to the Fn's log database

Inside the phpMyAdmin panel, take a look at the fn_db parameter and we will see all the tables for storing Fn information, as shown in the following screenshot. The data of the table apps are created by the command fn apps create, for example. What we'd like to see are table calls and table logs. The content of table calls can be retrieved by the fn calls list, and the content of table logs can also be retrieved in a similar way using fn logs get. But when we are able to access the logs directly, we can even do some analysis directly with the available data:

Figure 5.10: The list of all Fn's tables in phpMyAdmin

The following screenshot shows the content of table calls. There is a status column, which allows us to effectively filter to see what the call (status) is: success or error. There is also the stats column, which contains some temporal information to be retrieved and displayed by the Fn UI:

Figure 5.11: Fn calls log data in table calls

The following screenshot shows table logs. In the logs table, it just stamps each entry with the call ID. The column log shows the log message we printed out to the STDERR. We can see that there are different incorrect behaviors just by trying to send some invalid inputs to our hello_go function. With this table being so accessible, we can troubleshoot the Fn functions effectively without installing other extra tools:

Figure 5.12: Fn logs data captured from a function's STDERR

OK, it seems everything is working correctly if we could get MyAdmin to show the logs data. Finally, to confirm that all containers are running and what they should look like, just use the docker ps command again to check all running containers:

$ docker ps --format "table {{.ID}}	{{.Names}}	{{.Command}}	{{.Ports}}"
CONTAINER ID NAMES COMMAND PORTS
70810f341284 fnui "npm start" 0.0.0.0:4000->4000/tcp
ce4f8e9bc300 fnlb "./fnlb --nodes fn_0…" 0.0.0.0:8080->8081/tcp
dae4fb892b4d fn_1 "preentry.sh ./fnser…" 2375/tcp
8aefeb9e19ef fn_0 "preentry.sh ./fnser…" 2375/tcp
8645116af77d myadmin "/run.sh phpmyadmin" 9000/tcp, 0.0.0.0:9000->80/tcp
67bd136c331a mysql "docker-entrypoint.s…" 3306/tcp
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset