# How can I export host errors?

**URL:** <https://forum.ansible.com/t/how-can-i-export-host-errors/9847>\
**Category:** Get Help\
**Tags:** azure, playbook\
**Created:** [October 7, 2024, 9:43pm UTC](https://forum.ansible.com/t/how-can-i-export-host-errors/9847 "2024-10-07T21:43:11Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![MrPoulet](https://avatars.discourse-cdn.com/v4/letter/m/cdc98d/32.png) [@MrPoulet](https://forum.ansible.com/u/MrPoulet)\
**Post date:** [October 7, 2024, 9:43pm UTC](https://forum.ansible.com/t/how-can-i-export-host-errors/9847/1 "2024-10-07T21:43:11Z")

</div>

Hello,

For over a year, I’ve been working on and off on a pipeline for exporting all sorts of playbook statistics to Azure Log Analytics and then to Grafana. It has been extremely useful in getting a better view of all my Ansible operations.

It works kinda like this:

```auto
tasks: 
  - block:
     [do the thing]

   always:
     - include_role:
           name: export_playbook_stats

```

I even wrote a callback plugin to export the task timers to localhost so that they too can be exported as a log.

```auto
self.vars_manager.set_host_variable("localhost", 'task_timers', [v for _, v in self.stats.items()])

```

I have a dashboard that shows all sorts of stats about a play, such as which hosts fail most often, but something is missing: The error message associated with that host.

Adding `register` to every task is unfeasible. Even more so because a host gets kicked out once if fails the play.

Those error messages are written somewhere, does anyone know where they are and how I can bring them up to the surface of the play so that I may export them?

Thanks,

---

<div class="post-metadata">

**Author:** ![mikemorency](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/mikemorency/32/2672_2.png) [@mikemorency](https://forum.ansible.com/u/mikemorency)\
**Post date:** [October 8, 2024, 3:53pm UTC](https://forum.ansible.com/t/how-can-i-export-host-errors/9847/2 "2024-10-08T15:53:35Z")

</div>

A callback plugin would be the appropriate way to do this. When ansible executes, all of the outputs are processed by the callback plugin, which then shows/exports that data to some source. The default is to the console, but you could export that data to some other source.

See the callback plugins available here [Index of all Callback Plugins — Ansible Community Documentation](https://docs.ansible.com/ansible/latest/collections/index_callback.html)  
Some are similar to your use case, like exporting to splunk, logstash, opentelemetry…You could use those to guide your own plugin that exports to ALA

Also, theres already a plugin for grafana. You may just want to skip ALA and go straight there.

Edit: Actually, theres already a plugin for ALA too [community.general.loganalytics callback – Posts task results to Azure Log Analytics — Ansible Community Documentation](https://docs.ansible.com/ansible/latest/collections/community/general/loganalytics_callback.html#ansible-collections-community-general-loganalytics-callback)
