# k8s-event-exporter — watches Kubernetes Events and logs them to stdout as # structured JSON. Promtail tails the logs and ships them to Loki with the # label app=kubernetes-event-exporter. The Hermes agent queries them with LogQL: # {app="kubernetes-event-exporter"} |= "BackOff" # # This avoids giving the agent any k8s API token for events — the exporter # has its own narrow read-only SA, and the agent only talks to Loki. --- apiVersion: v1 kind: ServiceAccount metadata: name: k8s-event-exporter namespace: monitoring --- apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: name: k8s-event-exporter rules: - apiGroups: [""] resources: - events - pods verbs: ["get", "list", "watch"] --- apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRoleBinding metadata: name: k8s-event-exporter roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole name: k8s-event-exporter subjects: - kind: ServiceAccount name: k8s-event-exporter namespace: monitoring --- apiVersion: v1 kind: ConfigMap metadata: name: k8s-event-exporter-config namespace: monitoring data: config.yaml: | logLevel: info logFormat: json route: routes: - match: - receiver: dump receivers: - name: dump dump: {} --- apiVersion: apps/v1 kind: Deployment metadata: name: k8s-event-exporter namespace: monitoring labels: app: kubernetes-event-exporter spec: replicas: 1 selector: matchLabels: app: kubernetes-event-exporter template: metadata: labels: app: kubernetes-event-exporter spec: serviceAccountName: k8s-event-exporter nodeSelector: kubernetes.io/arch: amd64 containers: - name: exporter image: opsgenie/kubernetes-event-exporter:0.9 args: - -conf=/config/config.yaml volumeMounts: - name: config mountPath: /config readOnly: true resources: requests: memory: "32Mi" cpu: "25m" limits: memory: "128Mi" cpu: "100m" volumes: - name: config configMap: name: k8s-event-exporter-config