<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>splunk &#8211; Blog of Kliment Andreev &#8211; A place so I won&#039;t forget things</title>
	<atom:link href="https://blog.andreev.it/tag/splunk/feed/" rel="self" type="application/rss+xml" />
	<link>https://blog.andreev.it</link>
	<description></description>
	<lastBuildDate>Sat, 31 Oct 2020 14:33:15 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	
	<item>
		<title>General: splunk &#8211; Quick Install Guide</title>
		<link>https://blog.andreev.it/2018/07/132-splunk-quick-install-guide/</link>
					<comments>https://blog.andreev.it/2018/07/132-splunk-quick-install-guide/#respond</comments>
		
		<dc:creator><![CDATA[Kliment Andreev]]></dc:creator>
		<pubDate>Wed, 25 Jul 2018 20:11:53 +0000</pubDate>
				<category><![CDATA[DevOps]]></category>
		<category><![CDATA[splunk]]></category>
		<guid isPermaLink="false">http://blog.iandreev.com/?p=3918</guid>

					<description><![CDATA[In this post I&#8217;ll describe how to install Splunk on a CentOS 7.x server,&#8230;]]></description>
										<content:encoded><![CDATA[<div id="bsf_rt_marker"></div><p>In this post I&#8217;ll describe how to install Splunk on a CentOS 7.x server, join it to the AD, install SSL certificates and configure reverse proxy. In addition, I&#8217;ll install forwarders on Windows, FreeBSD and  CentOS. The version of Splunk that I am using is 7.1.2.</p>
<h1>Splunk installation</h1>
<p>The installation is very simple. Once you create an account and log in, you can download the Linux installer. Log as root and put the tarball under <strong>/tmp</strong> on the Splunk server and extract it under <strong>/opt</strong>.</p>
<pre class="brush: bash; title: ; notranslate">
tar xzvf splunk-7.1.2-a0c72a66db66-Linux-x86_64.tgz -C /opt
</pre>
<p>Make sure you disable SELinux by editing <strong>/etc/selinux/config</strong> and change <strong>SELINUX=enforcing</strong> to <strong>SELINUX=permissive</strong>. Also, type <strong>setenforce 0</strong>.<br />
Go to the <strong>/opt</strong> folder and start Splunk.</p>
<pre class="brush: bash; title: ; notranslate">
cd /opt/splunk/bin
./splunk start
</pre>
<p>You&#8217;ll be prompted to accept the license and enter the admin password. Once completed in 10-20 seconds, you&#8217;ll get a message that &#8220;The Splunk web interface is at http://splunk-dev.andreev.local:8000&#8221; or whatever you named your server.<br />
If you want to start Splunk on each boot, you&#8217;ll have to type.</p>
<pre class="brush: bash; title: ; notranslate">
./splunk enable boot-start
</pre>
<p>If you go to your Splunk server now by visiting http://splunk-ip:8000, you&#8217;ll see the login page. If you are getting time-out, make sure that port 8000 is open on the firewall.</p>
<pre class="brush: bash; title: ; notranslate">
firewall-cmd --zone=public --permanent --add-port=8000/tcp
firewall-cmd --reload
</pre>
<p>Once you see the login page, you can log in as <strong>admin </strong>and the password you chose when you installed Splunk.</p>
<h1>AD Integration</h1>
<p>Most likely, you&#8217;ll want to integrate Splunk with your corporate Active Directory. This is how it can be done. But, let&#8217;s check the AD first and see what do we have there. In my case, I have a user called <strong>svc_splunk</strong> that will do the LDAP queries for the Splunk server. This user is under the <strong>Users OU</strong>. Also, I have an OU called <strong>Groups </strong>and I have three groups there, <strong>Splunk Admins, Splunk Users</strong> and <strong>Splunk Power Users</strong>.<br />
Go to Splunk logged as admin and under <strong>Settings </strong>from the main menu, look at the lower right corner and you&#8217;ll see the <strong>Access controls</strong>. When the new screen appears, click the <strong>Authentication method</strong>. Select <strong>LDAP </strong>and click to <strong>Configure Splunk to use LDAP</strong>. You&#8217;ll see a new screen, just click <strong>New LDAP</strong> in the upper right corner. I&#8217;ll describe what you have to enter here section by section. First, enter the <strong>LDAP strategy name</strong>, in my case is AD Integration with andreev.local. For <strong>LDAP connection settings</strong>, I have andreev.local for the <strong>host</strong>. This is not actually my host, it&#8217;s my domain that resolves to one of the hosts. You can type a host name here e.g. dc01.andreev.local, but if that hosts goes down, LDAP won&#8217;t work. So, use the domain name here and make sure it resolves to an IP of a domain controller. For the <strong>port</strong> enter <strong>389 </strong>which is the standard LDAP port. The <strong>Bind DN</strong> is the distinguished name for the user that will do the LDAP queries. As I said, I have a user called <strong>svc_splunk</strong> that does this for me. This user is under my <strong>Users OU</strong>. Use <strong>adsiedit.msc</strong> find the user in question and check the distinguished name property.<br />
<a href="https://blog.andreev.it/wp-content/uploads/2018/07/P109-01.png"><img fetchpriority="high" decoding="async" src="https://blog.andreev.it/wp-content/uploads/2018/07/P109-01.png" alt="" width="635" height="432" class="aligncenter size-full wp-image-8228" /></a><br />
For <strong>Bind DN Password</strong>, enter the password for the svc_splunk user. This is how it looks like on my side.<br />
<a href="https://blog.andreev.it/wp-content/uploads/2018/07/P109-02.png"><img decoding="async" src="https://blog.andreev.it/wp-content/uploads/2018/07/P109-02.png" alt="" width="959" height="550" class="aligncenter size-full wp-image-8229" /></a><br />
The next section is for the <strong>User settings</strong>. For the <strong>User base DN</strong>, enter the OU where you have your users defined. If you have multiple OUs, use semicolon. Check the <strong>User base filter</strong> and the description. If you have one single OU for the users and thousands of users there, you might want to do some filtering, otherwise the LDAP queries will take some time. For the <strong>User name attribute</strong> use <strong>sAMAccountName</strong> and for the <strong>Real name attribute</strong> use <strong>displayName</strong>. This is how my config looks like.<br />
<a href="https://blog.andreev.it/wp-content/uploads/2018/07/P109-03.png"><img decoding="async" src="https://blog.andreev.it/wp-content/uploads/2018/07/P109-03.png" alt="" width="961" height="536" class="aligncenter size-full wp-image-8230" /></a><br />
In AD I have my three Splunk groups defined in an OU called <strong>Groups</strong>. So, under <strong>Group settings</strong> and <strong>Group base DN</strong>, I have to specify that OU as <strong>OU=Groups,DC=andreev,DC=local</strong>. The <strong>Group name attribute</strong> is <strong>sAMAccountName </strong>and the <strong>Static member attribute</strong> is <strong>member</strong>. This is how my config looks like. You can click <strong>Save </strong>now.<br />
Once completed, you&#8217;ll get back to this screen. Now, we have to tell Splunk to map those AD groups with Splunk&#8217;s internal roles. In order to do that, click <strong>Map Groups</strong>.<br />
<a href="https://blog.andreev.it/wp-content/uploads/2018/07/P109-04.png"><img loading="lazy" decoding="async" src="https://blog.andreev.it/wp-content/uploads/2018/07/P109-04.png" alt="" width="1263" height="288" class="aligncenter size-full wp-image-8231" /></a><br />
You will see your groups in the list. If you don&#8217;t see any groups, you have something misconfigured or most likely you don&#8217;t have any members. Make sure you have at least one member in the group, otherwise it won&#8217;t show up. OK, so click on <strong>Splunk Power Users</strong> for example and click on <strong>power </strong>on the left side. Click <strong>Save </strong>after. Now, you can log off from Splunk as admin and log in as the configured AD user.</p>
<h1>SSL Certificates</h1>
<p>The tutorial for the installation of SSL certificates can be found <a href="https://docs.splunk.com/Documentation/Splunk/7.1.2/Security/Getthird-partycertificatesforSplunkWeb" rel="noopener noreferrer" target="_blank">here </a>and <a href="http://docs.splunk.com/Documentation/Splunk/7.1.2/Security/SecureSplunkWebusingasignedcertificate">here</a>. It&#8217;s a very detailed explanation of how to create your own private key, obtain a third-party signed certificate etc&#8230; So, in essence, you&#8217;ll need your private key and the signed 3-rd party certificate. Usually, they&#8217;ll send you the server certificate and the so called bundle, which is the intermediate certificate and the CA certificate in one file. You&#8217;ll have to put the server certificate first and the bundle next. To create the new file, use the cat command.</p>
<pre class="brush: bash; title: ; notranslate">
cat server_cert.pem bundle.pem &gt; full_cert.pem
</pre>
<p>You have to create a directory called <strong>mycerts </strong>under <strong>/opt/splunk/etc/auth</strong> and put the private key and the full certificate there. This assumes that your Splunk directory is at <strong>/opt/splunk</strong>.<br />
Then, go to <strong>/opt/splunk/etc/system/local</strong> and edit <strong>web.conf</strong>. If there is no such file, fine, just create it and paste the following.</p>
<pre class="brush: bash; title: ; notranslate">
&#x5B;settings]
enableSplunkWebSSL = true
privKeyPath = /opt/splunk/etc/auth/mycerts/private_cert.key
serverCert = /opt/splunk//etc/auth/mycerts/full_cert.pem
</pre>
<p>Restart Splunk.</p>
<pre class="brush: bash; title: ; notranslate">
/opt/splunk/bin/splunk restart
</pre>
<p>You should be able to access your server with https://splunk-ip:8000 now. If Splunk doesn&#8217;t start, take a look at the Splunk log and look for any SSL errors.</p>
<pre class="brush: bash; title: ; notranslate">
tail -f /opt/splunk/var/log/splunk/splunkd.log
</pre>
<h1>Splunk and reverse proxy</h1>
<p>Anytime you access Splunk server, you have to specify port 8000 in the URL. With a reverse proxy, you can just type the URL of the splunk server or IP and the reverse proxy will do the redirects for you.<br />
In order to do that, we&#8217;ll install nginx on the same Splunk server.</p>
<pre class="brush: bash; title: ; notranslate">
yum install epel-release
yum install nginx
</pre>
<p>Make sure to open the firewall for both http and https.</p>
<pre class="brush: bash; title: ; notranslate">
firewall-cmd --zone=public --add-service=http --permanent
firewall-cmd --zone=public --add-service=https --permanent
firewall-cmd --reload
</pre>
<p>In addition, if you have SELinux enabled (most likely not) or run nginx on a separate server, make this change or you&#8217;ll get &#8220;Bad Gateway&#8221; error from nginx.</p>
<pre class="brush: bash; title: ; notranslate">
setsebool -P httpd_can_network_connect true
</pre>
<p>Edit <strong>nginx.conf</strong> from <strong>/etc/nginx</strong> directory and right before the first server directive, insert these configuration lines. Make sure you have the certificates available or nginx won&#8217;t start.</p>
<pre class="brush: bash; title: ; notranslate">
server {
    listen 443 ssl;
    ssl on;
    ssl_certificate /opt/splunk/etc/auth/mycerts/full_cert.pem;
    ssl_certificate_key /opt/splunk/etc/auth/mycerts/private_cert.key;
    location / {
        proxy_pass https://127.0.0.1:8000;
    }
}
</pre>
<p>These lines will redirect all https requests to port 8000. In addition, modify the original default server config by adding the highlighted line.</p>
<pre class="brush: bash; highlight: [6]; title: ; notranslate">
    server {
        listen       80 default_server;
        listen       &#x5B;::]:80 default_server;
        server_name  _;
        root         /usr/share/nginx/html;
        return 301 https://$host$request_uri;

        # Load configuration files for the default server block.
</pre>
<p>This line redirects all http calls to https, so pretty much you can go to your browser now and type &#8220;splunk&#8221; or whatever your Splunk server is called and you&#8217;ll get the prompt. Don&#8217;t forget to enable nginx on boot and restart it after making changes to <strong>nginx.conf</strong>.</p>
<pre class="brush: bash; title: ; notranslate">
systemctl enable nginx
systemctl restart nginx
</pre>
<h1>Receive data</h1>
<p>If you haven&#8217;t done so, make sure that you have port 9997 configured on the Splunk server to receive data.<br />
Go to <strong>Settings | DATA | Forwarding and Receiving</strong>.<br />
<a href="https://blog.andreev.it/wp-content/uploads/2018/07/P109-05.png"><img loading="lazy" decoding="async" src="https://blog.andreev.it/wp-content/uploads/2018/07/P109-05.png" alt="" width="581" height="188" class="aligncenter size-full wp-image-8232" /></a><br />
Click on <strong>Configure Receiving</strong>.<br />
<a href="https://blog.andreev.it/wp-content/uploads/2018/07/P109-06.png"><img loading="lazy" decoding="async" src="https://blog.andreev.it/wp-content/uploads/2018/07/P109-06.png" alt="" width="976" height="140" class="aligncenter size-full wp-image-8233" /></a><br />
Click on <strong>New Receiving Port</strong> in the upper right corner and enter <strong>9997 </strong>for the port. You can have multiple forwarders sending to this port on the server.<br />
<a href="https://blog.andreev.it/wp-content/uploads/2018/07/P109-07.png"><img loading="lazy" decoding="async" src="https://blog.andreev.it/wp-content/uploads/2018/07/P109-07.png" alt="" width="940" height="237" class="aligncenter size-full wp-image-8234" /></a></p>
<h1>Create Indexes</h1>
<p>For each forwarder we&#8217;ll create a separate index. In order to do so, go to <strong>Settings | DATA | Indexes</strong> on the Splunk server.<br />
<a href="https://blog.andreev.it/wp-content/uploads/2018/07/P109-08.png"><img loading="lazy" decoding="async" src="https://blog.andreev.it/wp-content/uploads/2018/07/P109-08.png" alt="" width="588" height="242" class="aligncenter size-full wp-image-8235" /></a><br />
Click on <strong>New Index</strong> in the upper right corner and name the index.<br />
<a href="https://blog.andreev.it/wp-content/uploads/2018/07/P109-09.png"><img loading="lazy" decoding="async" src="https://blog.andreev.it/wp-content/uploads/2018/07/P109-09.png" alt="" width="788" height="556" class="aligncenter size-full wp-image-8236" /></a><br />
Accept all defaults and click <strong>Save</strong>. </p>
<h1>Splunk forwarder in Windows</h1>
<p>I&#8217;ll explain how to install a forwarder on Windows. Download the MSI file from the Splunk website, right-click on it and <strong>Run as Administrator</strong>. Check to accept the license. Make sure the bottom check mark is checked if you are using on-prem Splunk server. Click on <strong>Customize Options</strong> so you can specify what to monitor. It&#8217;s easier that dealing with conf files.<br />
<a href="https://blog.andreev.it/wp-content/uploads/2018/07/P109-10.png"><img loading="lazy" decoding="async" src="https://blog.andreev.it/wp-content/uploads/2018/07/P109-10.png" alt="" width="492" height="381" class="aligncenter size-full wp-image-8237" /></a><br />
Choose the destination folder.<br />
<a href="https://blog.andreev.it/wp-content/uploads/2018/07/P109-11.png"><img loading="lazy" decoding="async" src="https://blog.andreev.it/wp-content/uploads/2018/07/P109-11.png" alt="" width="489" height="389" class="aligncenter size-full wp-image-8238" /></a><br />
Fill the dialog if you are using certificate for forwarder-index communication.<br />
<a href="https://blog.andreev.it/wp-content/uploads/2018/07/P109-12.png"><img loading="lazy" decoding="async" src="https://blog.andreev.it/wp-content/uploads/2018/07/P109-12.png" alt="" width="496" height="390" class="aligncenter size-full wp-image-8239" /></a><br />
Choose the account that will run the forwarder.<br />
<a href="https://blog.andreev.it/wp-content/uploads/2018/07/P109-13.png"><img loading="lazy" decoding="async" src="https://blog.andreev.it/wp-content/uploads/2018/07/P109-13.png" alt="" width="491" height="384" class="aligncenter size-full wp-image-8240" /></a><br />
Choose what do you want to monitor.<br />
<a href="https://blog.andreev.it/wp-content/uploads/2018/07/P109-14.png"><img loading="lazy" decoding="async" src="https://blog.andreev.it/wp-content/uploads/2018/07/P109-14.png" alt="" width="496" height="388" class="aligncenter size-full wp-image-8241" /></a><br />
Enter a password.<br />
<a href="https://blog.andreev.it/wp-content/uploads/2018/07/P109-15.png"><img loading="lazy" decoding="async" src="https://blog.andreev.it/wp-content/uploads/2018/07/P109-15.png" alt="" width="490" height="381" class="aligncenter size-full wp-image-8242" /></a><br />
If you have a single server, your deployment and indexing server are the same as in my case.<br />
<a href="https://blog.andreev.it/wp-content/uploads/2018/07/P109-16.png"><img loading="lazy" decoding="async" src="https://blog.andreev.it/wp-content/uploads/2018/07/P109-16.png" alt="" width="496" height="386" class="aligncenter size-full wp-image-8243" /></a><br />
Indexing server.<br />
<a href="https://blog.andreev.it/wp-content/uploads/2018/07/P109-17.png"><img loading="lazy" decoding="async" src="https://blog.andreev.it/wp-content/uploads/2018/07/P109-17.png" alt="" width="496" height="385" class="aligncenter size-full wp-image-8244" /></a><br />
Click <strong>Install </strong>and <strong>Finish</strong>. By default, Splunk on Windows will send everything to the main index. In odrder to change it, open up <strong>C:\Program Files\SplunkUniversalForwarder\etc\system\local\inputs.conf</strong> and add the highlighted line.</p>
<pre class="brush: bash; highlight: [3]; title: ; notranslate">
&#x5B;default]
host = wintest
index = index_name
</pre>
<h1>Splunk forwarder on FreeBSD</h1>
<p>I&#8217;ll explain how to install a forwarder on FreeBSD 11.x. On the FreeBSD server, log as root and create a directory called <strong>/opt</strong>.</p>
<pre class="brush: bash; title: ; notranslate">
mkdir /opt
</pre>
<p>Download the tarball for the universal forwarder from Splunk&#8217;s website and extract it there. </p>
<pre class="brush: bash; title: ; notranslate">
tar xzvf splunkforwarder-XXXXXX-freebsd-9.3-amd64.tgz -C /opt
</pre>
<p>Configure the Splunk forwarder so it knows which server to use.</p>
<pre class="brush: bash; title: ; notranslate">
cd /opt/splunkforwarder/bin
./splunk add forward-server splunk-dev:9997
</pre>
<p>Then add the file that you want to monitor and specify the index and the type of the file (sourcetype).</p>
<pre class="brush: bash; title: ; notranslate">
./splunk add monitor /var/log/httpd-access.log -index bsd-test -sourcetype access_combined
</pre>
<p>Start the Splunk forwarder and make sure it starts on boot.</p>
<pre class="brush: bash; title: ; notranslate">
./splunk start
./splunk enable boot-start
</pre>
<p>You can see what&#8217;s monitored.</p>
<pre class="brush: bash; title: ; notranslate">
/opt/splunkforwarder/bin/splunk list monitor
</pre>
<p>If you want to add another log file after you&#8217;ve started the forwarder, you&#8217;ll have to restart the forwarder.</p>
<pre class="brush: bash; title: ; notranslate">
/opt/splunkforwarder/bin/splunk restart
</pre>
<p>If for some reason, you are not able to see your data on the Splunk server, check the <strong>/opt/splunk/etc/system/local/inputs.conf</strong> file on the server and make sure you have <strong>disabled = 0</strong> line there. </p>
<h1>Splunk forwader on CentOS</h1>
<p>I’ll explain how to install a forwarder on CentOS 7.x. On the CentOS server, log as root and install the Splunk forwarder. You have to download it first.</p>
<pre class="brush: bash; title: ; notranslate">
rpm -ivh splunkforwarder-XXXXXXXX-linux-2.6-x86_64.rpm
</pre>
<p>This command will extract the package under <strong>/opt/splunkforwarder</strong>. Configure the Splunk forwarder so it knows which server to use.</p>
<pre class="brush: bash; title: ; notranslate">
cd /opt/splunkforwarder/bin
./splunk add forward-server splunk-dev:9997
</pre>
<p>Then add the file that you want to monitor and specify the index and the type of the file (sourcetype).</p>
<pre class="brush: bash; title: ; notranslate">
./splunk add monitor /var/log/nginx/access.log -index centos-test -sourcetype access_combined
</pre>
<p>Start the Splunk forwarder and make sure it starts on boot.</p>
<pre class="brush: bash; title: ; notranslate">
./splunk start
./splunk enable boot-start
</pre>
<p>If you want to add another log file after you&#8217;ve started the forwarder, you&#8217;ll have to restart the forwarder.</p>
<pre class="brush: bash; title: ; notranslate">
/opt/splunkforwarder/bin/splunk restart
</pre>
<p>If for some reason, you are not able to see your data on the Splunk server, check the <strong>/opt/splunk/etc/system/local/inputs.conf</strong> file on the server and make sure you have <strong>disabled = 0</strong> line there. </p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.andreev.it/2018/07/132-splunk-quick-install-guide/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
