This topic describes how to use Non-Sucking Service Manager (NSSM) to configure Logstash as a Windows service.

Background information

After you use PowerShell to launch the logstash.bat process, the logstash process runs in the frontend. In most cases, the process is used to test and debug log collection. After you complete the debugging, we recommend that you configure Logstash as a Windows service. You can run Logstash in the backend and set auto-run at startup for Logstash. You can use NSSM to configure Logstash as a Windows service. For more information about NSSM, visit NSSM documentation.

You can also use NSSM to start, stop, modify, and remove services in the Command Prompt.

Install Logstash as a Windows service

When you install Logstash for the first time, perform this step. Otherwise, skip this step.

You can run one of the following commands to install Logstash as a Windows service:
  • 32-bit system
    C:\logstash-2.2.2-win\nssm-2.24\win32\nssm.exe install logstash "C:\logstash-2.2.2-win\bin\logstash.bat" "agent -f C:\logstash-2.2.2-win\conf"
  • 64-bit system
    C:\logstash-2.2.2-win\nssm-2.24\win64\nssm.exe install logstash "C:\logstash-2.2.2-win\bin\logstash.bat" "agent -f C:\logstash-2.2.2-win\conf"

Start the service

You can run one of the following commands to start the service:
  • 32-bit system
    C:\logstash-2.2.2-win\nssm-2.24\win32\nssm.exe start logstash
  • 64-bit system
    C:\logstash-2.2.2-win\nssm-2.24\win64\nssm.exe start logstash

Stop the service

You can run one of the following commands to stop the service:

  • 32-bit system
    C:\logstash-2.2.2-win\nssm-2.24\win32\nssm.exe stop logstash
  • 64-bit system
    C:\logstash-2.2.2-win\nssm-2.24\win64\nssm.exe stop logstash

Modify the service

You can run one of the following commands to modify the service:

  • 32-bit system
    C:\logstash-2.2.2-win\nssm-2.24\win32\nssm.exe edit logstash
  • 64-bit system
    C:\logstash-2.2.2-win\nssm-2.24\win64\nssm.exe edit logstash

Delete the service

You can run one of the following commands to delete the service:

  • 32-bit system
    C:\logstash-2.2.2-win\nssm-2.24\win32\nssm.exe remove logstash
  • 64-bit system
    C:\logstash-2.2.2-win\nssm-2.24\win64\nssm.exe remove logstash