Run Kibana as service on CentOS

Hi there,

I am trying to get Kibana up and running on Centos. Following the instructions on the elastic site, I can successfully download the files and run in the console.

But is there any guidance anywhere that helps me get this set up to run as a service for a production environment?

Any help appreciated.

Matt

We're working on that, as part of providing KB4 packages.

In the meantime it's pretty simple to build an init script to handle it, just copy an existing one and modify it :slight_smile:

OK - thanks! :smile:

Here's the systemd service file I'm using on my CentOS 7 systems for Kibana 4.1:

[Unit]
Description=Kibana 4

[Service]
Type=simple
User=logstash
Environment=CONFIG_PATH=/etc/kibana/kibana.yml
Environment=NODE_ENV=production
ExecStart=/opt/kibana-{{ kibana_version }}/node/bin/node /opt/kibana-{{ kibana_version }}/src/bin/kibana.js

[Install]
WantedBy=multi-user.target

Here's the service file that I use on CentOS 7 to run Kibana 4.1:

[Unit]
Description=Kibana 4

[Service]
Type=simple
User=logstash
Environment=CONFIG_PATH=/etc/kibana/kibana.yml
Environment=NODE_ENV=production
ExecStart=/opt/kibana-4.1.0/node/bin/node /opt/kibana-4.1.0/src/bin/kibana.js

[Install]
WantedBy=multi-user.target

Thank you - this is working great :smile:

For the record, you'd put it into "/etc/systemd/system/kibana.service". Whenever changing systemd unit files it's a good idea to do:

systemctl daemon-reload

Then you can start the service with:

systemctl start kibana

Thanks Jeffrey :slight_smile:

Hello, Jeffrey.

I'm trying to run Kibana with this setup guide

In this case I don't have file src/bin/kibana.js in extracted folder. How I can register the systemctl service with /opt/kibana-4.3.1/bin/kibana run command?

Thank you

Up: OK. I'm already found this init script with instruction.

Elastic changed things around in the latest releases. If you'd prefer a native systemd unit file (and who wouldn't!) here's my current one:

[Unit]
Description=Kibana 4

[Service]
Type=simple
User=logstash
Environment=CONFIG_PATH=/etc/kibana/kibana.yml
Environment=NODE_ENV=production
ExecStart=/opt/kibana/4.3.1/node/bin/node /opt/kibana/4.3.1/src/cli

[Install]
WantedBy=multi-user.target

1 Like

Thank's again, Jeffrey.

I'll try to check your new config.

Hello Jeffrey,
Can you help for adding this service to autorun for kibana service start after a system was reboot?

Hi there,

I am not sure if this is still valid discussion, if not please just delete this post.

If you are interested in systemd, this is how I do it (including start after a reboot).

  1. /opt/kibana is a symbolic link to /opt/kibana-4.5.1-1
    which makes it very easy to upgrade/downgrade (you can create kibana_current) if you are using rpm/deb packages.

  2. rsyslog (default in Redhat) /etc/rsyslog.d/kibana.conf:

$umask 0000
$fileOwner kibana
$dirOwner kibana
$dirCreateMode 0755
$fileCreateMode 0444

if $programname == 'kibana' and $syslogfacility-text == 'local7' /var/log/kibana/kibana.log

  1. Systemd file: /etc/systemd/system/kibana.service

[Unit]
Description=Kibana
After=syslog.target network.target remote-fs.target nss-lookup.target

[Service]
Type=simple
User=kibana
Environment=NODE_ENV=production
Environment=CONFIG_PATH=/opt/kibana/config/kibana.yml
EnvironmentFile=/etc/default/kibana
WorkingDirectory=/opt/kibana/
ExecStart=/opt/kibana/bin/../node/bin/node --max-old-space-size=512 /opt/kibana/bin/../src/cli
StandardOutput=syslog
StandardError=syslog
SyslogFacility=local7
SyslogLevel=notice
SyslogIdentifier=kibana
Restart=on-failure

[Install]
WantedBy=multi-user.target

  1. then enable in systemd:
    systemctl enable kibana
  2. and finally start kibana:
    systemctl start kibana
  3. and optionally check the status:
    systemctl status kibana

*please execute all commands as root

  1. Optionally you can add logrotate to rotate the log file under /var/log/kibana/kibana.log

I hope it helps!

Cheers,
Rafal.

The latest versions of KB all come with an init script.

Hi Mark,

I agree,

  • but how do you get logs from in a separate place (not 'messages')?
  • you cannot easily pass NODE_OPTIONS because /opt/kibana/bin/kibana is not including it, you have to add at the end but before 'exec': [ -r /etc/default/kibana ] && . /etc/default/kibana

Old topic, I know. If I should create a new topic, please let me know.

I am trying to get kibana to output logs to /var/log/kibana/kibana.log so that I can process the http response codes better (using logstash filters), however, I can't get kibana to load after editing kibana.yml. It works when I use /opt/kibana/bin/kibana, and the logs go to the correct file, however, when I try to use the systemd file that comes with kibana, systemd says that everything is working fine, but I am unable to get kibana to load at all.

Using kibana 4.4.2 on CentOS 7

Please do.