[[winlogbeat-getting-started]]
== Getting Started With Winlogbeat

To get started with your own Winlogbeat setup, install and configure these
related products:

 * Elasticsearch for storage and indexing the data.
 * Kibana for the UI.
 * Logstash (optional) for inserting data into Elasticsearch.

See {libbeat}/getting-started.html[Getting Started with Beats and the Elastic
Stack] for more information.

After installing the Elastic Stack, read the following topics to learn how to install, configure, and run Winlogbeat:

* <<winlogbeat-installation>>
* <<winlogbeat-configuration>>
* <<config-winlogbeat-logstash>>
* <<winlogbeat-template>>
* <<winlogbeat-starting>>
* <<winlogbeat-sample-dashboards>>
* <<winlogbeat-command-line-options>>
* <<directory-layout>>

[[winlogbeat-installation]]
=== Step 1: Installing Winlogbeat

. Download the Winlogbeat zip file from the
https://www.elastic.co/downloads/beats/winlogbeat[downloads page].
. Extract the contents into `C:\Program Files`.
. Rename the `winlogbeat-<version>` directory to `Winlogbeat`.
. Open a PowerShell prompt as an Administrator (right-click on the PowerShell
icon and select Run As Administrator). If you are running Windows XP, you may
need to download and install PowerShell.
. Run the following commands to install the service.

["source","sh",subs="attributes,callouts"]
------------------------------------------------
PS C:\Users\Administrator> cd 'C:\Program Files\Winlogbeat'
PS C:\Program Files\Winlogbeat> .\install-service-winlogbeat.ps1

Security warning
Run only scripts that you trust. While scripts from the internet can be useful,
this script can potentially harm your computer. If you trust this script, use
the Unblock-File cmdlet to allow the script to run without this warning message.
Do you want to run C:\Program Files\Winlogbeat\install-service-winlogbeat.ps1?
[D] Do not run  [R] Run once  [S] Suspend  [?] Help (default is "D"): R

Status   Name               DisplayName
------   ----               -----------
Stopped  winlogbeat         winlogbeat
------------------------------------------------

NOTE: If script execution is disabled on your system, you need to set the
execution policy for the current session to allow the script to run. For example:
`PowerShell.exe -ExecutionPolicy UnRestricted -File .\install-service-winlogbeat.ps1`.

Before starting Winlogbeat, you should look at the configuration options in the
configuration file, for example `C:\Program Files\Winlogbeat\winlogbeat.yml`.
For more information about these options, see <<winlogbeat-configuration-details>>.

[[winlogbeat-configuration]]
=== Step 2: Configuring Winlogbeat

To configure Winlogbeat, you edit the `winlogbeat.yml` configuration file. Here
is a sample of the `winlogbeat.yml` file:

[source,yaml]
--------------------------------------------------------------------------------
winlogbeat.event_logs:
  - name: Application
  - name: Security
  - name: System

output.elasticsearch:
  hosts:
    - localhost:9200

logging.to_files: true
logging.files:
  path: C:/ProgramData/winlogbeat/Logs
logging.level: info
--------------------------------------------------------------------------------

To configure Winlogbeat:

. In the `event_logs` section, specify the event logs that you want to monitor.
By default, Winlogbeat is set to monitor application, security, and system logs:
+
[source,yaml]
----------------------------------------------------------------------
winlogbeat.event_logs:
  - name: Application
  - name: Security
  - name: System
----------------------------------------------------------------------
+
To obtain a list of available event logs, run `Get-EventLog *` in PowerShell.
For more information about this command, see the configuration details for
<<configuration-winlogbeat-options-event_logs-name,event_logs.name>>.

. If you are sending output to Elasticsearch, set the IP address and port where
Winlogbeat can find the Elasticsearch installation:
+
[source,yaml]
----------------------------------------------------------------------
output.elasticsearch:
  hosts:
    - localhost:9200
----------------------------------------------------------------------
+
If you are sending output to Logstash, see <<config-winlogbeat-logstash>> instead.

. After you save your configuration file, test it with the following command.
+
[source,shell]
----------------------------------------------------------------------
PS C:\Program Files\Winlogbeat> .\winlogbeat.exe -c .\winlogbeat.yml -configtest -e
----------------------------------------------------------------------

[[config-winlogbeat-logstash]]
=== Step 3: Configuring Winlogbeat to Use Logstash

include::../../libbeat/docs/shared-logstash-config.asciidoc[]

[[winlogbeat-template]]
=== Step 4: Loading the Index Template in Elasticsearch

include::../../libbeat/docs/shared-template-load.asciidoc[]

[[winlogbeat-starting]]
=== Step 5: Starting Winlogbeat

Start the Winlogbeat service with the following command:

[source,shell]
----------------------------------------------------------------------
PS C:\Program Files\Winlogbeat> Start-Service winlogbeat
----------------------------------------------------------------------

Winlogbeat should now be running. If you used the configuration described here,
then you can view the log file at `C:\ProgramData\winlogbeat\Logs\winlogbeat`.

You can view the status of the service and control it from the Services
management console in Windows. To launch the management console, run
this command:

[source,shell]
----------------------------------------------------------------------
PS C:\Program Files\Winlogbeat> services.msc
----------------------------------------------------------------------

==== Stopping Winlogbeat

Stop the Winlogbeat service with the following command:

[source,shell]
----------------------------------------------------------------------
PS C:\Program Files\Winlogbeat> Stop-Service winlogbeat
----------------------------------------------------------------------

[[winlogbeat-sample-dashboards]]
=== Step 6: Loading Sample Kibana Dashboards

To make it easier for you to start monitoring your servers in Kibana,
we have created sample Winlogbeat dashboards. The dashboards are provided as
examples. We recommend that you
http://www.elastic.co/guide/en/kibana/current/dashboard.html[customize] them
to meet your needs.

image:./images/winlogbeat-dashboard.png[Winlogbeat statistics]

include::../../libbeat/docs/dashboards.asciidoc[]
