Skip to content
awick edited this page Apr 5, 2013 · 94 revisions

Table of Contents

Elasticsearch

How many elasticsearch nodes or machines do I need?

The answer of course is "it depends". Factors include how much memory each box has, how many days you want to store meta data for, how fast the disks are, what percentage of the traffic is HTTP, the average transfer rate of all the interfaces, if the sessions are long lived or short lived, how fast response times should be for operators, how many operators are querying at the same time, etc.

A rough guideline for NODES is 1/3 * Number_of_Gigabit_Interfaces * Number_of_Days_of_History. If you have large machines then you can run multiple nodes per MACHINE.

The good news is 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 elastic head interface to delete the oldest sessions-* index.

Data never gets deleted

Make sure you set up the db/daily.sh script to run once a day, during off peak. This script optimizes the previous days data and deletes the oldest data.

When do I add additional nodes? Why are queries slow?

If queries are too slow then the easiest fix is to add additional elasticsearch nodes. You should also use the bigdesk http://moloches-machine:9200/_plugin/bigdesk/ and watch the heap memory graph, if it is approaching the max it is time to add more nodes or reduce the number of days being stored.

Elasticsearch doesn't do well if Java hits a OutOfMemory condition. If you ever have one you should immediate delete the oldest sessions-* index, update the daily.sh script to delete more often, and restart the elasticsearch cluster. Then you should order more machines. :)

Adding additional nodes

  • Use the same elasticsearch.yml file on the new nodes, no changes are usually required
  • After starting the new elasticsearch nodes make sure they show up in bigdesk, if they don't show up check the logs and firewall issues
  • Run the "db/db.pl upgrade" script
NOTE: Today and past days will NOT take advantage of the new nodes. Only FUTURE days (sessions-* indexes) will use the new nodes since by default Moloch uses the number of shardes equal to the number of nodes.

How to enable elastic search replication

Turning on replication will consume twice the disk space on the nodes and increase the network bandwidth between nodes, so make sure you actually need replication.

To fix future days

  • Edit the db/db.pl file and change the number_of_replicas from 0 to 1
  • Run the "db/db.pl upgrade" script

Elasticsearch crashed and now won't return green

Make sure all the nodes are actually running by checking bigdesk. Before starting to scream, make sure to wait at least 5-10 minutes after restarting before giving up. The most likely cause is the _state directory is missing for various shards. If you can live without the ENTIRE day that isn't going green the easiest solution is to use elastic head to just delete the day, the sessions-* index. http://moloches-machine:9200/_plugin/head/

If you want to try and recover the rest of the day then you need

  • Find the machines with the missing index
  • Check to see if the shard even exists (For example shard 4 on 120715 would live in /disk1/data/Moloch/nodes/0/indices/sessions-120715/4)
  • If that directory is missing you need to create it by copying a empty version of the same directory from a temporary elastic search instance.
Upgrade to 0.19.10 or later which seems to fix this issue

Capture

Why am I dropping packets?

Need to check disk IO (iostat -xm 5) and CPU utilization/interrupts

  • If using RAID 5 make sure you have write cache enabled on the RAID card
    • Adaptec Example: arcconf SETCACHE 1 LOGICALDRIVE 1 WBB
  • Make sure you use taskset to give moloch-capture its own CPU
  • Check that the CPU you are giving moloch-capture isn't handling lots of interrupts (cat /proc/interrupts)
  • Make sure other processes aren't using the same CPU as moloch-capture
  • For ifdrop's increase the ring buffer using ethtool -g to view maximum and ethtool -G to set

How do I import existing PCAPs?

Think of the 'moloch-capture' binary much like you would 'tcpdump'. 'moloch-capture' can listen to live network interface(s), or read from historic packet capture files.

  • ${moloch_dir}/bin/moloch-capture -c [config_file] -r [pcap_file]
For an entire directory, use -R [pcap]

See ${moloch_dir}/bin/moloch-capture --help for more info

Viewer

Where do I learn more about the expressions available

Click on the owl

Map counts are wrong

  • The source and destination ips are each counted, so the map should total twice the number of sessions
  • Currently elasticsearch only has accurate counts up to 2 billion uniques
  • Some countries aren't shown, but can still be searched using their ISO-3

Browser security exception/replacing cert

By default the easybutton-singlehost.sh script creates a self signed cert. This will cause good browsers to throw a security exception.

Quick Fix

Most browsers have a method for adding a self signed cert so its accepted and stops showing warnings. Start with this google query https://www.google.com/search?q=adding+a+self+signed+certificate for suggestions on your browser

Correct Fix

  • Contact your pki folks and ask for a new cert, or purchase one
  • if you will have multiple viewer machines (or think you will) it is easier to give them ALL the host names at once so the single cert can have multiple alt names in it
  • Replace the /data/moloch/etc/moloch.crt and moloch.key files on all the viewer nodes
  • Restart the viewer (node) process

Clone this wiki locally