-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathfaq.html
More file actions
2291 lines (2212 loc) · 102 KB
/
Copy pathfaq.html
File metadata and controls
2291 lines (2212 loc) · 102 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="en">
<head>
<title>Moloch FAQ</title>
<!-- Required meta tags always come first -->
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
<meta http-equiv="x-ua-compatible" content="ie=edge" />
<meta name="description" content="Frequently asked Moloch questions" />
<!-- facebook open graph tags -->
<meta property="og:url" content="http://molo.ch/faq" />
<meta property="og:description" content="Frequently asked Moloch questions" />
<meta property="og:image" content="http://molo.ch/moloch_2x2.png" />
<!-- twitter card tags additive with the og: tags -->
<meta name="twitter:card" content="summary" />
<meta name="twitter:domain" value="molo.ch" />
<meta name="twitter:description" value="Frequently asked Moloch questions" />
<meta name="twitter:image" content="http://molo.ch/moloch_2x2.png" />
<meta name="twitter:url" value="http://molo.ch/faq" />
<!-- fontawesome http://fontawesome.io/ -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<!-- Bootstrap CSS https://getbootstrap.com/ -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
<!-- custom index page styles -->
<link rel="stylesheet" type="text/css" href="index.css">
</head>
<body id="viewport">
<div class="container">
<nav class="navbar navbar-dark bg-dark fixed-top navbar-expand-md">
<div class="navbar-brand">
<img src="simple_logo.png" />
<div class="ml-5">Moloch FAQ</div>
</div>
<ul class="nav navbar-nav mr-auto"></ul>
<form class="form-inline text-right">
<a href="https://molo.ch"
class="btn btn-sm btn-outline-success">
<span class="fa fa-arrow-left">
</span>
back to molo.ch homepage
</a>
</form>
</nav>
<div class="faq-content">
<h3>Table of Contents</h3>
<ul>
<li>
<a href="#general">General</a>
<ul>
<li><a href="#why-should-i-use-moloch">Why should I use Moloch?</a></li>
<li><a href="#upgrading-moloch">Upgrading Moloch</a></li>
<li><a href="#what-oses-are-supported">What OSes are supported?</a></li>
<li><a href="#moloch-is-not-working">Moloch is not working</a></li>
<li><a href="#how-do-i-reset-moloch">How do I reset Moloch?</a></li>
<li><a href="#self-signed-ssl-tls-certificates">Self-Signed SSL/TLS Certificates</a></li>
<li><a href="#how_do_i_upgrade_to_moloch_1">How do I upgrade to Moloch 1.0</a></li>
</ul>
</li>
<li>
<a href="#elasticsearch">Elasticsearch</a>
<ul>
<li><a href="#how-many-elasticsearch-nodes-or-machines-do-i-need">How many elasticsearch nodes or machines do I need?</a></li>
<li><a href="#data-never-gets-deleted">Data never gets deleted</a></li>
<li><a href="#error-dropping-request-_bulk">ERROR - Dropping request /_bulk</a></li>
<li><a href="#when-do-i-add-additional-nodes-why-are-queries-slow">When do I add additional nodes? Why are queries slow?</a></li>
<li><a href="#removing-nodes">Removing nodes</a></li>
<li><a href="#how-to-enable-elasticsearch-replication">How to enable elasticsearch replication</a></li>
<li><a href="#how-do-i-upgrade-elasticsearch">How do I upgrade elasticsearch?</a></li>
<li><a href="#how-do-i-upgrade-to-es-6-x">How do I upgrade to ES 6.x</a></li>
<li><a href="#how_do_i_upgrade_to_es_5x">How do I upgrade to ES 5.x</a></li>
<li><a href="#es-2-org-elasticsearch-common-breaker-circuitbreakingexception-fielddata-data-too-large">ES 2 - org.elasticsearch.common.breaker.CircuitBreakingException: [FIELDDATA] Data too large</a></li>
<li><a href="#recommended-elasticsearch-settings">Recommended Elasticsearch Settings</a></li>
</ul>
</li>
<li>
<a href="#capture">Capture</a>
<ul>
<li><a href="#what-kind-of-capture-machines-should-we-buy">What kind of capture machines should we buy?</a></li>
<li><a href="#what-kind-of-network-packet-broker-should-we-buy">What kind of Network Packet Broker should we buy?</a></li>
<li><a href="#what-kind-of-packet-capture-speeds-can-moloch-capture-handle">What kind of packet capture speeds can moloch-capture handle?</a></li>
<li><a href="#moloch_requires_full_packet_captures_error">Moloch requires full packet captures error</a></li>
<li><a href="#why-am-i-dropping-packets">Why am I dropping packets?</a></li>
<li><a href="#how-do-i-import-existing-pcaps">How do I import existing PCAPs?</a></li>
<li><a href="#how-do-i-monitor-multiple-interfaces">How do I monitor multiple interfaces?</a></li>
<li><a href="#moloch-capture-crashes">Moloch capture crashes</a></li>
<li><a href="#error-pcap-open-failed">ERROR - pcap open failed</a></li>
<li><a href="#how-to-reduce-amount-of-traffic-pcap">How to reduce amount of traffic/pcap?</a></li>
<li><a href="#life-of-a-packet">Life of a packet</a></li>
<li><a href="#pcap-deletion">PCAP Deletion</a></li>
<li><a href="#dontsavebpfs-doesn-t-work">dontSaveBPFs doesn’t work</a></li>
<li><a href="#zero-byte-pcap-files">Zero byte pcap files</a></li>
<li><a href="#can-i-virtualize-moloch-with-kvm-using-openvswitch">Can I virtualize Moloch with KVM using OpenVswitch?</a></li>
</ul>
</li>
<li>
<a href="#viewer">Viewer</a>
<ul>
<li><a href="#where-do-i-learn-more-about-the-expressions-available">Where do I learn more about the expressions available</a></li>
<li><a href="#exported-pcap-files-are-corrupt-sometimes-session-detail-fails">Exported pcap files are corrupt, sometimes session detail fails</a></li>
<li><a href="#map-counts-are-wrong">Map counts are wrong</a></li>
<li><a href="#what-browsers-are-supported">What browsers are supported?</a></li>
<li><a href="#viewer-doesn-t-run-after-upgrading-node-js">Viewer doesn’t run after upgrading Node.js</a></li>
<li><a href="#error-getaddrinfo-eaddrinfo">Error: getaddrinfo EADDRINFO</a></li>
<li><a href="#how-do-i-proxy-moloch-using-apache">How do I proxy Moloch using Apache</a></li>
<li><a href="#i-still-get-prompted-for-password-after-setting-up-apache-auth">I still get prompted for password after setting up apache auth</a></li>
<li><a href="#how-do-i-search-multiple-moloch-clusters">How do I search multiple Moloch clusters</a></li>
<li><a href="#how-do-i-use-self-signed-ssl-tls-certificates-with-multies">How do I use self-signed SSL/TLS Certificates with MultiES ?</a></li>
<li><a href="#how-do-i-reset-my-password">How do I reset my password?</a></li>
<li><a href="#error-couldn-t-connect-to-remote-viewer-only-displaying-spi-data">Error: Couldn’t connect to remote viewer, only displaying SPI data</a></li>
<li><a href="#compiled-against-a-different-node-js-version-error">compiled against a different Node.js version error</a></li>
</ul>
</li>
<li>
<a href="#parliament">Parliament</a>
<ul>
<li><a href="#sample-apache-config">Sample Apache Config</a></li>
</ul>
</li>
</ul>
</div>
<div>
<h2 id="general">
General
</h2>
<div>
<div>
<h3 id="why-should-i-use-moloch">
Why should I use Moloch?
</h3>
<div>
<p>If you want a standalone open source full packet capture (FPC) system with meta data parsing and searching then Moloch may be your answer!
Moloch allows you complete control of deployment and architecture.
There are <a href="https://github.com/aol/moloch/wiki/Other-FPC-Systems">other FPC systems</a> available.</p>
</div>
</div>
<div>
<h3 id="upgrading-moloch">
Upgrading Moloch
</h3>
<div>
<p>Upgrading Moloch requires you install versions in order, as described in the chart below.
If the version you are currently on isn’t listed please upgrade to the next higher version in the chart, you can then install the major releases in order to catch up.
New installs can start from the latest version.</p>
</div>
<table class="table table-sm table-bordered">
<thead>
<tr>
<th>
Moloch Version
</th>
<th>
ES Versions
</th>
<th>
Special Instructions
</th>
<th>
Notes
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<p>1.7</p>
</td>
<td>
<p>5.x or 6.x</p>
</td>
<td>
<p><a href="#how-do-i-upgrade-to-es-6-x">ES 6 instructions</a></p>
</td>
<td>
<p>Must have finished the 1.x reindexing, stop captures for best results</p>
</td>
</tr>
<tr>
<td>
<p>1.1.1</p>
</td>
<td>
<p>5.x or 6.x (new only)</p>
</td>
<td>
<p><a href="how_do_i_upgrade_to_moloch_1">Instructions</a></p>
</td>
<td>
<p>Must be on ES 5 already</p>
</td>
</tr>
<tr>
<td>
<p>0.20.2</p>
</td>
<td>
<p>2.4, 5.x</p>
</td>
<td>
<p><a href="#how_do_i_upgrade_to_es_5x">ES 5 instructions</a></p>
</td>
<td></td>
</tr>
</tbody>
</table>
</div>
<div>
<h3 id="what-oses-are-supported">
What OSes are supported?
</h3>
<div>
<p>We have RPMs/DEBs available at <a href="http://molo.ch/#downloads" rel="nofollow">http://molo.ch/#downloads</a>
Our deployment is on Centos 6 and Centos 7 with the elrepo 4.x kernel installed for packet performance increases and afpacket support.
A large amount of development is done on Mac OS X 10.13 using MacPorts, however, it has never been tested in a production setting. :)
Moloch is no longer supported on 32 bit machines.</p>
</div>
<div>
<p>Moloch requires gcc/g++ 4.8.4 or later to compile fully. This is because some nodejs packages require it.</p>
</div>
<div>
<p>The following OSes should work out of the box:</p>
</div>
<div>
<ul>
<li>
<p>CentOS 7</p>
</li>
<li>
<p>Ubuntu 14.04, 16.04</p>
</li>
<li>
<p>FreeBSD 9</p>
</li>
<li>
<p>FreeBSD 10.0 (wiseService doesn’t work, but the wise plugin does), 10.3 is known NOT to compile currently</p>
</li>
</ul>
</div>
<div>
<p>The following OSes should work after installing gcc/g++ 4.8 yourself</p>
</div>
<div>
<ul>
<li>
<p>CentOS 6 - <a href="https://wiki.centos.org/AdditionalResources/Repositories/SCL" rel="nofollow">https://wiki.centos.org/AdditionalResources/Repositories/SCL</a></p>
<pre><code>yum install centos-release-scl
yum install devtoolset-3-toolchain</code></pre>
</li>
<li>
<p>Ubuntu 12.04 - <a href="https://wiki.ubuntu.com/ToolChain" rel="nofollow">https://wiki.ubuntu.com/ToolChain</a></p>
<pre><code>add-apt-repository ppa:ubuntu-toolchain-r/test
apt-get update
apt-get install gcc-4.8</code></pre>
</li>
</ul>
</div>
</div>
<div>
<h3 id="moloch-is-not-working">
Moloch is not working
</h3>
<div>
<p>Here is the common check list:</p>
</div>
<div>
<ol>
<li>
<p>Check that Elasticsearch is running and green using <code>curl <a href="http://localhost:9200/_cat/health" rel="nofollow">http://localhost:9200/_cat/health</a></code> on the machine running Elasticsearch</p>
</li>
<li>
<p>Check that the db has been initialized with <code>/data/moloch/db/db.pl <a href="http://localhost:9200" rel="nofollow">http://localhost:9200</a> info</code></p>
</li>
<li>
<p>Check that viewer is reachable by visiting <code><a href="http://viewerhostname:8005" rel="nofollow">http://viewerhostname:8005</a></code> from your browser</p>
<div>
<ol type="a">
<li>
<p>If it doesn’t render, looks strange or warns of an old browser, use a newer <a href="#what-browsers-are-supported">supported browser</a></p>
</li>
</ol>
</div>
</li>
<li>
<p>Check for errors in <code>/data/moloch/logs/viewer.log</code> and that viewer is running with <code>pgrep -lf viewer</code></p>
</li>
<li>
<p>Check for errors in <code>/data/moloch/logs/capture.log</code> and that capture is running with <code>pgrep -lf capture</code></p>
</li>
<li>
<p>Check that the stats page shows the capture nodes you are expecting, visit <code><a href="http://viewer.host.name:8005/stats" rel="nofollow">http://viewer.host.name:8005/stats</a></code> in your browser</p>
<div>
<ol type="a">
<li>
<p>Make sure the nodes are showing packets being received</p>
</li>
<li>
<p>Make sure the timestamp for nodes is recent (within 5 seconds)</p>
</li>
</ol>
</div>
</li>
<li>
<p>Verify that there is no <code>bpf=</code> in <code>/data/moloch/etc/config.ini</code> that is dropping all the traffic</p>
</li>
<li>
<p>If viewer in the browser has "Oh no, Moloch is empty! There is no data to search." but the stats tab shows packets are being captured</p>
<div>
<ol type="a">
<li>
<p>Moloch only writes records when a session has ended, it will take several minutes for session to show up after a fresh start, see <code>/data/moloch/etc/config.ini</code> to shorten the timeouts</p>
</li>
<li>
<p>Verify your time frame for search covers the data (try switching to ALL)</p>
</li>
<li>
<p>Check that you don’t have a view set</p>
</li>
<li>
<p>Check that your user doesn’t have a forced expression set</p>
</li>
</ol>
</div>
</li>
<li>
<p>Restart moloch-capture after adding a <code>--debug</code> option may print out useful information what is wrong if you are having packet capture issues. You can add multiple <code>--debug</code> options to get even more information.
Capture will print out the config settings it is using, verify they are what you expect.</p>
</li>
<li>
<p>Restart viewer after adding a <code>--debug</code> option may print out useful information what is wrong if you are having issues viewing packets that were captured</p>
<div>
<ol type="a">
<li>
<p>Make sure the plugins and parsers directories are correctly set in <code>/data/moloch/etc/config.ini</code> and readable by viewer process</p>
</li>
</ol>
</div>
</li>
</ol>
</div>
</div>
<div>
<h3 id="how-do-i-reset-moloch">
How do I reset Moloch?
</h3>
<div>
<ol>
<li>
<p>Leave elasticsearch running</p>
</li>
<li>
<p>Shutdown all running viewer or capture processes so no new data is recorded.</p>
</li>
<li>
<p>To delete all the SPI data stored in elasticsearch, use the <code>db.pl</code> script with either the <code>init</code> or <code>wipe</code> commands. The only difference between the two commands is that <code>wipe</code> leaves the
added users so they don’t need to be re-added.</p>
</li>
</ol>
</div>
<div>
<pre><code>/data/moloch/db/db.pl ESHOST:ESPORT wipe</code></pre>
</div>
<div>
<ol>
<li>
<p>Delete the pcap files. The PCAP files are stored on the file system in raw format. You need to do this on <strong>all</strong> of the capture machines</p>
</li>
</ol>
</div>
<div>
<pre><code>/bin/rm -f /data/moloch/raw/*</code></pre>
</div>
</div>
<div>
<h3 id="self-signed-ssl-tls-certificates">
Self-Signed SSL/TLS Certificates
</h3>
<div>
<p>It is possible to get self signed certificates to work in the following scenarios:</p>
</div>
<div>
<ul>
<li>
<p>User to Moloch Viewer</p>
</li>
<li>
<p>Viewer to Elasticsearch</p>
</li>
<li>
<p>Capture to Elasticsearch</p>
</li>
<li>
<p>MultiES to Elasticsearch</p>
</li>
<li>
<p>Viewer to MultiES</p>
</li>
</ul>
</div>
<div>
<p>That said, the core team does not support or recommend it. Use the money you are saving on a commercial product and go buy real certs. Wildcard certs are now cheap and you can even go with free Lets Encrypt certs.
There may be folks on the Moloch slack workspace willing to help out.</p>
</div>
<div>
<p>Both capture and viewer can run with <code>--insecure</code> to turn off cert checking.</p>
</div>
</div>
<div>
<h3 id="how_do_i_upgrade_to_moloch_1">
How do I upgrade to Moloch 1.0
</h3>
<div>
<p>Moloch 1.0 has some large changes and updates that will require all session data to be reindexed.
The reindexing is done in the background AFTER upgrading so there is little downtime. Large changes in 1.0 include:</p>
</div>
<div>
<ul>
<li>
<p>All the field names have been renamed, and analyzed fields have been removed</p>
</li>
<li>
<p>Country codes are being changed from 3 character to 2 character</p>
</li>
<li>
<p>Tags will NOT be migrated if added before 0.14.1</p>
</li>
<li>
<p>The data for http.hasheader and email.hasheader will NOT migrate</p>
</li>
<li>
<p>IPv6 is fully supported and uses the Elasticsearch ip type</p>
</li>
</ul>
</div>
<div>
<p>If you have any special parsers, tagger, plugins or wise source you may have to change configurations.</p>
</div>
<div>
<ul>
<li>
<p>All db fields will need -term removed, capture won’t start and will warn you</p>
</li>
</ul>
</div>
<div>
<p>To upgrade:</p>
</div>
<div>
<ul>
<li>
<p>First make sure you are using ES 5.5.x (5.6 recommended) and Moloch 0.20.2 or 0.50.x before continuing. Upgrade to those version first!</p>
</li>
<li>
<p>Download 1.1.1 from <a href="https://molo.ch/#downloads" rel="nofollow">https://molo.ch/#downloads</a></p>
</li>
<li>
<p>Shutdown all capture, viewer and wise processes</p>
</li>
<li>
<p>Install Moloch 1.1.1</p>
</li>
<li>
<p>Run <code>/data/moloch/bin/moloch_update_geo.sh</code> on all capture nodes which will download the new mmdb style maxmind files</p>
</li>
<li>
<p>Run <code>db.pl <a href="http://localhost:9200" rel="nofollow">http://localhost:9200</a> upgrade</code> once</p>
</li>
<li>
<p>Start wise, then capture, then viewers. Especially watch the capture.log file for any warnings/errors.</p>
</li>
<li>
<p>Verify that NEW data is being collected and showing up in viewer, all old data will NOT show up yet.</p>
</li>
</ul>
</div>
<div>
<p>Once 1.1.1 is working, its time to reindex the old session data:</p>
</div>
<div>
<ul>
<li>
<p>Disable any db.pl expire or optimize jobs, or curator</p>
</li>
<li>
<p>Start screen or tmux since this will take several days</p>
</li>
<li>
<p>In the /data/moloch/viewer directory run <code>/data/moloch/viewer/reindex2.js --slices X</code></p>
<div>
<ul>
<li>
<p>The number of slices should be between 2 and the number of shards each index has, the higher the faster but more elasticsearch CPU that will be used. We recommend 1/2 the number of shards.</p>
</li>
<li>
<p>You can optionally add a --index option if there are indices you need to reindex first, otherwise it will work from newest to oldest</p>
</li>
<li>
<p>You can optionally add a --deleteOnDone, which will delete indices as they are converted, but you may want to try a reindex first on 1 index to make sure it is working.</p>
</li>
</ul>
</div>
</li>
<li>
<p>As reindex runs old data will show up in viewer</p>
</li>
<li>
<p>Delete ALL old indices with
</p>
<pre><code>curl -XDELETE 'http://localhost:9200/sessions-*'</code></pre>
</li>
<li>
<p>Once the reindex finishes run the db.pl expire/optimize or curator job manually, this will take a while</p>
</li>
<li>
<p>Now can reenable any db.pl expire or optimize jobs, or curator. <strong>Do NOT reenable crons until you let them run and finish manually.</strong></p>
</li>
</ul>
</div>
</div>
</div>
</div>
<div>
<h2 id="elasticsearch">
Elasticsearch
</h2>
<div>
<div>
<h3 id="how-many-elasticsearch-nodes-or-machines-do-i-need">
How many elasticsearch nodes or machines do I need?
</h3>
<div>
<p>The answer, of course, is "it depends". Factors include:</p>
</div>
<div>
<ul>
<li>
<p>How much memory each box has</p>
</li>
<li>
<p>How many days you want to store meta data (SPI data) for</p>
</li>
<li>
<p>How fast the disks are</p>
</li>
<li>
<p>What percentage of the traffic is HTTP</p>
</li>
<li>
<p>The average transfer rate of all the interfaces</p>
</li>
<li>
<p>If the sessions are long lived or short lived</p>
</li>
<li>
<p>How fast response times should be for operators</p>
</li>
<li>
<p>How many operators are querying at the same time</p>
</li>
</ul>
</div>
<div>
<p>Some important things to remember when designing your cluster:</p>
</div>
<div>
<ul>
<li>
<p>1Gbps of network traffic requires ~300GB of disk a day. For example, to store 14 days of 2.5Gbps average traffic you need 14*2.5*300 or ~10TB of disk space.</p>
</li>
<li>
<p>SPI data is usually kept longer then PCAP data. For example, you may store pcap for a week but SPI data for a month.</p>
</li>
<li>
<p>Have at least 3% of disk space available in memory. For example, if the cluster has 7TB of data then 7*0.03 or 210GB of memory is the minimum recommended. Note: the more days store the memory ratio can actually decrease, to 2% or 1%.
</p>
</li>
<li>
<p>Assign half the memory to Elasticsearch (but no more then 31G per node, read <a href="https://www.elastic.co/blog/a-heap-of-trouble" rel="nofollow">https://www.elastic.co/blog/a-heap-of-trouble</a>) and half the memory to disk cache.
</p>
</li>
<li>
<p>Use version 5 of Elasticsearch or later.</p>
</li>
</ul>
</div>
<div>
<p>If you have large machines, they you can run multiple nodes per MACHINE. We have some <a href="https://molo.ch/#estimators" rel="nofollow">estimators</a> that may help.</p>
</div>
<div>
<p>The good news is that it is easy to add new nodes in the future, so feel free to start with less nodes. As a temporary fix to capacity problems, you can reduce the number of days of meta data that are stored. Just use the elasticsearch
head interface to delete the oldest <code>sessions-*</code> index.</p>
</div>
</div>
<div>
<h3 id="data-never-gets-deleted">
Data never gets deleted
</h3>
<div>
<p>The SPI data and the PCAP data are not deleted at the same time.
The PCAP data is deleted as the disk fills up on the capture machines, <a href="#pcap-deletion">more info</a>.
The SPI data is deleted when the <code>./db.pl expire</code> command is run, usually from cron during off peak.
There is a sample in the daily.sh script.</p>
</div>
<div>
<p>So deleting a PCAP file will NOT delete the SPI data, and deleting the SPI data will not delete the PCAP data from disk.</p>
</div>
<div>
<p>The UI does have commands to delete and scrub individual sessions, but the user must have the <code>Remove Data</code> ability on the users tab.
Usually this is used for things you don’t want operators to see, such as bad images.</p>
</div>
</div>
<div>
<h3 id="error-dropping-request-_bulk">
ERROR - Dropping request /_bulk
</h3>
<div>
<p>This error almost always means that your Elasticsearch cluster can not keep up with the amount of sessions that the capture nodes are trying to send it.
You may only see the error message on your busiest capture nodes since capture tries to buffer the requests.</p>
</div>
<div>
<p>Some things to check:</p>
</div>
<div>
<ul>
<li>
<p>Since Moloch 1.7.0 the ES Nodes tab of the Stats section now has the ability to turn on Write Task completed and rejected columns. Look for nodes having issues. Make sure those nodes don’t have disk issues.</p>
</li>
<li>
<p>Make sure each Elasticsearch node has 30G of memory (no more) and 30G of disk cache (at least) available to it. So for example if you are on a 64G machine only run 1 Elasticsearch node on the machine.</p>
</li>
<li>
<p>Make sure swap is turned off on Elasticsearch machines.</p>
</li>
<li>
<p>If you are running multiple Elasticsearch nodes make sure the disks can support the iops load</p>
</li>
<li>
<p>Make sure you are running the latest Elasticsearch that the version of Moloch supports, for example 5.6.7 if using Elasticesarch 5</p>
</li>
<li>
<p>If using replication on the sessions index, turn off replication of the current day and only replicate past days. This can be done by using <code>--replicas 1</code> with your daily <code>./db.pl expire</code> run after turning off
replicate in the sessions template using <code>./db.pl upgrade</code> without the <code>--replicas</code> option</p>
</li>
<li>
<p>Make sure there is at most 1 shard of each sessions per node, if there are more run <code>./db.pl upgrade</code> again</p>
</li>
<li>
<p>You can increase the size of the write task Q in elasticsearch, see <a href="#recommended-elasticsearch-settings">Recommended Elasticsearch Settings</a>.</p>
</li>
</ul>
</div>
<div>
<p>If these don’t help, you need to add more nodes or reduce the number of sessions being monitored. You can reduce the number of sessions with <a href="./Settings#packetdropips">packet-drop-ips</a> or bpf filters or <a
href="./RulesFormat">rules files</a> for example.</p>
</div>
</div>
<div>
<h3 id="when-do-i-add-additional-nodes-why-are-queries-slow">
When do I add additional nodes? Why are queries slow?
</h3>
<div>
<p>If queries are too slow the easiest fix is to add additional elasticsearch nodes.
Elasticsearch doesn’t do well if Java hits an OutOfMemory condition.
If you ever have one, you should immediately delete the oldest sessions2-* index, update the <code>daily.sh</code> script to delete more often, and restart the elasticsearch cluster.
Then you should order more machines. :)</p>
</div>
</div>
<div>
<h3 id="removing-nodes">
Removing nodes
</h3>
<div>
<ul>
<li>
<p>Go into the Moloch stats page and the ES Shards subtab</p>
</li>
<li>
<p>Click on the nodes you want to remove and exclude them</p>
</li>
<li>
<p>Wait for the shards to be moved off.</p>
</li>
<li>
<p>If no shards move, you may need to config Elasticsearch to allow 2 shards per node, although a large number may be required if removing many nodes.
</p>
<pre><code>curl -XPUT 'localhost:9200/sessions*/_settings' -d '{
"index.routing.allocation.total_shards_per_node": 2
}'</code></pre>
</li>
<li>
<p>If there are many shards that need to be redistributed, the defaults might take days, which is good for the cluster, but it might make you crazy. Increase the speed from default 3 streams at 20mb (60mb/sec) to something higher like 6
streams at 50mb (300mb/sec). Obviously, adjust for the speed of the new nodes' disks and network.
</p>
<pre><code>curl -XPUT localhost:9200/_cluster/settings -d '{"transient":{
"indices.recovery.concurrent_streams":6,
"indices.recovery.max_bytes_per_sec":"50mb"}
}'</code></pre>
</li>
</ul>
</div>
</div>
<div>
<h3 id="how-to-enable-elasticsearch-replication">
How to enable elasticsearch replication
</h3>
<div>
<p>Turning on replication will consume twice the disk space on the nodes and increase the network bandwidth between nodes, so make sure you actually <strong>need</strong> replication.</p>
</div>
<div>
<p>To change future days (since 0.14.1):
</p>
<pre><code>db/db.pl <ESHOST:ESPORT> upgrade --replicas 1</code></pre>
</div>
<div>
<p>To change past days, but not the current day (since 0.14.1):
</p>
<pre><code>db/db.pl <ESHOST:ESPORT> expire <type> <num> --replicas 1</code></pre>
</div>
<div>
<p>We recommend the second solution since it allows current traffic to be written to ES once, and during off peak the previous days traffic will be replicated.</p>
</div>
</div>
<div>
<h3 id="how-do-i-upgrade-elasticsearch">
How do I upgrade elasticsearch?
</h3>
<div>
<p><a href="https://www.elastic.co/guide/en/elasticsearch/reference/2.3/rolling-upgrades.html" rel="nofollow">Rolling upgrades</a> are supported for elasticesearch 2.x when doing a minor upgrade. In all other cases you must shutdown the
entire cluster and restart it with the new version.</p>
</div>
<div>
<ul>
<li>
<p>Download latest elasticsearch from <a href="http://www.elasticsearch.org/downloads/" rel="nofollow">http://www.elasticsearch.org/downloads/</a></p>
</li>
<li>
<p>Uncompress archive and move into <code>/data/moloch</code> (if using single host config)</p>
</li>
<li>
<p>Edit the ES start script so it has the correct version, <code>/data/moloch/bin/run_es.sh</code> (if using single hostconfig)</p>
</li>
<li>
<p>Shutdown current elasticsearch node:
</p>
<pre><code>kill <pid(s)></code></pre>
</li>
<li>
<p>Start the new version back up:
</p>
<pre><code>/data/moloch/bin/run_es.sh</code></pre>
</li>
</ul>
</div>
</div>
<div>
<h3 id="how-do-i-upgrade-to-es-6-x">
How do I upgrade to ES 6.x
</h3>
<div>
<p><strong>ES 6.x is supported by Moloch 1.x for NEW clusters and >= 1.5 for UPGRADING clusters.</strong></p>
</div>
<div>
<p>NOTE - If upgrading, you must FIRST upgrade to Moloch 1.0 or 1.1 (1.1.1 recommended) before upgrading to > 1.5. Also all reindex operations needs to be finished.</p>
</div>
<div>
<p>We do NOT provide ES 6 startup scripts or configuration, so if upgrading please make sure you get startup scripts working on test machines before shutting down your current cluster.</p>
</div>
<div>
<p><strong>Upgrading to ES 6 will REQUIRE two downtimes </strong></p>
</div>
<div>
<p>First outage: If you are NOT using Moloch DB version 51 (or later) you must follow these steps while still using ES 5.x. To find what DB version you are using, either run <code>db.pl localhost:9200 info</code> or mouse over the (I) in
Moloch.</p>
</div>
<div>
<ul>
<li>
<p>Install Moloch >= 1.5</p>
</li>
<li>
<p>Shutdown capture</p>
</li>
<li>
<p>run <code>./db.pl <a href="http://ESHOST:9200" rel="nofollow">http://ESHOST:9200</a> upgrade</code></p>
</li>
<li>
<p>Restart capture</p>
</li>
<li>
<p>Verify everything is working</p>
</li>
<li>
<p>Make sure you delete the old indices that db.pl complained about</p>
</li>
</ul>
</div>
<div>
<p>Second outage: Upgrade to ES 6</p>
</div>
<div>
<ul>
<li>
<p>Make sure you delete the old indices that db.pl complained about</p>
</li>
<li>
<p>Shutdown everything</p>
</li>
<li>
<p>Upgrade ES to 6.x</p>
</li>
<li>
<p><strong>WARNING</strong> - path.data will have to be updated to access your old data. If you had path.data: /data/foo you will probably need to change to /data/foo/<clustername></p>
</li>
<li>
<p>Start ES cluster</p>
</li>
<li>
<p>Wait for cluster to go GREEN, this will take <strong>LONGER</strong> then usual as ES upgrades things from 5.x to 6.x format.
<code>curl <a href="http://localhost:9200/_cat/health" rel="nofollow">http://localhost:9200/_cat/health</a></code></p>
</li>
<li>
<p>Start viewers and captures</p>
</li>
</ul>
</div>
</div>
<div>
<h3 id="how_do_i_upgrade_to_es_5x">
How do I upgrade to ES 5.x
</h3>
<div>
<p><strong>ES 5.x is supported by Moloch 0.17.1 for NEW clusters and 0.18.1 for UPGRADING clusters.</strong></p>
</div>
<div>
<p>ES 5.0.x, 5.1.x and 5.3.0 are NOT supported because of ES bugs/issues. We currently use 5.6.7.</p>
</div>
<div>
<p>WARNING - If you have sessions-* indices created with ES 1.x, you can NOT upgrade. Those indices will need to be deleted.</p>
</div>
<div>
<p>We do NOT provide ES 5 startup scripts, so if upgrading please make sure you get startup scripts working on test machines before shutting down your current cluster.</p>
</div>
<div>
<p><strong>Upgrading to ES 5 may REQUIRE 2 downtime periods of about 5-15 minutes each.</strong></p>
</div>
<div>
<p>First outage: If you are NOT using Moloch DB version 34 (or later) you must follow these steps while still using ES 2.4. To find what DB version you are using, either run <code>db.pl localhost:9200 info</code> or mouse over the (I) in
Moloch.</p>
</div>
<div>
<ul>
<li>
<p>Upgrade to ES 2.4.x</p>
</li>
<li>
<p>Check for GREEN ES cluster <code>curl <a href="http://localhost:9200/_cat/health" rel="nofollow">http://localhost:9200/_cat/health</a></code></p>
</li>
<li>
<p>Install Moloch 0.18.1 to 0.20.2</p>
</li>
<li>
<p>Shut down all capture nodes</p>
</li>
<li>
<p>Run <code>./db.pl <a href="http://ESHOST:9200" rel="nofollow">http://ESHOST:9200</a> upgrade</code></p>
</li>
<li>
<p><strong>Start up captures and make sure everything works</strong></p>
</li>
<li>
<p>You can remain on ES 2.4.x until you want to try ES 5</p>
</li>
</ul>
</div>
<div>
<p>Second outage: Upgrade to ES 5</p>
</div>
<div>
<ul>
<li>
<p>You MUST be on ES 2.4.x and Moloch DB version 34 (or later) before using ES 5 (see above)</p>
</li>
<li>
<p>Shutdown EVERYTHING (elasticsearch, viewer, capture)</p>
</li>
<li>
<p>Upgrade ES to 5.6.x</p>
</li>
<li>
<p>Start ES cluster</p>
</li>
<li>
<p>Wait for cluster to go GREEN, this will take <strong>LONGER</strong> then usual as ES upgrades things from 2.x to 5.x format. <code>curl <a href="http://localhost:9200/_cat/health"
rel="nofollow">http://localhost:9200/_cat/health</a></code></p>
</li>
<li>
<p>Start viewers and captures</p>
</li>
</ul>
</div>
</div>
<div>
<h3 id="es-2-org-elasticsearch-common-breaker-circuitbreakingexception-fielddata-data-too-large">
ES 2 - org.elasticsearch.common.breaker.CircuitBreakingException: [FIELDDATA] Data too large
</h3>
<div>
<p>This seems to happen with old indices that are upgraded from ES versions before 2 to ES 2, because old indices didn’t use the <code>doc_values</code> settings. Increasing the size of the fielddata cache will fix the problem.</p>
</div>
<div>
<p>Either edit your elasticsearch.yml and add:
</p>
<pre><code>indices.breaker.fielddata.limit: 80%</code></pre>
or run the command:
<pre><code>curl -XPUT localhost:9200/_cluster/settings -d '{
"persistent" : {
"indices.breaker.fielddata.limit" : "80%"
}
}'</code></pre>
</div>
<div>
<p>If that doesn’t work, you can try increasing the heap size per node, but don’t go over 31G. For more information, read <a href="https://www.elastic.co/guide/en/elasticsearch/guide/current/heap-sizing.html" rel="nofollow">the heap sizing
guide</a></p>
</div>
</div>
<div>
<h3 id="recommended-elasticsearch-settings">
Recommended Elasticsearch Settings
</h3>
<div>
<p>Here are some of our recommended Elasticsearch settings. Many of these can be updated on the fly, but it is still best to put them in your <code>elasticsearch.yml</code> file. We strongly recommend using the same
<code>elasticsearch.yml</code> file on all hosts, things that need to be different per host can be set with variables.</p>
</div>
<div>
<h4 id="disk-watermark">
Disk Watermark
</h4>
<div>
<p>You will probably want to change the watermark settings so you can use more of your disk space. You have the option to use ALL percentages or ALL values, but you can’t mix them. The most common sign of a problem with these settings is
an error that has <code>FORBIDDEN/12/index read-only / allow delete</code> in it. You can use <code>./db.pl <a href="http://localhost:9200" rel="nofollow">http://localhost:9200</a> unflood-stage _all</code> to clear the error, once you
adjust the settings and/or delete some data.
<a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/disk-allocator.html" rel="nofollow">Elasticsearch Docs</a></p>
</div>
<div>
<pre><code>cluster.routing.allocation.disk.watermark.low: 97%
cluster.routing.allocation.disk.watermark.high: 98%
cluster.routing.allocation.disk.watermark.flood_stage: 99%</code></pre>
</div>
<div>
<p>or if you want more control use values instead of percentages.</p>
</div>
<div>
<pre><code>cluster.routing.allocation.disk.watermark.low: 300gb
cluster.routing.allocation.disk.watermark.high: 200gb
cluster.routing.allocation.disk.watermark.flood_stage: 100gb</code></pre>
</div>
</div>
<div>
<h4 id="shard-limit">
Shard Limit
</h4>
<div>
<p>If you have a lot of shards that you want to be able to search against at once
<a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/search.html" rel="nofollow">Elasticsearch Docs</a>
</p>
<pre><code>action.search.shard_count.limit: 100000</code></pre>