Ubuntu/Debian
#
Elastic Stack InstallationElasticsearch is the distributed search and analytics engine at the heart of the Elastic Stack. The ElastiFlow Unified Flow Collector can be configured to store the collected, processed and enriched records in Elasticsearch. Kibana enables you to interactively explore, visualize, and share insights into your data and manage and monitor the stack. Elasticsearch is where the indexing, search, and analysis happens.
This document will describes in detail the installation of the ElastiFlow Unified flow collector and the Elastic Stack (Elasticsearch and Kibana) on a single server running Ubuntu Linux 20.04 LTS.
#
SizingElasticsearch can be deployed as a single-mode server or multi-node cluster. The latter provides for horizontal scaling to handle very high ingest rates and longer retention periods. For more information on properly sizing an Elasticsearch cluster, see Sizing.
#
EnvironmentResource | Information |
---|---|
Hostname | myhost |
IP Address | 192.168.56.101 |
CPU Cores | 4 |
Memory | 32 GB |
Storage | 1 TB |
OS | Ubuntu Server 20.04 LTS |
Elasticsearch | 7.17.0 |
Kibana | 7.17.0 |
ES Features | TLS, RBAC |
ElastiFlow UFC | 5.4.0 |
important
The hostname and IP address above are for examples only. You MUST replace these values with those of your own server when executing any commands or editing any files.
#
Tune the Linux Kernel#
1. Add Parameters Required by ElasticsearchElasticsearch uses a mmapfs
directory by default to store its indices. The Linux default limits on mmaps is usually too low, which can result in out-of-memory exceptions. This limit should be raised to 262144
.
Run the following command to add the file /etc/sysctl.d/70-elasticsearch.conf
with the attribute vm.max_map_count=262144
:
#
2. Tune Network ParametersThe default Linux network parameters are not optimal for high throughput applications, in particular a high volume of ingress UDP packets. This can result in dropped packets and lost data. Linux network performance for ElastiFlow can optimized by changing the parameters below.
Run the following command to add the file /etc/sysctl.d/60-net.conf
with the recommended changes.
#
3. Apply ChangesFor changes to the above parameters to take effect the system can be restarted. Alternatively the following commands can be run to apply the changes without a reboot:
#
Disable the FirewallThe easiest way to get started is to disable the Linux firewall. Alternatively the firewall can be configured to allow access to any required ports. Details of configuring the Linux firewall are beyond the scope of this document. However if enabled, you will need to allow access to the following ports:
Application | Port |
---|---|
Elasticsearch | TCP/9200 |
Kibana | TCP/5601 |
Unified Flow Collector | UDP 9995 or other port(s) configured by EF_FLOW_SERVER_UDP_PORT |
#
Install Prerequisite PackagesRun the following commands to install required packages.
#
Install Elasticsearch#
1. Add Elastic PGP KeyElastic signs all of their packages with the Elasticsearch Signing Key (PGP key D88E42B4
, available from https://pgp.mit.edu) with fingerprint: 4609 5ACC 8548 582C 1A26 99A9 D27D 666C D88E 42B4
Download and install the public signing key.
#
2. Add the Elastic RepositoryAdd the Elastic repository definition to /etc/apt/sources.list.d/elastic-7.x.list
by running the following command.
apt
#
3. Install Elasticsearch using Run the following commands to install the Elasticsearch package.
note
If two entries exist for the same Elasticsearch repository, you will see an error during apt update
similar to Duplicate sources.list entry https://artifacts.elastic.co/packages/7.x/apt/ ...
Examine /etc/apt/sources.list.d/elasticsearch-7.x.list
for the duplicate entry or locate the duplicate entry amongst the files in /etc/apt/sources.list.d/
and the /etc/apt/sources.list
file.
#
4. Configure JVM Heap SizeIf a JVM is started with unequal initial and max heap sizes, it may pause as the JVM heap is resized during system usage. For this reason it’s best to start the JVM with the initial and maximum heap sizes set to equal values.
Add the file heap.options
to /etc/elasticsearch/jvm.options.d
and set -Xms
and -Xmx
to about one third of the system memory, but do not exceed 31g
. For this example we will use 12GB of the available 32GB of memory for JVM heap.
#
5. Increase System LimitsIncreased system limits should be specified in a systemd
attributes file for the elasticsearch
service.
#
6. Generate CA and CertificatesThere are numerous ways to generate certificates that can be used to secure communications using TLS. To simplify the process Elastic provides the elasticsearch-certutil
tool. For more details about this tool, refer to Elastic's documentation.
It is first necessary to generate a certificate authority (CA) by running the following command.
When you see Please enter the desired output file [elastic-stack-ca.zip]:
press enter
to accept the default.
The resulting file will be placed in /usr/share/elasticsearch
. To unzip and move the CA key and cert to /etc/elasticsearch/certs
run the following commands.
To generate certificates for the Elasticsearch node, create a file named /usr/share/elasticsearch/instances.yml
similar to the following. Replace the values with those appropriate for your environment.
For example, in the system used for this guide, the name of the server is myhost
, the IP address is 192.168.56.101
and there is no name configured in DNS. The instance would contain:
Use elasticsearch-certutil
to genrate the certificates and keys from the CA and instances file.
The resulting file will be placed in /usr/share/elasticsearch
. To unzip and move the node keys and certs to /etc/elasticsearch/certs
run the following commands.
#
7. Edit elasticsearch.ymlEdit the Elasticsearch configuration file, /etc/elasticsearch/elasticsearch.yml
, replacing the contents of the file with the following configuration. Edit as necessary for your environment.
note
If you want Elasticsearch data to be stored on a different mount point, you must first create the directory and assign permissions to the elasticsearch
. For example, to store data on /mnt/data0
, run sudo mkdir /mnt/data0/elasticsearch && sudo chown -R elasticsearch:elasticsearch /mnt/data0/elasticsearch
. The edit the path.data
option in elasticsearch.yml
specifying this path.
#
8. Enable and Start ElasticsearchExecute the following commands to start Elsticsearch and enable it run automatically when the server boots:
Confirm Elasticsearch started successfully by executing:
#
9. Set Passwords for Elasticsearch Built-in AccountsExecute the following command for to setup passwords for the various built-in accounts:
The following will be displayed:
Answer y
, then enter and confirm passwords for the built-in Elasticsearch accounts.
#
10. Verify ElasticsearchEnsure that the Elasticsearch REST API is available by running the following:
The output should be similar to the following:
#
Install Kibanaapt
#
1. Install Kibana using Run the following commands to install the Kibana package.
#
2. Copy CA and CertificatesKibana will also require access to the CA, certifcates and keys. To use the same files that were created for Elasticsearch, copy them from /etc/elasticsearch
to /etc/kibana
.
#
3. Edit kibana.ymlEdit the Kibana configuration file /etc/kibana/kibana.yml
, replacing the contents of the file with the following configuration. Edit as necessary for your environment (especially elasticsearch.password
).
#
4. Enable and Start KibanaExecute the following commands:
Confirm Kibana started successfully by executing:
You should now be able to access Kibana at https://IP_OF_KIBANA_HOST:5601
. Since this HTTPS connection is using a self-signed certificate, you may see an error similar to the following.
Chrome:
Firefox:
Safari:
You need to either create an exception in your browser, or import and trust the CA certificate on the system running the browser. This can usually be achieved by downloading the ca.crt
file from the server. Double-clicking it will usually propt you to import the certificate. On MacOS the certificate should appear as follows in the keychain application after it is configured to be trusted.
You should now be able to connect to Kibana after allowing an exception. To login use the user elastic
and the password you defined earlier for this user.
#
Install the ElastiFlow Unified Flow CollectorThe ElastiFlow Unified Flow Collector can be installed natively on Ubuntu and Debian Linux. The instructions are available here. In this section we will cover the primary configuration options for the Elasticsearch output.
The Unified Flow Collector options are configured using environment variables. To configure the environment variables, edit the file /etc/systemd/system/flowcoll.service.d/flowcoll.conf
. For details on all of the configuration options, please refer to the Configuration Reference.
#
1. Request a Basic or Trial LicenseWithout a license key the ElastiFlow Unified Flow Collector run with a Community tier license. The Basic tier is also available at no cost and supports additional standard information elements. A license can be requested on the ElastiFlow website. Alternatively a 30-day Premium trial may be requested, which increases the scalability of the collector and enables all supported vendor and standard information elements.
note
After requesting a license it can take up to 30 minutes for the email to arrive.
License keys are generated per account. EF_FLOW_ACCOUNT_ID
must contain the Account ID for the Licence Key specified in EF_FLOW_LICENSE_KEY
. The number of licensed units will be 1
for a Basic license, and up to 64 for a 30-day Trial.
#
2. Copy CA CertificateThe Unified Flow Collector will require access to the CA certifcate to verify the Elasticsearch node. Copy the CA certifcate from /etc/elasticsearch/certs/ca/ca.crt
to /etc/elastiflow/ca/ca.crt
.
#
3. Enable the Elasticsearch OutputSet EF_FLOW_OUTPUT_ELASTICSEARCH_ENABLE
to true
to enable the Elasticsearch output.
#
4. Specify a SchemaThe Unified Flow Collector outputs data using ElastiFlow's CODEX schema. Optionally you can choose to output data in Elastic Common Schema (ECS). To do so, set EF_FLOW_OUTPUT_ELASTICSEARCH_ECS_ENABLE
to true
.
@timestamp
#
5. Source of There are multiple possible sources to set the value of @timestamp
field, which is the primary timestamp field used by Kibana. They supported options are:
Value | Field Used | Description |
---|---|---|
start | flow.start.timestamp | The flow start time indicated in the flow. |
end | flow.end.timestamp | The flow end time (or last reported time). |
export | flow.export.timestamp | The time from the flow record header. |
collect | flow.collect.timestamp | The time that the collector processed the flow record. |
Usually end
would be the best setting. However, in the case of poorly behaving or misconfigured devices, collect
may be the better option. The actual timestamp used may be different than configured depending on the content of the received records. If end
is not available the collector will fall back to export
. If export
is not available the collector will fall back to collect
.
#
6. Index Shards and ReplicasFor this small single node install set the number of shards to 1
and replicas to 0
.
note
The optimum value for these settings will depend on a number of factors. The number of shards should be at least 1 for each Elasticsearch data node in a cluster. Larger nodes (16+ CPU cores) and higher ingest rates can benefit from 2 shards per node. The largest nodes (64 CPU cores, 8 memory channels and multiple SSD drives) can even benefit from 3 or 4 shards per node. In a multi-node cluster 1 or more replicas may be specified for redundancy.
#
7. ILM LifecycleSet the Index Lifecycle Management (ILM) lifecyle to elastiflow
. The lifecycle policy will also need to be added later in Kibana Management.
#
8. Elasticsearch Server and CredentialsDefine the elasticsearch node to which the collector should connect and the credentials for which the password was defined during the Elasticsearch installation.
#
9. Encrypted Communications with TLSEnable TLS and specify the path to the CA certificate.
#
10. Enable and Start the Unified Flow CollectorExecute the following commands:
Confirm the service started successfully by executing:
The collector is now ready to receive flow records from the network infrastructure.
#
Import Kibana ObjectsThe last step is to import the Kibana saved objects and apply the recommended advanced settings. Follow the instuctions in the Kibana section of the documentation for detailed instructions.