Getting started with the ELK Stack monitoring solution
Security
The last step is to introduce some security to the stack. Until now, if you enabled access to the stack from all networks, it would mean that anyone could mess with the data. The ELK base configuration does not include any kind of access restrictions, but you can add security through plugins. Two options are the paid Elastic X-Pack Security plugin [4] and the OpenDistro [5] security plugin.
It is worth noting that another option would be to use a proxy service like Apache or Nginx to enforce authorization, but for consistency, I'll stick with a dedicated solution.
The basic scenario is, a user presents credentials that are verified against access backends. When the user's identity is confirmed, the security plugin assigns privileges and roles for the user (Figure 5).
When the OpenDistro plugin is enabled, Kibana presents a login panel (Figure 6).
The configuration for the OpenDistro plugin is stored in a few YAML files in /usr/share/elasticsearch/plugins/opendistro_security/securityconfig/
.
As you can see in Listing 16, the YAML file for the security plugin is organized by user account. The hash is an encrypted password generated with the hash.sh
script, which is located in the tools
subdirectory of the plugin directory. The opendistro_security_roles
entry lets you specify any of the predefined roles. Most of the roles are self explanatory, but a word is needed for the logstash
role, since it also includes permissions to write Beats indices. If you want to create your own roles, you have to modify the action_groups.yml
, roles.yml
, and roles_mapping.yml
file, which are located in the plugin's securityconfig
subdirectory. The config file can also refer to roles assigned in an authentication system such as LDAP or ActiveDirectory.
Listing 16
internal_users.yml
01 # All passwords are: 02 # qwerty 03 _meta: 04 type: "internalusers" 05 config_version: 2 06 07 admin: 08 hash: "$2y$12$N5/i8SBuGv9c8vI5fYNWFe2otKwYPbAfBpNObFjCDpRJQp0k55bfC" 09 reserved: true 10 hidden: true 11 opendistro_security_roles: 12 - all_access 13 description: "Demo admin user" 14 15 kibanaserver: 16 hash: "$2y$12$N5/i8SBuGv9c8vI5fYNWFe2otKwYPbAfBpNObFjCDpRJQp0k55bfC" 17 reserved: true 18 hidden: false 19 opendistro_security_roles: 20 - kibana_server 21 description: "Demo kibanaserver user" 22 23 kibana: 24 hash: "$2y$12$N5/i8SBuGv9c8vI5fYNWFe2otKwYPbAfBpNObFjCDpRJQp0k55bfC" 25 reserved: false 26 opendistro_security_roles: 27 - kibana_user 28 - readall_and_monitor 29 description: "Demo kibana user" 30 31 logstash: 32 hash: "$2y$12$N5/i8SBuGv9c8vI5fYNWFe2otKwYPbAfBpNObFjCDpRJQp0k55bfC" 33 reserved: true 34 hidden: false 35 opendistro_security_roles: 36 - logstash 37 description: "Demo Logstash & Beats user"
You can mark a user, role, role mapping, or action group as reserved. Resources that have the reserved flag set to true can't be changed using the REST API or Kibana. Reserved resources are not returned by the REST API and are not visible in Kibana.
In order to further harden your ELK stack, you can generate certificates to use with SSL and enable them in Elasticsearch, then add user credentials to the Kibana server as well as all beats. In the long run, however, it is a good idea to plug your stack into a company authentication service, such as Okta or LDAP.
Summary
ELK is an amazing solution that allows users to swiftly explore the status of the infrastructure. Although it was originally designed to handle logging, with later iterations and plugins, it has become a fully functional MAL tool (Monitoring-Alerting-Logging). This paper has touched on a few of the many potential options. Other notable features include fully configurable alerting, machine learning, anomaly detectors, and a performance analyzer.
Infos
- ELK Stack: https://www.elastic.co/elastic-stack
- Ansible: https://www.ansible.com/
- grok Filter: https://github.com/logstash-plugins/logstash-patterns-core/blob/master/patterns/grok-patterns
- X-Pack Security Plugin: https://www.elastic.co/guide/en/elasticsearch/reference/current/setup-xpack.html
- OpenDistro: https://opendistro.github.io/for-elasticsearch-docs/
- Code in this Article: https://github.com/szandala/ELK
« Previous 1 2 3
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.
News
-
Fedora 40 Beta Released Soon
With the official release of Fedora 40 coming in April, it's almost time to download the beta and see what's new.
-
New Pentesting Distribution to Compete with Kali Linux
SnoopGod is now available for your testing needs
-
Juno Computers Launches Another Linux Laptop
If you're looking for a powerhouse laptop that runs Ubuntu, the Juno Computers Neptune 17 v6 should be on your radar.
-
ZorinOS 17.1 Released, Includes Improved Windows App Support
If you need or desire to run Windows applications on Linux, there's one distribution intent on making that easier for you and its new release further improves that feature.
-
Linux Market Share Surpasses 4% for the First Time
Look out Windows and macOS, Linux is on the rise and has even topped ChromeOS to become the fourth most widely used OS around the globe.
-
KDE’s Plasma 6 Officially Available
KDE’s Plasma 6.0 "Megarelease" has happened, and it's brimming with new features, polish, and performance.
-
Latest Version of Tails Unleashed
Tails 6.0 is based on Debian 12 and includes GNOME 43.
-
KDE Announces New Slimbook V with Plenty of Power and KDE’s Plasma 6
If you're a fan of KDE Plasma, you'll be thrilled to hear they've announced a new Slimbook with an AMD CPU and the latest version of KDE Plasma desktop.
-
Monthly Sponsorship Includes Early Access to elementary OS 8
If you want to get a glimpse of what's in the pipeline for elementary OS 8, just set up a monthly sponsorship to help fund its continued existence.
-
DebConf24 to be Held in South Korea
Busan will be the location of the latest DebConf running July 28 through August 4