It seems like you didn't installed Splunk forwarder but Splunk EP single instance. In forwarder, you wouldn't have UI.
so if it Universal forwarder, you will be pointing it to your deployment server first, which can deploy outputs.conf file into forwarder to tell, where are your indexers are. From that point on, whether you have monitors or not, forwarder should be starting its internal logs to Splunk indexer.
if it is a single instance as I thought, then you can just add from ui. for ansible automation, i guess we can think of 2 strategies,
- automation via Splunk configuration files
- automation via Splunk cli commands (as you have tried in the question)
one key thing to note, you do monitoring automation with Splunk deployment server in modern systems. i can think of an exception only in systems like containers which you may want to preconfigure each container to make them start sending immediately.
Assuming, your automation will take place in clustered environment, you may want to read little more in Splunk architecture, checking on the commands you have put:
splunk add forward-server localhost:9997 -auth admin:changeme # this is telling universal forwarder where to forward data (generally an indexer, sometimes HF)
More here,
https://docs.splunk.com/Documentation/Forwarder/7.1.2/Forwarder/Configuretheuniversalforwarder
splunk add monitor /var/log # this is locally done on universal forwarder, since index not defined, if anything successful to monitor, it should be going to index=main in splunk side. in forwarder, you would find the trace of your command in /opt/splunkforwarder/etc/system/local/inputs.conf
splunk enable listen 9997 -auth admin:changeme # this simply tells splunk software to listen incoming traffic. 9997 is default data port for Splunk
https://docs.splunk.com/Documentation/Forwarder/8.1.1/Forwarder/Enableareceiver
now questions:
- it depends :) . in a single instance, you can configure them in UI, or .conf files or via CLI. in a multi clustered environment, you would use other splunk instances such as deployment server, license server, cluster master, search head deployer.
- I believe you can, however, you need to have 2 seperate installs, one for splunk indexer-search head (single instance) , and one for splunk universal forwarder.
Following this you will need configure ports in respect to splunk architecture.
such that,
splunk enable listen 9997 -auth admin:changeme will be on indexer
vs
splunk add forward-server localhost:9997 -auth admin:changeme
splunk add monitor /var/log
on forwarder.
- I believe Architecture. There are several deployment architectures for Splunk. They are not super complex. I personally have a mix of architectures in my work.
Secondly, UI is there,
however my first personal choice of configuration is .conf files, then cli commands (mostly troubleshooting times since you can do other tests at the same time) , then UI.