How Do You Get Nginx Logs to be in JSON format?

Problem scenario
The book Expert Python Programming (page 278) says 12 Factor app recommends that the application should not be aware of the format of the logs. JSON format for logs can be beneficial for various purposes. You want Nginx’s access logs — but not error logs — to be in JSON format. What do you do?

Solution
Use a file like this for your nginx.conf.

How Do You Zero out a /var/log/mail File?

Problem scenario
You backed up /var/log/mail to a different file. You want the /var/log/mail file to start empty so you can review it without looking at old activity. What do you do?

Solution
Run these four commands:

sudo su –
cd /var/log
mail
exit

Now you /var/log/mail file will still exist and record activity as normal. It will not have anything in it before the time you ran the above “>

How Do You Get the ElasticSearch, LogStash or Kibana Service to Remain On?

Problem scenario
The elasticsearch, logstash or kibana services will start, but when you check the status, it does not remain on. It keeps stopping. You see the status as “failed.”

Solution
Possible Solution #1
Add more memory or swap space to the system. If you need assistance with either of these, see this posting.

How Do You Install ElasticSearch on CentOS/RHEL/Fedora?

Prerequisites
This assumes you have installed Java. If you need assistance with installing Java, see this posting. This assumes you have a server with 4 GB of memory (e.g., virtual memory and RAM in an amount greater than 4 GB). The command to run to see how much memory you need is this one: free -mh If you need more memory, see this posting.

How Do You Install Splunk on a Debian/Ubuntu Linux Server?

Problem scenario
You have a Debian or Ubuntu Linux server. You want to install a trial version of Splunk. What should you do?

Solution
1. Sign up for an account to get the installation media: https://www.splunk.com/en_us/download.html
2. Click on “Linux”
3. Obtain the .deb file.
4. Put the .deb file on the Linux server.
5.

How Do You Generate a 100 GB Log File?

Problem scenario
You want to generate a large log file to use later on (e.g., for the Elastic Stack or Splunk). How do you create a 100 GB log file?

Solution
Find an example log to base the generation off. Run these commands to find a log that you would want to copy its format:

cd /var/log
ls -lh –sort=size
sudo tail foobar # where foobar is the name of the log file you want to sample

2.

What is ChatOps?

Question
What is ChatOps?

Answer
ChatOps is the integration of a chatroom (e.g., Slack, HipChat, etc.) with the controls of an API (e.g., a REST API) to invoke DevOps or systems administration tasks. ChatOps chatrooms allow for text communication in real-time. In a ChatOps chatroom there is a syntax for messages to reboot a server or deploy code. Issuing such commands allows for centralized logging and close communication with many people.

What Are the Recommended Practices of Logging?

Problem scenario
The primary purposes of logging include troubleshooting (root cause analysis of poor performance, debugging unintended behavior, or resolving catastrophic failures). In some cases logging is used for monitoring of resource utilization and planning of changes. What patterns or characteristics of a good logging system (consistent with what some may phrase as “best practices”)?

Solution
Here are 13 traits of good logging.