ELK Stack 
Because logs are not meant to go to /dev/null 
Guillermo Carrasco 
@guillemch
Logging & ELK stack
Logging & ELK stack 
What are logs? 
What are logs for? Theory vs reality 
Logstash & Elasticsearch 
Kibana
What are logs? 
http://adam.herokuapp.com/past/2011/4/1/logs_are_streams_not_files/
What are logs? 
2014-09-19 13:08:37,972 INFO [MiSeqIntegrator] (SequencingIntegrationUtil) 
Extracted raw content - [cycleNumber = 308 , runFolder = "D:IlluminaMiSeqTemp 
140904_M01320_0130_000000000-A9NE9" , netFolder = "Z:140904_M01320_0130_000000000-A9NE9" , 
Record 
http://adam.herokuapp.com/past/2011/4/1/logs_are_streams_not_files/
What are logs? 
2014-09-19 13:08:37,972 INFO [MiSeqIntegrator] (SequencingIntegrationUtil) 
Extracted raw content - [cycleNumber = 308 , runFolder = "D:IlluminaMiSeqTemp 
140904_M01320_0130_000000000-A9NE9" , netFolder = "Z:140904_M01320_0130_000000000-A9NE9" , 
Record 
http://adam.herokuapp.com/past/2011/4/1/logs_are_streams_not_files/
What are logs? 
2014-09-19 13:08:37,972 INFO [MiSeqIntegrator] (SequencingIntegrationUtil) 
Extracted raw content - [cycleNumber = 308 , runFolder = "D:IlluminaMiSeqTemp 
140904_M01320_0130_000000000-A9NE9" , netFolder = "Z:140904_M01320_0130_000000000-A9NE9" , 
Record 
http://adam.herokuapp.com/past/2011/4/1/logs_are_streams_not_files/
What are logs? 
2014-09-19 13:08:37,972 INFO [MiSeqIntegrator] (SequencingIntegrationUtil) 
Extracted raw content - [cycleNumber = 308 , runFolder = "D:IlluminaMiSeqTemp 
140904_M01320_0130_000000000-A9NE9" , netFolder = "Z:140904_M01320_0130_000000000-A9NE9" , 
Record 
http://adam.herokuapp.com/past/2011/4/1/logs_are_streams_not_files/
What are logs? 
2014-09-19 13:08:37,972 INFO [MiSeqIntegrator] (SequencingIntegrationUtil) 
Extracted raw content - [cycleNumber = 308 , runFolder = "D:IlluminaMiSeqTemp 
140904_M01320_0130_000000000-A9NE9" , netFolder = "Z:140904_M01320_0130_000000000-A9NE9" , 
Record 
MiSeqIntegrator.log 
HiSeqIntegrator.log 
apache.log 
GenStat.log 
supervisord.log 
… 
http://adam.herokuapp.com/past/2011/4/1/logs_are_streams_not_files/
What are logs? 
2014-09-19 13:08:37,972 INFO [MiSeqIntegrator] (SequencingIntegrationUtil) 
Extracted raw content - [cycleNumber = 308 , runFolder = "D:IlluminaMiSeqTemp 
140904_M01320_0130_000000000-A9NE9" , netFolder = "Z:140904_M01320_0130_000000000-A9NE9" , 
Record 
MiSeqIntegrator.log 
HiSeqIntegrator.log 
apache.log 
GenStat.log 
supervisord.log 
… 
So 
logs 
are 
files? 
http://adam.herokuapp.com/past/2011/4/1/logs_are_streams_not_files/
What are logs? 
2014-09-19 13:08:37,972 INFO [MiSeqIntegrator] (SequencingIntegrationUtil) 
Extracted raw content - [cycleNumber = 308 , runFolder = "D:IlluminaMiSeqTemp 
140904_M01320_0130_000000000-A9NE9" , netFolder = "Z:140904_M01320_0130_000000000-A9NE9" , 
Record 
MiSeqIntegrator.log 
HiSeqIntegrator.log 
apache.log 
GenStat.log 
supervisord.log 
… 
- Logs are time-oriented streams of 
records 
http://adam.herokuapp.com/past/2011/4/1/logs_are_streams_not_files/
What are logs for? 
Theory
What are logs for? 
Theory 
Provide real-time and valuable 
information about the execution of 
a program 
Use this information in your benefit: 
prevent problems, do analytics, plot 
status…
Example: Our pipeline
Example: Our pipeline 
started job X for sample Y 
Aligning sample X 
Generating report for Project A.Sample_14_09 
Cleaning /proj/a2010002/nobackup area
Example: Our pipeline 
started job X for sample Y 
Aligning sample X 
Generating report for Project A.Sample_14_09 
Cleaning /proj/a2010002/nobackup area 
Submitted jobs in the last X mins… Pipeline crashes in the last X days…
Example: Illumina logs
Example: Illumina logs 
- Status of a particular 
run 
- Failures/Anomalies 
- Cycles sequenced 
today/this week/etc 
- …
What are logs for? 
Reality
What are logs for? 
Reality 
Something we look at ONLY when 
something has already gone wrong… 
if we can!
On the previous examples…
On the previous examples… 
- The pipeline logs are dumped to 
nextgen_analysis_server.log, in 
milou-b, under the functional 
account… and rotated! 
- The Illumina logs are just never 
looked at…
Problems
Problems 
- Logs spread around servers and 
accounts 
- Rotating logs may disappear 
- If you don’t rotate, logs will fill up 
disks 
- Hardly difficult to do any analytics 
(real-time) 
- Different applications == different 
log formats
Problems 
Genologics support: 
”I took a look at the system. Unfortunately 
the logs are filling up in too quick of a 
time. I have increased the number of logs 
and the size of them. We should have more 
that one day of logs now.”
Problems 
rm -rf <all_the_logs>
ELK Stack 
! 
- Elasticsearch 
- Logstash 
- Kibana
Logstash
Logstash 
Index log records form 
different sources 
Re-format log data to be 
structured and ”queryable" 
Apply filters 
Store your structured data 
into Elasticsearch (and 
other outputs)
input { 
#Read messages from redis 
redis { 
host => "localhost" 
data_type => "list" 
password => "password" 
key => "python" 
codec => json 
} 
} 
! 
#We want to filter multiline events, and we'll suppose that multiline 
#events are composed by one event and the following ones starting with 
#a sapce (like anexception traceback) 
filter { 
multiline { 
type => "exception" 
pattern => "^s" 
what => "previous" 
add_tag => [ "exception" ] 
} 
} 
! 
output { 
elasticsearch { 
host => "tools.scilifelab.se" 
} 
}
Elasticsearch
Elasticsearch 
Built on top of Lucene 
Store complex data as 
structured JSON documents. 
All fields are indexed by 
default, and all the indices 
can be used in a single query. 
Schema free (good for logs) 
RESTful API
Kibana
Kibana 
No code required 
Real-time analysis for 
streaming data 
Customise and create 
dashboards 
For freeeee!!!
Shippers
Shippers 
Broker*
Shippers 
Broker* 
Indexer
Shippers 
Broker* 
Indexer 
Storage & search
Shippers 
Broker* 
Indexer 
Visualization 
Storage & search
Thank you!

Elk scilifelab

  • 1.
    ELK Stack Becauselogs are not meant to go to /dev/null Guillermo Carrasco @guillemch
  • 2.
  • 3.
    Logging & ELKstack What are logs? What are logs for? Theory vs reality Logstash & Elasticsearch Kibana
  • 4.
    What are logs? http://adam.herokuapp.com/past/2011/4/1/logs_are_streams_not_files/
  • 5.
    What are logs? 2014-09-19 13:08:37,972 INFO [MiSeqIntegrator] (SequencingIntegrationUtil) Extracted raw content - [cycleNumber = 308 , runFolder = "D:IlluminaMiSeqTemp 140904_M01320_0130_000000000-A9NE9" , netFolder = "Z:140904_M01320_0130_000000000-A9NE9" , Record http://adam.herokuapp.com/past/2011/4/1/logs_are_streams_not_files/
  • 6.
    What are logs? 2014-09-19 13:08:37,972 INFO [MiSeqIntegrator] (SequencingIntegrationUtil) Extracted raw content - [cycleNumber = 308 , runFolder = "D:IlluminaMiSeqTemp 140904_M01320_0130_000000000-A9NE9" , netFolder = "Z:140904_M01320_0130_000000000-A9NE9" , Record http://adam.herokuapp.com/past/2011/4/1/logs_are_streams_not_files/
  • 7.
    What are logs? 2014-09-19 13:08:37,972 INFO [MiSeqIntegrator] (SequencingIntegrationUtil) Extracted raw content - [cycleNumber = 308 , runFolder = "D:IlluminaMiSeqTemp 140904_M01320_0130_000000000-A9NE9" , netFolder = "Z:140904_M01320_0130_000000000-A9NE9" , Record http://adam.herokuapp.com/past/2011/4/1/logs_are_streams_not_files/
  • 8.
    What are logs? 2014-09-19 13:08:37,972 INFO [MiSeqIntegrator] (SequencingIntegrationUtil) Extracted raw content - [cycleNumber = 308 , runFolder = "D:IlluminaMiSeqTemp 140904_M01320_0130_000000000-A9NE9" , netFolder = "Z:140904_M01320_0130_000000000-A9NE9" , Record http://adam.herokuapp.com/past/2011/4/1/logs_are_streams_not_files/
  • 9.
    What are logs? 2014-09-19 13:08:37,972 INFO [MiSeqIntegrator] (SequencingIntegrationUtil) Extracted raw content - [cycleNumber = 308 , runFolder = "D:IlluminaMiSeqTemp 140904_M01320_0130_000000000-A9NE9" , netFolder = "Z:140904_M01320_0130_000000000-A9NE9" , Record MiSeqIntegrator.log HiSeqIntegrator.log apache.log GenStat.log supervisord.log … http://adam.herokuapp.com/past/2011/4/1/logs_are_streams_not_files/
  • 10.
    What are logs? 2014-09-19 13:08:37,972 INFO [MiSeqIntegrator] (SequencingIntegrationUtil) Extracted raw content - [cycleNumber = 308 , runFolder = "D:IlluminaMiSeqTemp 140904_M01320_0130_000000000-A9NE9" , netFolder = "Z:140904_M01320_0130_000000000-A9NE9" , Record MiSeqIntegrator.log HiSeqIntegrator.log apache.log GenStat.log supervisord.log … So logs are files? http://adam.herokuapp.com/past/2011/4/1/logs_are_streams_not_files/
  • 11.
    What are logs? 2014-09-19 13:08:37,972 INFO [MiSeqIntegrator] (SequencingIntegrationUtil) Extracted raw content - [cycleNumber = 308 , runFolder = "D:IlluminaMiSeqTemp 140904_M01320_0130_000000000-A9NE9" , netFolder = "Z:140904_M01320_0130_000000000-A9NE9" , Record MiSeqIntegrator.log HiSeqIntegrator.log apache.log GenStat.log supervisord.log … - Logs are time-oriented streams of records http://adam.herokuapp.com/past/2011/4/1/logs_are_streams_not_files/
  • 12.
    What are logsfor? Theory
  • 13.
    What are logsfor? Theory Provide real-time and valuable information about the execution of a program Use this information in your benefit: prevent problems, do analytics, plot status…
  • 14.
  • 15.
    Example: Our pipeline started job X for sample Y Aligning sample X Generating report for Project A.Sample_14_09 Cleaning /proj/a2010002/nobackup area
  • 16.
    Example: Our pipeline started job X for sample Y Aligning sample X Generating report for Project A.Sample_14_09 Cleaning /proj/a2010002/nobackup area Submitted jobs in the last X mins… Pipeline crashes in the last X days…
  • 17.
  • 18.
    Example: Illumina logs - Status of a particular run - Failures/Anomalies - Cycles sequenced today/this week/etc - …
  • 19.
    What are logsfor? Reality
  • 20.
    What are logsfor? Reality Something we look at ONLY when something has already gone wrong… if we can!
  • 21.
    On the previousexamples…
  • 22.
    On the previousexamples… - The pipeline logs are dumped to nextgen_analysis_server.log, in milou-b, under the functional account… and rotated! - The Illumina logs are just never looked at…
  • 23.
  • 24.
    Problems - Logsspread around servers and accounts - Rotating logs may disappear - If you don’t rotate, logs will fill up disks - Hardly difficult to do any analytics (real-time) - Different applications == different log formats
  • 25.
    Problems Genologics support: ”I took a look at the system. Unfortunately the logs are filling up in too quick of a time. I have increased the number of logs and the size of them. We should have more that one day of logs now.”
  • 26.
    Problems rm -rf<all_the_logs>
  • 27.
    ELK Stack ! - Elasticsearch - Logstash - Kibana
  • 28.
  • 29.
    Logstash Index logrecords form different sources Re-format log data to be structured and ”queryable" Apply filters Store your structured data into Elasticsearch (and other outputs)
  • 30.
    input { #Readmessages from redis redis { host => "localhost" data_type => "list" password => "password" key => "python" codec => json } } ! #We want to filter multiline events, and we'll suppose that multiline #events are composed by one event and the following ones starting with #a sapce (like anexception traceback) filter { multiline { type => "exception" pattern => "^s" what => "previous" add_tag => [ "exception" ] } } ! output { elasticsearch { host => "tools.scilifelab.se" } }
  • 31.
  • 32.
    Elasticsearch Built ontop of Lucene Store complex data as structured JSON documents. All fields are indexed by default, and all the indices can be used in a single query. Schema free (good for logs) RESTful API
  • 33.
  • 34.
    Kibana No coderequired Real-time analysis for streaming data Customise and create dashboards For freeeee!!!
  • 36.
  • 37.
  • 38.
  • 39.
    Shippers Broker* Indexer Storage & search
  • 40.
    Shippers Broker* Indexer Visualization Storage & search
  • 41.

Editor's Notes

  • #2 My name is… Today I want to talk about logging in general and ELK stack in particular.
  • #9 So, to have a look at the pipeline logs, you have to log into Uppmax, ssh to our functional account, and be lucky that you were not too slow…
  • #10 And not only the log rotation is a problem, let’s me honest… because what happens when you’re in your happy weekend and you receive a mail from NAGIOS telling…. etc Show timestamps!!!
  • #14 Also, other aspects like highly scalable and replication, of course - go out from the slides and show some API queries (the 15th of sept there are logs from milou)
  • #15 Also, other aspects like highly scalable and replication, of course - go out from the slides and show some API queries (the 15th of sept there are logs from milou)
  • #16 The broker is not really needed for the ELK stack to work, but eases life and is recommended for a production deploy.