Caution
Grafana Alloy is the new name for our distribution of the OTel collector. Grafana Agent has been deprecated and is in Long-Term Support (LTS) through October 31, 2025. Grafana Agent will reach an End-of-Life (EOL) on November 1, 2025. Read more about why we recommend migrating to Grafana Alloy.
eventhandler_config next
eventhandler_config
configures the Kubernetes eventhandler integration. This
integration watches
Event
resources in a Kubernetes cluster and forwards them as log entries to a Loki
sink. This integration depends on the experimental integrations-next
feature
being enabled.
On restart, the integration will look for a cache file (configured using
cache_path
) that stores the last shipped event. This file is optional, and if
present, will be used to avoid double-shipping events if Agent or the
integration restarts. Kubernetes expires events after 60 minutes, so events
older than 60 minutes ago will never be shipped.
To use the cache feature and maintain state in a Kubernetes environment, a StatefulSet must be used. Sample manifests are provided at the bottom of this doc. Please adjust these according to your deployment preferences. You can also use a Deployment, however the presence of the cache file will not be guaranteed and the integration may ship duplicate entries in the event of a restart. Loki does not yet support entry deduplication for the A->B->A case, so further deduplication can only take place at the Grafana / front-end layer (Grafana Explore does provide some deduplication features for Loki datasources).
This integration uses Grafana Agent’s embedded Loki-compatible logs
subsystem
to ship entries, and a logs client and sink must be configured to use the
integration. Please see the sample Agent config below for an example
configuration.
Pipelines
and relabel configuration are not yet supported, but these features will be
added soon. You should use the job=eventhandler cluster=...
labels to query
your events (you can then use LogQL on top of the result set).
If not running the integration in-cluster, the integration will use
kubeconfig_path
to search for a valid Kubeconfig file, defaulting to a
kubeconfig in the user’s home directory. If running in-cluster, the appropriate
ServiceAccount
and Roles must be defined. Sample manifests are provided
below.
Configuration reference:
Sample agent config:
server:
log_level: info
integrations:
eventhandler:
cache_path: "/etc/eventhandler/eventhandler.cache"
logs:
configs:
- name: default
clients:
- url: https://logs-prod-us-central1.grafana.net/api/prom/push
basic_auth:
username: YOUR_LOKI_USER
password: YOUR_LOKI_API_KEY
external_labels:
cluster: "cloud"
positions:
filename: /tmp/positions0.yaml
Be sure to replace the Loki credentials with the appropriate values.
Sample StatefulSet manifests. Please adjust these according to your needs: