The Alloy Operator is a Kubernetes Operator that manages the lifecycle of Grafana Alloy instances. It is built with the Operator SDK using the Alloy Helm chart as its base.
To use the Alloy Operator, there are three steps to follow:
- Deploy the Alloy CustomResourceDefinition (CRD).
- Deploy the Alloy Operator.
- Deploy an Alloy instance.
$ kubectl apply -f https://raw.githubusercontent.com/grafana/alloy-operator/refs/heads/main/operator/manifests/crd.yaml
$ kubectl apply -f https://raw.githubusercontent.com/grafana/alloy-operator/refs/heads/main/operator/manifests/operator.yaml
Create a file for your Alloy instance:
---
apiVersion: collectors.grafana.com/v1alpha1
kind: Alloy
metadata:
name: alloy-test
spec:
alloy:
configMap:
content: |-
prometheus.exporter.self "default" {}
prometheus.scrape "default" {
targets = prometheus.exporter.self.default.targets
forward_to = [prometheus.remote_write.local_prom.receiver]
}
prometheus.remote_write "local_prom" {
endpoint {
url = "http://prometheus-server.prometheus.svc:9090/api/v1/write"
}
}
The spec
section supports all fields in the
Alloy Helm chart's values file.
For some examples, see the tests that are used within this repository:
- Basic Alloy instance
- DaemonSet with HostPath volume mounts
- StatefulSet with WAL
- Remote Configuration
NOTE: The Alloy instances do not deploy the PodLogs CRD, nor does it support the crds
field in the spec
.
We welcome contributions to the Grafana Alloy Operator! Please see our Contributing Guide for more information.