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.
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.
02 Datasources
Datasources are a powerful concept in gomplate. They allow you to reach out to other files, systems and resources to pull data.
docker run -v ${PWD}/:/etc/grafana grafana/agentctl:latest template-parse file:///etc/grafana/02_config.yml
Config
The config.yml adds a new field sources
. Sources can be any number of things defined in the gomplate datasources documentation. In this example using fruit.
template_paths:
- "file:///etc/grafana/01_assets"
datasources:
- name: fruit
url: "file://etc/grafana/01_assets/fruit.json"
["mango","peach","orange"]
Usage
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 (datasource "fruit") }}
- name: {{ . }}
{{ end }}
A Datasource is reference by name and in this case it is an array and used exactly like the looping example.