The document outlines exercises for learning the ELK stack using Docker. It introduces Elasticsearch for data storage, Logstash for collecting and parsing logs, and Kibana for visualization. The exercises demonstrate setting up the environment, sending a test message to ELK, analyzing Shakespeare works, customizing the Kibana dashboard, using Grok filters to parse logs, and filtering Apache logs with Logstash.
2. Agenda
ELK Stack Introduction
Prerequisite: Setup environment using Docker
Exercise 1: Say Hello To ELK Stack
Exercise 2:Analyze Shakespeare works
Exercise 3: Customize your Kibana Dashboard
Exercise 4: Use customize grok rule to parse your "Hello
World"
Exercise 5: Use pre-defined grok rule to filter Apache log
Learn ELK in Docker in 90 minutes2 01/09/15
3. What is ELK stack
ElasticSearch
Store the data that LogStash processed and provide full-text
index
LogStash
Collecting and parsing log files.Transform unstructured log into
meaningful and searchable.
Kibana
Provide a friendly web console for user to interact with
ElasticSearch.
Learn ELK in Docker in 90 minutes3 01/09/15
4. What is ELK stack – Deploy Diagram
Learn ELK in Docker in 90 minutes4 01/09/15
5. Environment (docker)
Learn ELK in Docker in 90 minutes5 01/09/15
http://boot2docker.io/ Boot2docker 1.3.x /recommend
$ docker -v
User/Passwd: docker/tcuser
Start the container
docker pull leorowe/codingwithme-elk
docker tag leorowe/codingwithme-elk elk
docker run -d --name elk -p 80:80 -p 3333:3333 -p 9200:9200 elk
Enter the container
docker exec -it elk bash
6. Exercise 1:
Say Hello To ELK Stack
Open the browser and visit Kibana (192.168.59.103 )
If it return HTTP 404 then
ifconfig (docker@boot2docker: and find eth1 ip, begin with
192.168.)
Say “Hello World” to ELK
echo ‘Hello World’ | nc localhost 3333 (boot2Docker)
Check the greeting in Kibana
Learn ELK in Docker in 90 minutes6 01/09/15
7. Exercise 2: Analyze Shakespeare works
Enter ELK container: docker exec –it elk bash
/build.sh
Find line_id of “to be or not to be”
How many times did “food” and “love” appear in the
same sentence.
Learn ELK in Docker in 90 minutes7 01/09/15
8. Exercise 3 : Customize your Kibana
Dashboard
Learn ELK in Docker in 90 minutes8 01/09/15
Open a blank dashboard
Add a row
1.click “Add A Row” button
2.type the row name then click Create Row and Save button
9. Add a terms panels
Click Add Panel button
Select terms as Panel Type
Type speaker as Fileld
Toggle Other checkbox
Select bar asView Options Style
Click Save button
Learn ELK in Docker in 90 minutes9 01/09/15
10. Men vs Women. Who wins?
Add a new query box
Type men and women in each query box
Click search button
Add a Hits Panel
Choose hits as type
Choose pie as Style
Click Save button
Learn ELK in Docker in 90 minutes10 01/09/15
11. Exercise 4 : Use customize grok filter
to parse your "Hello World"
Learn ELK in Docker in 90 minutes11 01/09/15
add a grok filter into /logstash.conf
input { tcp { port => 3333 type => "text event"}}
filter{
grok{ match=>['message','%{WORD:greetings}%{SPACE}%
{WORD:name}']
}
}
output { elasticsearch { host => localhost } }
13. Exercise 5 : Use Logstash to filter
Apache log
Learn ELK in Docker in 90 minutes13 01/09/15
14. Exercise 5 : Use Logstash to filter
Apache log
Using grok
Learn ELK in Docker in 90 minutes14 01/09/15
15. Workflow
Learn ELK in Docker in 90 minutes15 01/09/15
See http://logstash.net/docs/1.4.2/tutorials/getting-started-with-logstash
16. Add a file input
input {
tcp { port => 3333 type => "text event"}
}
file {
type => 'apache-log'
path => '/*.log‘
start_position => "beginning"
}
}
Learn ELK in Docker in 90 minutes16 01/09/15
17. Add a filter to deal with Apache logs
filter{
if [type]=='apache-log'{
grok{
match=>['message','%{COMMONAPACHELOG:message}']
}
date{
match=>['timestamp','dd/MMM/yyyy:HH:mm:ss Z']
}
mutate {
convert => { "response" => "integer" }
convert => { "bytes" => "integer" }
}
}
}
Learn ELK in Docker in 90 minutes17 01/09/15
18. Exercise 5 : Use Logstash to filter
Apache log
Restart logstash (/restart-logstash.sh)
Check out Logstash Dashboard Page.
Learn ELK in Docker in 90 minutes18 01/09/15
19. Exercise 5 : Use Logstash to filter
Apache log
Add response query
response:200 response:304 response:401
Learn ELK in Docker in 90 minutes19 01/09/15
20. Summary
ELK Stack is the off the shelf toolkits to manage and
analyze your logs or whatever it has a timestamp
attribute.
Learn ELK in Docker in 90 minutes20 01/09/15