Heartbeat list of host help

Hi all,

I am trying to configure an icmp.yml file to ping a list of hosts on my network.
I got it to ping the host that part is working, how do I add name: to the list of host.

  • type: icmp
    enabled: true
    schedule: '@every 1m'

    List of hosts to ping

    hosts:
    - host1
    - host2
    - etc....

is there a way to add a name so I don't get the unnamed - auto gibberish name in the Kibana dashboard?

thanks

Hi @delatucci - Welcome to our community forums!

You may want to consider using the following monitors options: id and name.

I believe the auto gibberish name you are referring to is actually the id. Since the id is not specified, a generated value will be used (c.f. documentation).

I hope that helps.

Thank you for your guidance.

I dont expect the great people of the community to do my job for me but can you give me an example of how that yaml file should be laid out. I have tried all different ways, to no success.

@delatucci - I have tried all different ways, to no success. - I am not sure what you have tried and which issue you are facing. Did you include the id in option in heartbeat.yml file and did you check if the value was correctly indexed? May be you could share with us the heartbeat.yml and some documents from your index as well as some screenshots of the issue.

Again thanks you for your help.

for example, this is what the most recent attempt looks like. please see below - This is the icmp.yml

These files contain a list of monitor configurations identical

to the heartbeat.monitors section in heartbeat.yml

The .example extension on this file must be removed for it to

be loaded.

  • type: icmp # monitor type icmp (requires root) uses ICMP Echo Request to ping

    configured hosts

    Monitor name used for job name and document type.

    name: icmp

    Enable/Disable monitor

    enabled: true

    Configure task schedule using cron-like syntax

    schedule: '@every 5m' #'*/60 * * * * * *' exactly every 5 seconds like 10:00:00, 10:00:05, ...

    List of hosts to ping

    hosts:
    - hostname1
    id:hostname1
    - hostname2
    id:hostname2
    - hostname3
    id:hostname3

    Configure IP protocol types to ping on if hostnames are configured.

    Ping all resolvable IPs if mode is all, or only one IP if mode is any.

    ipv4: true
    ipv6: false
    mode: any

    Total running time per ping test.

    timeout: 16s

    Waiting duration until another ICMP Echo Request is emitted.

    wait: 1s

    The tags of the monitors are included in their own field with each

    transaction published. Tags make it easy to group servers by different

    logical properties.

    #tags: ["service-X", "web-tier"]

    Optional fields that you can specify to add additional information to the

    monitor output. Fields can be scalar values, arrays, dictionaries, or any nested

    combination of these.

    #fields:

    env: staging

    If this option is set to true, the custom fields are stored as top-level

    fields in the output document instead of being grouped under a fields

    sub-dictionary. Default is false.

    #fields_under_root: false

the heartbeat log has this error in response:
job err parse icmp://hostname1 name:hostname1: invalid port ":hostname1" after host

I also got this error"
error invalid config: yaml: line 22: mapping values are not allowed in this context
when i tried it this way
hosts:
-host1
id: host1

Again any guidance on the correct syntax/structure of how to properly create this file will be greatly appreciated.

Ok So i got the name to show up in Kibana the way i wanted it to show with this yml config

type: icmp
name: icmp
enabled: true
schedule: '@every 2m'

List of hosts to ping

hosts: host1
name: host1

however when i added an additional host like so

type: icmp
name: icmp
enabled: true
schedule: '@every 2m'

List of hosts to ping

hosts: host1
name: host1
hosts: "x.x.x.x"
name: "host2"

it looks like it stop pinging host 1 and now only pings "x.x.x.x"

**it only shows the last host that was added. **

***for example my most recent config file had "x.x.x.x" "y.y.y.y" and "z.z.z.z" now it only show 1 ping top z.z.z.z ***

I am going to use this discussion to add notes for others in the future that may have this similar issue.

ok so this is my new icmp.yml file looks like this basically

  • type: icmp
    name: icmp
    enable: true
    schedule: '@every 2m'
    hosts: "x.x.x.x"
    name: host1
  • type: icmp
    name: icmp
    enable: true
    schedule: '@every 2m'
    hosts: "y.y.y.y"
    name: host2
  • type: icmp
    name: icmp
    enable: true
    schedule: '@every 2m'
    hosts: "z.z.z.z"
    name: host3

I couldn't figure out how to do it as a list for example:

hosts:

  • "x.x.x.x"
    name: host1
  • "y.y.y.y"
    name: host2
  • "z.z.z.z"
    name: host3

I think doing it in the list format would be much cleaner and more efficient but I am unable to produce the desired results.

Thank you for the feedback provided @delatucci. Let me clarify a few things:

  1. The id and name monitor options are specific to a monitor (and not to the hosts). For example, a valid configuration would be:
# heartbeat.yml
heartbeat.monitors:
- type: icmp
  id: "my-icmp-monitor-id"
  name: "my-icmp-monitor-name"
  schedule: '*/5 * * * * * *'
  hosts: ["host1,host2,host3"]
heartbeat.scheduler:
  limit: 10
  1. Within an ICMP monitor, you will not be able to define multiple hosts option. hosts can only appear once within the monitor definition and it is an array of hosts to ping. This is why the configuration you mentioned earlier will not work.

  2. If you create an ICMP monitor with multiple hosts to ping, this would correspond to a logical grouping and as such, I do not see what would be the benefits of having a separate id, name for each host.

  3. The only way you could achieve what you want (id, name per monitor per host) would be to define one ICMP monitor for each host. Example of such configuration (not tested):

# heartbeat.yml
heartbeat.monitors:
- type: icmp
  id: "my-icmp-monitor-id1"
  name: "my-icmp-monitor-name1"
  schedule: '*/5 * * * * * *'
  hosts: ["host1"]
- type: icmp
  id: "my-icmp-monitor-id2"
  name: "my-icmp-monitor-name2"
  schedule: '*/5 * * * * * *'
  hosts: ["host2"]
- type: icmp
  id: "my-icmp-monitor-id3"
  name: "my-icmp-monitor-name3"
  schedule: '*/5 * * * * * *'
  hosts: ["host3"]
heartbeat.scheduler:
  limit: 10

I hope that helps.

Thanks Romain,

What i am trying to do:

I am using the ICMP monitor to ping by ip address
I want the id or name to display a Human Readable description of the IP address.
for example my icmp.yml is as follows

  • type: icmp
    name: icmp
    enable: true
    schedule: '@every 2m'
    hosts: "x.x.x.x"
    name: "Printer in John's office"
  • type: icmp
    name: icmp
    enable: true
    schedule: '@every 2m'
    hosts: "y.y.y.y"
    name: "switch in conference room A"
  • type: icmp
    name: icmp
    enable: true
    schedule: '@every 2m'
    hosts: "z.z.z.z"
    name: "Wireless AP in the cube farm"

and so on and so on.

This has worked so far as looking at the Uptime dashboard now I am able to see the names, however, I haven't learned how to sort it or search by name.

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