Closed Rotfuks closed 1 week ago
Assuming that you already have Mimir installed.
Install Alloy
helm repo add grafana https://grafana.github.io/helm-charts
helm repo update
kubectl create namespace alloy
kubectl config set-context --current --namespace alloy
helm install --namespace alloy alloy grafana/alloy
Configure Alloy to import rules into Mimir
cat <<EOF > rules-alloy
mimir.rules.kubernetes "local" {
address = "http://mimir-gateway.mimir"
tenant_id = "tenant-1"
rule_namespace_selector {
match_labels = {
"kubernetes.io/metadata.name" = "alloy",
}
}
rule_selector {
match_labels = {
"foo" = "bar",
}
}
}
EOF
cat <
kubectl create configmap alloy-config "--from-file=alloy.config=./rules-alloy" helm upgrade -n alloy alloy grafana/alloy -f values.yaml
3. Create a PrometheusRule
```yaml
cat <<EOF > promrule.yaml
apiVersion: monitoring.coreos.com/v1
kind: PrometheusRule
metadata:
labels:
foo: bar
name: import-me
spec:
groups:
- name: dummy_group
rules:
- expr: dummy_expr
record: dummy_record
EOF
kubectl apply -f promrule.yaml
$ kubectl -namespace mimir port-forward svc/mimir-ruler 8080
$ mimirtool rules list --address='http://127.0.0.1:8080' --id=tenant-1
Namespace | Rule Group
alloy/alloy/import-me/fe097cad-fe46-49eb-af70-0f6e38b7dda9 | dummy_group
Motivation
We want to replace Grafana Agents everywhere with GrafanaLabs new OpenTelemetry Agent Alloy. Our Grafana Agent which is just for importing prometheus-rules into Mimir is a good starting point to get first experience with Alloy.
Todo
Outcome