# Heartbeat http monitor is not sending headers

**URL:** <https://discuss.elastic.co/t/heartbeat-http-monitor-is-not-sending-headers/175761>\
**Category:** Beats\
**Tags:** heartbeat\
**Created:** [April 8, 2019, 5:58am UTC](https://discuss.elastic.co/t/heartbeat-http-monitor-is-not-sending-headers/175761 "2019-04-08T05:58:42Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![marvnz](https://avatars.discourse-cdn.com/v4/letter/m/fbc32d/32.png) [@marvnz](https://discuss.elastic.co/u/marvnz)\
**Post date:** [April 8, 2019, 5:58am UTC](https://discuss.elastic.co/t/heartbeat-http-monitor-is-not-sending-headers/175761/1 "2019-04-08T05:58:43Z")

</div>

I have configured the following http monitor:

```
heartbeat.monitors:
- type: "http"
  urls: ["http://elasticsearch-dev-master.dev-common-cache.svc.cluster.local:9200","https://dev-common-cache.gubbins.bobbins","http://10.10.10.10:33101/"]
  schedule: "@every 10s"
  check.request.method: "GET"
  check.request.headers:
    HOST: 'dev-common-cache.gubbins.bobbins'
  check.response.body: "You Know, for Search"

```

These 3 urls all point to the same elasticsearch cluster, but just being reached through different network endpoints to try to establish they are all working.

However I don't think the headers are being sent through as the endpoint that goes through the nginx-ingress controller is not working as it requires that header to route the request. So my question is have I configured the http monitor correctly? Also I have enabled debug logging, but that doesn't show what the request looks like.

---

<div class="post-metadata">

**Author:** ![ruflin](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ruflin/32/3116_2.png) [@ruflin](https://discuss.elastic.co/u/ruflin)\
**Post date:** [April 8, 2019, 8:40am UTC](https://discuss.elastic.co/t/heartbeat-http-monitor-is-not-sending-headers/175761/2 "2019-04-08T08:40:39Z")

</div>

At first sight, your config looks correct. I stumbled over the `HOST` in upper-case. I assume that is intended?

As you already run it with the debug log, any chance you could share it?

---

<div class="post-metadata">

**Author:** ![marvnz](https://avatars.discourse-cdn.com/v4/letter/m/fbc32d/32.png) [@marvnz](https://discuss.elastic.co/u/marvnz)\
**Post date:** [April 8, 2019, 10:19am UTC](https://discuss.elastic.co/t/heartbeat-http-monitor-is-not-sending-headers/175761/3 "2019-04-08T10:19:30Z")

</div>

I have tried it lower case and in single quotes, but always the same http 404.

I can curl the ingress controller with the HOST: header and it works, but heartbeat can not successfully send the header so it keeps getting a validate 404 Not Found error as you can see in the screenshot attached.

 ![18%20PM](https://us1.discourse-cdn.com/elastic/original/3X/5/2/52ada92a1d3f0d739da9bbbc10892ef43e9b9e42.png)

---

<div class="post-metadata">

**Author:** ![martinr\_ubi](https://avatars.discourse-cdn.com/v4/letter/m/b5e925/32.png) [@martinr\_ubi](https://discuss.elastic.co/u/martinr_ubi)\
**Post date:** [April 10, 2019, 3:19am UTC](https://discuss.elastic.co/t/heartbeat-http-monitor-is-not-sending-headers/175761/4 "2019-04-10T03:19:26Z")

</div>

Hi @marvnz ,

This is a known bug/undocumented limitation of heartbeat \< v6.7.0.  
Specifically, the "host" header is ignored, it comes from GO, see below.

Originally reported:

> [@\[HTTP check\] Override Host header](https://discuss.elastic.co/t/http-check-override-host-header/157660):
>
> Hello, I have troubles overriding the Host header. I want to test individually: My CDN My varnish My backend To do that i need to check the IP with a custom Header, if i had to script it i would use Curl: curl -I -H "Host:my\_superb\_domain\_name.com" [http://IPCDN/myasset.json](http://IPCDN/myasset.json) curl -I -H "Host:my\_superb\_domain\_name.com" [http://IPvarnish/myasset.json](http://IPvarnish/myasset.json) curl -I -H "Host:my\_superb\_domain\_name.com" [http://IPbackend/myasset.json](http://IPbackend/myasset.json) So i tried to do something like that: - type: http urls: ["htt…

Issue:

> <https://github.com/elastic/beats/issues/9376>
>
> Hello
> 
> \*\*Describe the enhancement:\*\*
> I should be abled to override the Host h…eader to test my services.
> At the beginning i thought i did something wrong but Mr Cholakian told me to ask for a feature request: https://discuss.elastic.co/t/http-check-override-host-header/157660
> 
> \*\*Describe a specific use case for the enhancement or feature:\*\*
> I want to test individually:
> 
> My CDN
> My varnish
> My backend
> To do that i need to check the IP with a custom Header, if i had to script it i would use Curl:
> 
> curl -I -H "Host:my\_superb\_domain\_name.com" http://IPCDN/myasset.json
> curl -I -H "Host:my\_superb\_domain\_name.com" http://IPvarnish/myasset.json
> curl -I -H "Host:my\_superb\_domain\_name.com" http://IPbackend/myasset.json
> So i tried to do something like that:
> 
> \- type: http
> urls: \["http://IPCDN/myasset.json","http://IPvarnish/myasset.json","http://IPbackend/myasset.json"\]
> check.request:
> method: GET
> headers:
> accept-encoding: gzip,deflate
> host: my\_superb\_domain\_name.com
> 
> The Host header is not used, so i get a 404 or a 403 depending of the default behavior of my cdn/varnish/backend
> 
> It would be nice to be able to do so :)
> Have a good day
> 
> PS: Heartbeat.... not metricbeat of course

fix: (commit and pull)

> <https://github.com/elastic/beats/commit/893fdcb8b4471a6cee1c717d73f5f63d445931a3>

> <https://github.com/elastic/beats/pull/9516>
>
> As explained on \[golang's repository\](https://github.com/golang/go/issues/7682),… adding a \*Host\* header to the request's headers list isn't enough. So when this header is defined by the configuration, I also explicitly give it to the HTTP request.

Backport to 6.7.0:

> <https://github.com/elastic/beats/pull/9728>
>
> Cherry-pick of PR #9516 to 6.x branch. Original message: 
> 
> As explained on \[gola…ng's repository\](https://github.com/golang/go/issues/7682), adding a \*Host\* header to the request's headers list isn't enough. So when this header is defined by the configuration, I also explicitly give it to the HTTP request.

I myself didn't figure it out until I pointed heartbeat to a local netcat and figured that only the "host" header was silently ignored by heartbeat.  
`nc -kl 8888`

My struggle:

> [@Heartbeat bug with fix in 7.x, if no backport... doc fix in 6.x?](https://discuss.elastic.co/t/heartbeat-bug-with-fix-in-7-x-if-no-backport-doc-fix-in-6-x/172377):
>
> Hi, I lost some time investigating why Heartbeat 6.6.2 (lastest stable) was not respecting the "Host" http header I was configuring in an HTTP monitor. I was using exactly what the doc was saying, etc. Turns out when I understood the issue was specific to a specific header.. "Host" and not to all http headers. I looked for a known or unknown bug and found: Question is: If this fix is not scheduled to be backported to older heartbeat, I would recommend a documentation fix for older versi…

Instant relief with 6.7.

Hoping this helps,

Martin

---

<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:** [May 8, 2019, 3:19am UTC](https://discuss.elastic.co/t/heartbeat-http-monitor-is-not-sending-headers/175761/5 "2019-05-08T03:19:35Z")

</div>

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