# Winlogbeat Secrets Key Store

**URL:** https://discuss.elastic.co/t/winlogbeat-secrets-key-store/276457
**Category:** Beats
**Tags:** winlogbeat
**Created:** [June 20, 2021, 8:22am UTC](https://discuss.elastic.co/t/winlogbeat-secrets-key-store/276457 "2021-06-20T08:22:41Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![inf](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/inf/32/85793_2.png) [@inf](https://discuss.elastic.co/u/inf)
#### Post date: [June 20, 2021, 8:22am UTC](https://discuss.elastic.co/t/winlogbeat-secrets-key-store/276457/1 "2021-06-20T08:22:41Z")

</div>

Hi there!

(Reference link that I used for what I tried: [Secrets keystore for secure settings](https://www.elastic.co/guide/en/beats/winlogbeat/current/keystore.html))

Here's with I did to setup my Winlogbeat's communication with Elasticsearch, with the use of an API key (instead of credentials).

These commands are executed in an high-integrity PowerShell:

Confirm that the keystore is empty/not created:  
`.'C:\Program Files\Elastic\Winlogbeat\winlogbeat.exe' -c 'C:\Program Files\Elastic\Winlogbeat\winlogbeat.yml' keystore list`

Create the keystore:  
`.'C:\Program Files\Elastic\Winlogbeat\winlogbeat.exe' -c 'C:\Program Files\Elastic\Winlogbeat\winlogbeat.yml' keystore create`

Add key to the keystore:  
`.'C:\Program Files\Elastic\Winlogbeat\winlogbeat.exe' -c 'C:\Program Files\Elastic\Winlogbeat\winlogbeat.yml' keystore add ES_API`

`[API_key_string_placeholder]`

Confirm that the key was successfully added to the keystore:  
`.'C:\Program Files\Elastic\Winlogbeat\winlogbeat.exe' -c 'C:\Program Files\Elastic\Winlogbeat\winlogbeat.yml' keystore list`

Next, I replaced the following in my `winlogbeat.yml`:  
Original:  
`output.elasticsearch.api_key: [API_key_string_placeholder]`  
Modified:  
`output.elasticsearch.api_key: "${ES_API}"`

I executed this command to confirm that Winlogbeat could communicate with Elasticsearch successfully:  
`.'C:\Program Files\Elastic\Winlogbeat\winlogbeat.exe' -c 'C:\Program Files\Elastic\Winlogbeat\winlogbeat.yml' -e`

However, I cannot run `Start-Service winlogbeat` successfully:

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/9/5/95da7791c08578c0d7042e7ff55a4e80d77a44d0.png)

Running `sc qc winlogbeat` in cmd.exe shows the command that the service runs when it is started:

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/0/0/00babf14047400833a0fe004d424219fa7bf4076.png)

Running the command from the above output directly tells us a clearer error of why `Start-Service winlogbeat` did not work (I think):

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/1/4/144674ae2a496def78a9c7f8b4b206bd11eddbcf.png)

I added `-E "output.elasticsearch.api_key=\${ES_API}` to the above command, but it did not work too:

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/6/8/6861e5247c1ae57ee8f765242951d8b557821574.png)

I also added `-E "output.elasticsearch.api_key=\${ES_API}"` to the command executed in PowerShell earlier, so the full command is `.'C:\Program Files\Elastic\Winlogbeat\winlogbeat.exe' -c 'C:\Program Files\Elastic\Winlogbeat\winlogbeat.yml' -e -E "output.elasticsearch.api_key=\${ES_API}"`. However, it says that the authentication with Elasticsearch failed. Not attaching any screenshots here tentatively for this one because of the verbose data shown.

Not sure what I did wrong, particularly why there is a `missing field accessing 'output.elasticsearch.api_key'`. Perhaps something to do with the formatting (particularly `$`)?

Seeking advice please!

---

<div class="post-metadata">

### Author: ![inf](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/inf/32/85793_2.png) [@inf](https://discuss.elastic.co/u/inf)
#### Post date: [June 23, 2021, 12:16pm UTC](https://discuss.elastic.co/t/winlogbeat-secrets-key-store/276457/2 "2021-06-23T12:16:39Z")

</div>

Bump!

Wondering how we can solve this issue so that another layer of security is ensured when using Winlogbeat (or other Beats).

Also, if anyone can advice of a more secure method of authenticating with Elasticsearch (besides having an API Key + putting it in a Beats keystore), please advise!

Thank you. 🙂 And have a beautiful day!

---

<div class="post-metadata">

### Author: ![inf](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/inf/32/85793_2.png) [@inf](https://discuss.elastic.co/u/inf)
#### Post date: [July 6, 2021, 5:37am UTC](https://discuss.elastic.co/t/winlogbeat-secrets-key-store/276457/3 "2021-07-06T05:37:53Z")

</div>

Bump!

Still looking for assistance regarding this please.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [August 3, 2021, 7:38am UTC](https://discuss.elastic.co/t/winlogbeat-secrets-key-store/276457/4 "2021-08-03T07:38:19Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
