That's a great point. Luckily this is possible. I've actually just created a pull request to better document adding those fields. You can interpolate any fields you like with the standard fields option, which is per-monitor.
For convenience I've included an example below. You may also want to set fields_under_root: true
in your config if you'd prefer for those fields to be at the root level of your ES documents instead of the fields
key.
heartbeat.autodiscover:
providers:
- type: docker
templates:
- condition:
contains:
docker.container.image: redis
config:
- type: tcp
hosts: ["${data.host}:${data.port}"]
schedule: "@every 1s"
timeout: 1s
fields:
container_id: "${data.docker.container.id}"
container_image: "${data.docker.container.image}"
container_name: "${data.docker.container.name}"