Failed to get my heatbeat.yml to be used

Hi!
Tried it, but the pings (actually received to my clud instance) were to the default heartbeat.yml (2 http 2 icmp) inside the container (I believe that is what happened).

In examples\docker\heartbeat.docker.yml:

heartbeat.monitors:
- type: browser
  id: my-monitor
  name: My Monitor
  schedule: "@every 1m"
  script: |-
    step("load homepage", async () => {
        await page.goto('https://www.folksam.se');
    });
    step("Tryck till kundtjanst", async () => {
        await page.click('title=["Till kundservice"]');

    });

In examples\run.sh

#!/bin/bash
set -e
set -x
VERSION=${1:-7.10.0}
if [ ! -z $1 ]; then
  shift # discard first arg
fi
HEARTBEAT_ARGS=$@

if [ -z $1 ]; then
  HEARTBEAT_ARGS="-E output.elasticsearch.hosts=["localhost:9200"] -E output.elasticsearch.username=elastic -E output.elasticsearch.password=changeme"
else
  HEARTBEAT_ARGS="$@"
fi

# Set Image based on version
if [[ $VERSION =~ ^[0-9] ]]; then
	IMAGE=docker.elastic.co/experimental/synthetics:$VERSION-synthetics
else
	IMAGE=$VERSION
fi

echo "Using image '$IMAGE' with extra args: $HEARTBEAT_ARGS"
docker run \
  --rm \
  --name=heartbeat \
  --user=heartbeat \
  --net=host \
  --security-opt seccomp=seccomp_profile.json \
  --volume="$(pwd)/heartbeat.docker.yml:/usr/share/heartbeat/heartbeat.yml:ro" \
  --volume="$(pwd)/../../:/opt/elastic-synthetics:rw" \
  $IMAGE \
  --strict.perms=false -e \
  -E cloud.id=xxxx" \
  -E cloud.auth="elastic:xxx"
  $HEARTBEAT_ARGS

from examples\docker I start /(w10) using
sh run.sh 7.10.0
At starts up, the data is send to my cloud but always for
http://elasticsearch:9200/
http://kibana:5601/
icmp://elasticsearch
icmp://kibana

Why is not my heartbeat.yml used??

@Fredrik_Cronholm if you want to change where you want to send data you will have to specify those options while running your command

like this

sh run.sh 7.10.0 -E output.elasticsearch.hosts=["localhost:9200"] -E cloud.id=434343

same way you can specify other options -E cloud.id or -E cloud.auth or -E output.elasticsearch.username=elastic etc

let me know if it works.

That works, the data is sent to the correct place. It is the tests that is not used (the content of heartbeat.docker.yml)

I guess you can retry creating your container. That might help, we will try to reproduce this locally.

I'm not super used to docker, I have rerun sh run.sh a few times, no difference. I have also tried to copy the local config file to the container (as in the scrip), docker cp to /usr/share/heartbeat/heartbeat.yml but the same result.
Waiting for a possible resolution. I'm thinking my test file has some syntax errors and is therefore not used..?

Are you running run.sh from the synthetics/examples/docker folder on your clone of the repo?

This should run the docker version of Elastic Synthetics, taking the configuration from your local synthetics/examples/heartbeat.docker.yml file (i.e. this is the one you want to edit to contains your URLs and script).

Try making sure you are in the synthetics/examples/docker folder when you run run.sh so that it can mount the correct synthetics/examples/heartbeat.docker.ymlfile inside your docker container.

Yes I run it locally on my host in the cloned repo :frowning:

The mounting of your local heartbeat.docker.yml into the docker container works the same for regular Heartbeat (e.g. standard HTTP pings) as well as for the Synthetics implementation (i.e. it uses the same mechanism for getting your local heartbeat.docker.yml into the docker container).

It might be worth starting again to make sure you have a clean set up. Remove your clone of the Synthetics repository (backing up anything you may want to keep), then clone a new/up to date copy (git clone git@github.com:elastic/synthetics.git).

Before running it, also remove any docker images you may have (this will make sure it downloads the latest version when you next run). You can run docker images to see what images you have.

If you have anything like docker.elastic.co/experimental/synthetics or 7.10.0-synthetics, remove it with docker image rm IMAGE_ID, substituting the IMAGE_ID with what was listed for the image.

Add your Elasticsearch host/credentials to the synthetics/examples/docker/run.sh file as you did before. Don’t modify the heartbeat.docker.yml file yet.

Make sure you are in the synthetics/examples/docker folder, then run the ./run.sh 7.10.0 command, this will take a bit longer and download all the docker images needed. Check that this is running correctly.

If so, stop it ([ctrl][c]) then add your monitor configuration to the heartbeat.docker.yml and run ./run.sh 7.10.0 again to see if it runs with your monitors this time.

Hi!
Did as described (removed all images, clones new, started etc. etc). Still difference. Still doesn't check the elastic.io site (as described in the original heartbeat.docker.yml). It still checks 4 localhost adresses.

Hi @Fredrik_Cronholm,

Is it possible for you to post part of the logs from the docker container?
You can use this command to get the logs: docker logs --tail=50 <container-id>.

Cheers,
Hamid