Skip to content

Vendor Alertmanager config#4905

Merged
ptodev merged 2 commits intomainfrom
ptodev/fix-am-yaml
Nov 21, 2025
Merged

Vendor Alertmanager config#4905
ptodev merged 2 commits intomainfrom
ptodev/fix-am-yaml

Conversation

@ptodev
Copy link
Contributor

@ptodev ptodev commented Nov 21, 2025

#3448 would take the Alertmanager (AM) config from the AM repo:

github.com/prometheus/alertmanager/config

This PR instead copies AM config from the prometheus-operator repo. The benefit in doing this is that there are less side effects during marshal/unmarshal. The main driver is that the official struct from prometheus/alertmanager doesn't even behave consistently across oeprating systems. For example, a test currently fails on Windows:

Diff:
        	            	--- Expected
        	            	+++ Actual
        	            	@@ -248,3 +248,3 @@
        	            	     templates:
        	            	-    - /etc/alertmanager/template/*.tmpl
        	            	+    - testdata\alertmanager\etc\alertmanager\template\*.tmpl

This is because the code checks if templates is an absolute path and modifies it if it's not. On windows, paths starting with / do not look like absolute paths. This is a problem for Alloy since Alloy could be running on a different OS from Alertmanager.

@ptodev ptodev requested a review from a team as a code owner November 21, 2025 13:45
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The "expected" output has changed in some tests, because prometheus/alertmanager would take the global settings and apply them to each route. It would also always print some attributes like continue: false, even thought it's already set to false. I was always aware of this but since it didn't break anything I thought the benefit of using prometheus/alertmanager structs is still worth the downsides.

What changed my mind is when I saw that the file paths get modified, in an OS-inconsistent way no less. I'd rather be safe and use structs which get marshalled and unmarshalled with no side effects.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR vendors Alertmanager configuration types from the prometheus-operator repository instead of using the official prometheus/alertmanager package. This change resolves OS-specific behavior issues during marshal/unmarshal operations, particularly fixing a Windows test failure where absolute path detection caused inconsistent output (paths starting with / are not recognized as absolute on Windows).

Key changes:

  • New vendored types in internal/mimir/alertmanager/types.go with custom String() and Unmarshal() methods
  • Updated imports across codebase from prometheus/alertmanager/config to grafana/alloy/internal/mimir/alertmanager
  • Modified String() method signature to return (string, error) instead of string for better error handling

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
internal/mimir/alertmanager/types.go New vendored Alertmanager config types from prometheus-operator with custom marshaling methods and exported fields
internal/mimir/client/client.go Updated import to use vendored alertmanager types
internal/mimir/client/alerts.go Modified to handle new String() method signature that returns error
internal/mimir/client/alerts_test.go Updated to use new Unmarshal function and YAMLEq for comparison
internal/component/mimir/alerts/kubernetes/events.go Updated imports and error handling for new String() signature
internal/component/mimir/alerts/kubernetes/events_test.go Updated test to use new types and YAMLEq comparison
internal/component/mimir/alerts/kubernetes/alerts.go Updated to use new Unmarshal function and dereference returned pointer
internal/mimir/client/testdata/alertmanager/response.good.yml Removed default values that are no longer emitted by new marshaling
internal/mimir/client/testdata/alertmanager/conf.good.yml Removed comments and added default http_config values
internal/cmd/integration-tests-k8s/tests/mimir-alerts-kubernetes/testdata/expected_1.yml Updated expected output to match new marshaling behavior
internal/cmd/integration-tests-k8s/tests/mimir-alerts-kubernetes/testdata/expected_2.yml Updated expected output to match new marshaling behavior
Makefile Minor documentation formatting improvement

Copy link
Contributor

@jharvey10 jharvey10 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm definitely not an alerts expert, but the changes look pretty straightforward to me.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@ptodev ptodev merged commit 7c53dd1 into main Nov 21, 2025
43 of 45 checks passed
@ptodev ptodev deleted the ptodev/fix-am-yaml branch November 21, 2025 18:48
jharvey10 pushed a commit that referenced this pull request Nov 21, 2025
* Vendor Alertmanager config

* Apply suggestions from code review

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@jharvey10 jharvey10 mentioned this pull request Nov 21, 2025
jharvey10 added a commit that referenced this pull request Nov 24, 2025
* ci: sync publish workflow with main

* Vendor Alertmanager config (#4905)

* Vendor Alertmanager config

* Apply suggestions from code review

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* beyla: add meta_cache_address to beyla.ebpf.attributes.kubernetes (#4871)

* beyla: add meta_cache_address to beyla.ebpf.attributes.kubernetes

* chore: update changelog

* chore: lint

---------

Co-authored-by: Clayton Cornell <131809008+clayton-cornell@users.noreply.github.com>

* Upgrade Beyla component to 2.7.7 (#4891)

* upgrade beyla to 2.7.7

* update to Beyla 2.7.8

* update docs

* fix(pyroscope.ebpf): Use meter noop in otel-ebpf-profiler (#4920)

With a recent change, the default meter provider was no longer
initialized. This change disables the otel-ebpf-profiler internal
metrics to avoid warnings like this to appear:

```
WARN[0121] Invalid metric id 102, skipping
WARN[0121] Invalid metric id 272, skipping
```

* bump rc version in changelog

---------

Co-authored-by: Paulin Todev <paulin.todev@gmail.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Stephen Lang <skl@users.noreply.github.com>
Co-authored-by: Clayton Cornell <131809008+clayton-cornell@users.noreply.github.com>
Co-authored-by: Nikola Grcevski <6207777+grcevski@users.noreply.github.com>
Co-authored-by: Christian Simon <simon@swine.de>
dehaansa pushed a commit to madhub/alloy that referenced this pull request Dec 10, 2025
* Vendor Alertmanager config

* Apply suggestions from code review

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 18, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants