Monitoring
Monitoring
02/May/2023
Hospital Management System – Needs W.r.t Application
Stability
The architecture of management System is as follows
DevOps Classroomnotes
03/May/2023
What has to be monitored?
There are organizations and individuals who have published
the best practices on implementing a monitoring solution
Google Four Golden signals Refer Here
USE method Refer Here
RED method Refer Here
Terms in Monitoring
Latency
Traffic
Errors
Saturation
DevOps Classroomnotes
04/May/2023
Metrics, Logs and Traces
Refer Here for detailed info on logs vs metrics vs traces
Metrics: Metrics are numeric time-series data.
Logs :
Logs are text informations with no standard way/format.
Logs from different applications/servers
Apache 192.168.2.20 - - [28/Jul/2006:10:27:10 -0300] "GET /cgi-
bin/try/ HTTP/1.0" 200 3395
Refer Here for some other applications
For logs we deal with text (unstructured data)
using logs requires a solution to
convert unstructured text in semi structured
understand logs with various format
Log analysis solution
Traces:
APM (Application Performance Monitoring) Agents can
help
We are trying to make our applications observable
Monitoring tells you when something is wrong, while
observability enables you to understand why.
Tools
DevOps Classroomnotes
05/May/2023
Pull vs Push Monitoring
Pull Monitoring: Monitoring System pulls the information
from various servers/applications/network devices the metrics.
Examples
Pull:
Prometheus
Nagios
Push:
Log stash
splunk
Elastic Stack
This was called as ELK Stack
ELK
E = Elastic Search
L = Log Stash
K = Kibana
Architecture
DevOps Classroomnotes
06/May/2023
Applications we will be observing
Traditional Applications: These are the applications which run
on physical or virtual machines hosted on-premises or cloud
Containerized Applications: These will be the applications
running on kubernetes cluster.
Technology:
Python
.net
C#
nodejs
Approach:
We will be getting info in the following order
metrics
logs
traces
What is Site Reliability Engineering?
Traditional Applications
Ecommerce
shopizer (java)
nopCommerce (.net)
Saleor (python)
Sprut Commerce (nodejs)
Medical Record System/Hospital managment system
Open Mrs (java)
Bahmni (java)
hospital run (node js)
NOP Commerce
To install this application we need atleast two servers
database server: (Linux/Windows)
mysql
microsoft sql server
postgres
application/web server: (Linux/Windows)
dotnet core
nginx
Our setup:
2 ubuntu Linux servers
Metrics:
Server Metrics
cpu
memory
disk
network
Application metrics
Requests
Errors
Response time
Installation
Manual
Automated
DevOps Classroomnotes
07/May/2023
nopCommerce Architecture
This application has two servers involved
Application:
This application runs on .net core 7
install the application
If the application is horizontally scaled, then we
will be using a loadbalancer/reverse proxy
Database
we will be using mysql database
This can be a managed database
DevOps Classroomnotes
09/May/2023
Monitoring and Observability Setup
Labsetup
To view th down status. stop the service and wait for the page
to reload
Lets create an alert to send email about status of server
DevOps Classroomnotes
14/May/2023
Metric Beats to Capture Metrics
enable nginx metrics
navigate to /etc/metricbeat/modules.d and rename
nginx.yml.disabled to nginx.yml
copy the dashboards into bin sudo cp -r
/usr/share/metricbeat/kibana/ /usr/share/metricbeat/bin
Now start the metric beat after setting in metricbeat.yml
cloud.id
cloud.auth
kibana url
We have configured all dashboards
System Overview:
Apache Dashboard
DevOps Classroomnotes
16/May/2023
Log Analysis
Every logging mechanism will have levels, most widely
adopted levels are
INFO: This is informational log
DEBUG: This is informative log
ERROR: This represents errors
CRITICAL/FATAL: This represents serious system
failures
Logs are time based information.
In Elastic Stack we have logstash which can extract the logs,
transform and load into elastic search for
querying/visualizations
Logstash does the transformations with the help of plugins
input plugins: to read from different sources Refer
Here for input plugins supported by logstash
filter plugins: to transform the log Refer Here for filter
plugins
output plugins: to store the output to different
sources Refer Here for output plugins
Installing logstash:
Refer Here
Ideal use case for us
DevOps Classroomnotes
17/May/2023
Logstash
Lets create a linux vm and explore logstash
Logstash pipeline:
input {
stdin {
}
}
output {
stdout {
codec => json
}
}
* Lets add one more output to some file `stdout => codec =>
rubydebug
* Refer Here for file output plugin
input {
stdin {
}
}
output {
stdout {
}
file {
path => "/tmp/output%{+YYYY-MM-dd}.txt"
}
}
Activity 2: Lets create a pipeline to read the file /tmp/test and display the contents in stdout
input = file
output = stdout
input {
file {
path => ["/tmp/test"]
}
}
output {
stdout {
}
}
}
}
DevOps Classroomnotes
18/May/2023
Grok Patterns Open the DevTools in Kibana and then Grok
Debugger
Refer Here for the grok filter in logstash
For writing your own patterns use regex Refer Here
Lets try to build a simple pattern as shown below
Refer Here for grok debugger
DevOps Classroomnotes
19/May/2023
Sending logs to elastic cloud
Overview
}
output {
elasticsearch {
cloud_id =>
"learningenv:dXMtY2VudHJhbDEuZ2NwLmNsb3VkLmVzLmlvOjQ0MyQxMDg1YTVjOWQyOWY0N2FjODkyNTBmNjY3N
jJkYWU3MyRlNDM5MGRmYmJmMzM0MGViODZiMGNhNTg3ODA1MmZkOQ=="
cloud_auth => "elastic:h22oWprNjqqbEGTKPSvHHpqS"
}
file {
path => /tmp/test.log
}
}
DevOps Classroomnotes
20/May/2023
Fixing logstash issue with elastic cloud
We had issue with pipeline id. removed the pipeline field
restarted all the services and executing requests from a script
so filebeat reads the logs and sends to logstash, logstash
breaks the message into multiple fields and stores in elastic
search with index name apachelog-*
Now create a data view from kibana
Exercises
1. Make nop commerce observable
2. Post k8s metrics to elastic cloud