[New Add-on] Grafana Alloy

This is my first Home Assistant Add-on so tread lightly. So far it’s been working well for me, so I figured I’d share incase anyone else want’s to try it out.

Grafana Alloy

Grafana Alloy combines the strengths of the leading collectors into one place. Whether observing applications, infrastructure, or both, Grafana Alloy can collect, process, and export telemetry signals to scale and future-proof your observability approach.

Currently, this add-on supports the following components:

Installation

  1. Add repository to Home Assistant.
  2. Search for “Grafana Alloy” in the Home Assistant add-on store and install it.
  3. Disable “Protection mode” in the add-on panel. (Optional, see below for more details)
  4. Update configuration on the add-on “Configuration” Tab. See options below.
  5. Start the add-on.
  6. Check the Logs to confirm the add-on started successfully.
  7. You can also visit the Grafana Alloy Web UI by visiting http://<homeassistnat_ip>:12345 in your browser.

Protection Mode

Disabling protection mode is optional, however there are a few things that I found don’t work without disabling it. Most the limitations are around host processes. Per the Home Assistant Docs: “Allow the container to run on the host PID namespace. Works only for not protected add-ons.”

Note: These are just the limitations I found, there may be other incorrect or missing metrics.

Only disable the protection mode if you know, need AND trust the source of this add-on. Always review the code of an add-on before disabling protection mode.

Limitations:

prometheus.exporter.process

  • If Protection mode is enabled, the only process that will be collected is the one for Alloy. There will be no metrics for host processes.

prometheus.exporter.unix

  • Process related metrics won’t display any host process information with protection mode enabled.
  • Disk metrics will only show mount data for the Alloy add-on, no host mount data will be collected with protection mode enabled.

loki.source.journal

No limitations that I found.

Configuration

Config Description Default value Required
enable_prometheus Enable sending metrics to Prometheus. If enabled, prometheus_write_endpoint is required. true No
prometheus_write_endpoint Full URL to send metrics to. http://prometheus:9090/api/v1/write If enable_prometheus=true
enable_unix_component Enables prometheus.exporter.unix component to collect node_exporter metrics. true No
enable_process_component Enables prometheus.exporter.process component to collect process_exporter metrics. true No
prometheus_scrape_interval How frequently to scrape the targets of this scrape configuration. No
servername_tag servername tag value value. HomeAssistant No
instance_tag Overwrite the default metric “instance” tag. No
enable_loki Enable sending logs to Loki. If enabled, loki_endpoint is required. false No
loki_endpoint Full Loki URL to send logs to. http://loki:3100/api/v1/push No
override_config If enabled, all other options will be ignored and you can supply your own Alloy config. false No
override_config_path Path to Override Alloy config file. /config/alloy/example.alloy If override_config=true

If override_config is true and a valid Alloy config file is supplied in override_config_path, all other options will be ignored.

Support

  • Tested on aarch64 and amd64.

Todo

  • Add more customization options (Enable/disable components, scrape_interval, etc…)
  • Add Github workflows
  • Build and publish a docker image so users don’t have to build the image on every install
  • Verify all permissions added to config.yaml are required and remove unneeded ones
1 Like

This is awesome, thank you for sharing it. Have you thought about surfacing it through HACS? Gonna try it in a bit anyway but it would be better to avoid extra add-on repositories.

1 Like

Thanks! I haven’t looked into adding it through HACS yet, but if there is enough interest and it makes it easier for people to install/manage, I’ll definitely look into it more.

Hey,

Had a moment to give it a try. It is working great so far. The names of the log sources for the add-ons are a bit ugly but I like it. Is there a way to run this without protection disabled?

Cheers,
Adrian

1 Like

Glad to hear it’s working for you. I just released v0.0.2 with some more customization!

That’s my next task is to check what works/doesn’t work with protection mode disabled as well as go through the permissions.

Have you considered supporting sending sensor data to Prometheus via alloy? I am looking into ways to do this at the moment and this integration via alloy may be a good place.

Although perhaps using Prometheus - Home Assistant is a better approach for this, I am not sure.

If I’m understanding the ask correctly, you’d need a custom addon that pulled the sensor data from HA and expose them for Alloy/Prometheus to scrape. It’s nothing that Alloy or Prometheus can do out of the box.

Edit: Maybe that Prometheus integration is what you’re looking for. I’ll have to play around with it a little more, but it might be possible to scrape the metrics from the Prometheus integration and ship the metrics to the configured prom database.

Edit2: Yeah, looks like the Prometheus integration is what you’re looking for. It provides a bunch of Home Assistant metrics. I don’t think it’s worth it at this time to integrate it into this addon as you can either configure Prometheus to scrape it or add a custom alloy config to do so.

HACS is for integrations, not add-ons.

2 Likes

FYI - I’ve removed the protection mode requirement. There are a few things that won’t work without it that I’ve detailed in the repo.

Thanks for doing this. I have to try the loki setup now, the prometheus one works great.

I also like the option to just provide a custom alloy configuration file. For now I am fine with the provided one, but I can see how I may want to tweak some relabeling and other rules down the road.

1 Like

My thanks as well! I installed this today to forward logs to my Loki instance. So far everything seems to be forwarding as expected! Based on the description of this, I wasn’t sure exactly which logs it would have access to, but I was pleased to see logs from HA core and my other add-ons were all available.

1 Like

Thanks for this greate addon. I create a new loki Addon which supports the new Drill Down Log functionality.

A actualy use promtail togeather with syslog-ng to collect syslogs from other hosts. Is it posible to activate syslog functionality in alloy?

Is it possible to activate the syslog port 514 (udp) like the syslog_ng addon on port 5514? So that Alloy can collect the syslogs from other hosts and containers instead of using the syslog_ng and promtail addon.

Hey, thanks for the interest. I’ve opened up a github request for this and will take a look at implementing when I get a minute.

Is this the functionality you are looking to activate? Have you tried supplying your own config or is there something that needs to be added to the capabilities of the addon?

Hello wymangr,

I’d like to suggest an enhancement for the Grafana Alloy addon.

The container needs to open a port (e.g. 5514/UDP) to enable Alloy to receive syslog messages from other servers. This would only require adding the following to the config.yaml:

ports:
5514/udp:
ports_description:
5514/udp: Alloy syslog port

The configuration shown in the documentation at loki.source.syslog | Grafana Alloy documentation is the correct one. Perhaps this could be integrated into the addon by default, or users could activate this option through a custom Alloy configuration.

Thank you for your great work on this addon!

Best regards,
Frogy76

1 Like

I’ve added the Loki syslog server feature in this release. Let me know if you have any issues.
Edit: There was a bug in 0.0.6, so if anyone updated, update again to v0.0.7.