Caution
Grafana Agent has reached End-of-Life (EOL) on November 1, 2025. Agent is no longer receiving vendor support and will no longer receive security or bug fixes. Current users of Agent Static mode, Agent Flow mode, and Agent Operator should proceed with migrating to Grafana Alloy. If you have already migrated to Alloy, no further action is required. Read more about why we recommend migrating to Grafana Alloy.
Important: This documentation is about an older version. It's relevant only to the release noted, many of the features and functions have been updated or replaced. Please view the current version.
01 Basics of Templating
The templating is based on the excellent gomplate library. Currently using a custom fork to allow loading gomplate as a library in addition to some new commands. This will NOT try to cover the full range of gomplate, would recommend reading the documentation for full knowledge.
docker run -v ${PWD}/:/etc/grafana grafana/agentctl:latest template-parse file:///etc/grafana/01_config.yml
Looping
server:
log_level: debug
metrics:
wal_directory: /tmp/grafana-agent-normal
global:
scrape_interval: 60s
remote_write:
- url: https://prometheus-us-central1.grafana.net/api/prom/push
basic_auth:
username: xyz
password: secretpassword
configs:
- name: default
{{ range slice "apple" "banana" "pear" }}
- name: {{ . }}
{{ end }}The templating engine uses directives that are wrapped in {{ command }}, in the above the dynamic configuration engine will loop over the three values, and those values can be accessed by {{ . }} which means current value.
Final
The final.yml contains 4 prometheus configs
- default
- apple
- banana
- pear



