diff --git a/.github/ISSUE_TEMPLATE/blank.yaml b/.github/ISSUE_TEMPLATE/blank.yaml index 9d6245a49e8..6a7a0d1a6b0 100644 --- a/.github/ISSUE_TEMPLATE/blank.yaml +++ b/.github/ISSUE_TEMPLATE/blank.yaml @@ -78,6 +78,7 @@ body: - loki.source.syslog - loki.source.windowsevent - loki.write + - mimir.alerts.kubernetes - mimir.rules.kubernetes - otelcol.auth.basic - otelcol.auth.bearer diff --git a/.github/ISSUE_TEMPLATE/bug_report.yaml b/.github/ISSUE_TEMPLATE/bug_report.yaml index 76be2e90ebc..7fc726d80fc 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yaml +++ b/.github/ISSUE_TEMPLATE/bug_report.yaml @@ -78,6 +78,7 @@ body: - loki.source.syslog - loki.source.windowsevent - loki.write + - mimir.alerts.kubernetes - mimir.rules.kubernetes - otelcol.auth.basic - otelcol.auth.bearer diff --git a/.github/ISSUE_TEMPLATE/docs.yaml b/.github/ISSUE_TEMPLATE/docs.yaml index 407b39a686d..e69a0a34300 100644 --- a/.github/ISSUE_TEMPLATE/docs.yaml +++ b/.github/ISSUE_TEMPLATE/docs.yaml @@ -81,6 +81,7 @@ body: - loki.source.syslog - loki.source.windowsevent - loki.write + - mimir.alerts.kubernetes - mimir.rules.kubernetes - otelcol.auth.basic - otelcol.auth.bearer diff --git a/.github/ISSUE_TEMPLATE/feature_request.yaml b/.github/ISSUE_TEMPLATE/feature_request.yaml index aff80db9c0b..1f0956bd518 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.yaml +++ b/.github/ISSUE_TEMPLATE/feature_request.yaml @@ -78,6 +78,7 @@ body: - loki.source.syslog - loki.source.windowsevent - loki.write + - mimir.alerts.kubernetes - mimir.rules.kubernetes - otelcol.auth.basic - otelcol.auth.bearer diff --git a/.github/ISSUE_TEMPLATE/proposal.yaml b/.github/ISSUE_TEMPLATE/proposal.yaml index 77eafe2ec25..1adf8f6b83f 100644 --- a/.github/ISSUE_TEMPLATE/proposal.yaml +++ b/.github/ISSUE_TEMPLATE/proposal.yaml @@ -78,6 +78,7 @@ body: - loki.source.syslog - loki.source.windowsevent - loki.write + - mimir.alerts.kubernetes - mimir.rules.kubernetes - otelcol.auth.basic - otelcol.auth.bearer diff --git a/.github/workflows/integration-tests-k8s.yml b/.github/workflows/integration-tests-k8s.yml new file mode 100644 index 00000000000..77789c30fb7 --- /dev/null +++ b/.github/workflows/integration-tests-k8s.yml @@ -0,0 +1,23 @@ +name: Integration Tests on Kubernetes +on: + push: + branches: + - main + pull_request: + +permissions: + contents: read + +jobs: + run_tests: + runs-on: + labels: github-hosted-ubuntu-x64-large + steps: + - name: Checkout code + uses: actions/checkout@v4 + - name: Setup Go + uses: actions/setup-go@v5 + with: + go-version-file: go.mod + - name: Run tests + run: make integration-test-k8s diff --git a/CHANGELOG.md b/CHANGELOG.md index 6f24a497b08..13d877ccf04 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,10 @@ internal API changes are not present. Main (unreleased) ----------------- +### Features + +- A new `mimir.alerts.kubernetes` component which discovers `AlertmanagerConfig` Kubernetes resources and loads them into a Mimir instance. (@ptodev) + ### Enhancements - update promtail converter to use `file_match` block for `loki.source.file` instead of going through `local.file_match`. (@kalleep) diff --git a/Makefile b/Makefile index 9ffaffaadb1..fdba97cf948 100644 --- a/Makefile +++ b/Makefile @@ -158,7 +158,7 @@ run-alloylint: alloylint # more for packages that exclude tests via //go:build !race due to known race detection issues. The # final command runs tests for syntax module. test: - $(GO_ENV) go test $(GO_FLAGS) -race $(shell go list ./... | grep -v /integration-tests/) + $(GO_ENV) go test $(GO_FLAGS) -race $(shell go list ./... | grep -v -E '/integration-tests/|/integration-tests-k8s/') $(GO_ENV) go test $(GO_FLAGS) ./internal/static/integrations/node_exporter $(GO_ENV) cd ./syntax && go test -race ./... @@ -180,6 +180,11 @@ test-pyroscope: cd ./internal/component/pyroscope/util/internal/cmd/playground/ && \ $(GO_ENV) go build . +.PHONY: integration-test-k8s +integration-test-k8s: alloy-image + cd ./internal/cmd/integration-tests-k8s/ && \ + $(GO_ENV) go test -timeout 10m ./... + # # Targets for building binaries # diff --git a/docs/sources/reference/components/mimir/mimir.alerts.kubernetes.md b/docs/sources/reference/components/mimir/mimir.alerts.kubernetes.md new file mode 100644 index 00000000000..634e816d561 --- /dev/null +++ b/docs/sources/reference/components/mimir/mimir.alerts.kubernetes.md @@ -0,0 +1,495 @@ +--- +canonical: https://grafana.com/docs/alloy/latest/reference/components/mimir/mimir.alerts.kubernetes/ +aliases: + - ../mimir.alerts.kubernetes/ # /docs/alloy/latest/reference/components/mimir.alerts.kubernetes/ +description: Learn about mimir.alerts.kubernetes +labels: + stage: experimental + products: + - oss +title: mimir.alerts.kubernetes +--- + +# `mimir.alerts.kubernetes` + +{{< docs/shared lookup="stability/experimental.md" source="alloy" version="" >}} + +`mimir.alerts.kubernetes` discovers `AlertmanagerConfig` Kubernetes resources and loads them into a Mimir instance. + +* You can specify multiple `mimir.alerts.kubernetes` components by giving them different labels. +* You can use [Kubernetes label selectors][] to limit the `Namespace` and `AlertmanagerConfig` resources considered during reconciliation. +* Compatible with the Alertmanager APIs of Grafana Mimir, Grafana Cloud, and Grafana Enterprise Metrics. +* Compatible with the `AlertmanagerConfig` CRD from the [`prometheus-operator`][prometheus-operator]. +* This component accesses the Kubernetes REST API from [within a Pod][]. + +{{< admonition type="note" >}} +This component requires [Role-based access control (RBAC)][] to be set up in Kubernetes in order for {{< param "PRODUCT_NAME" >}} to access it via the Kubernetes REST API. + +[Role-based access control (RBAC)]: https://kubernetes.io/docs/reference/access-authn-authz/rbac/ +{{< /admonition >}} + +`mimir.alerts.kubernetes` doesn't support [clustering][clustered mode]. +[clustered mode]: ../../../../get-started/clustering/ + +[Kubernetes label selectors]: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#label-selectors +[prometheus-operator]: https://prometheus-operator.dev/ +[within a Pod]: https://kubernetes.io/docs/tasks/run-application/access-api-from-pod/ + +## Usage + +```alloy +mimir.alerts.kubernetes "