Binary Agent fails to load config.yaml while docker image succeeds
Hi,
I'm trying to run the agent natively on the OS (no docker). It has an issue with the generated config file from the cloud onboarding instructions:
./agent-linux-amd64 -config.file=${PWD}/promtail/config.yaml
2022-09-01 13:01:17.895532 I | error loading config file /home/ec2-user/promtail/config.yaml: yaml: unmarshal errors:
line 3: field http_listen_port not found in type server.config
line 4: field grpc_listen_port not found in type server.config
line 5: field positions not found in type config.config
line 7: field client not found in type config.config
line 9: field scrape_configs not found in type config.config
When the same config file is used for the docker version it works:
$ docker run --rm --name promtail --volume "$PWD/promtail:/etc/promtail" --volume "/var/log:/var/log" grafana/promtail:master -config.file=/etc/promtail/config.yaml
level=info ts=2022-09-01T13:09:25.187101415Z caller=server.go:260 http=[::]:36829 grpc=[::]:46441 msg="server listening on addresses"
level=info ts=2022-09-01T13:09:25.18745838Z caller=main.go:119 msg="Starting Promtail" version="(version=main-678495a, branch=main, revision=678495a97)"
level=info ts=2022-09-01T13:09:30.187192145Z caller=filetargetmanager.go:255 msg="Adding target" key="/var/log/*.log:{job=\"varlogs\"}"
The config file is the one generated from grafana cloud instractions:
---
server:
http_listen_port: 0
grpc_listen_port: 0
positions:
filename: /tmp/positions.yaml
client:
url: https://<api key>@logs-prod-eu-west-0.grafana.net/loki/api/v1/push
scrape_configs:
- job_name: system
static_configs:
- targets:
- localhost
labels:
job: varlogs
__path__: /var/log/*.log
What is the difference between the docker binary and the native one?
Hey there! The difference is that on the first case you're running the Agent binary, while on the second example you're using the Promtail docker image.
The Agent embeds Promtail for logs, but that is only a subset of its functionality as the Agent also includes metrics, traces, integrations and more.
You can check out our logs documentation or our "migrating from promtail" guide to see how to correctly configure your Agent to collect logs using Promtail.
For your example, it needed a couple of tweaks
- Removing the top-level server key as it doesn't apply to the Agent
- Group configs under a top-level
logs.configskey as an array - Use an array for
clients:which allows you to configure multiple of them
logs:
configs:
- name: "my-logs-job"
positions:
filename: /tmp/positions.yaml
clients:
- url: https://foo:[email protected]/loki/api/v1/push
scrape_configs:
- job_name: system
static_configs:
- targets:
- localhost
labels:
job: varlogs
__path__: /var/log/*.log
This issue has been automatically marked as stale because it has not had any activity in the past 30 days. The next time this stale check runs, the stale label will be removed if there is new activity. The issue will be closed in 7 days if there is no new activity. Thank you for your contributions!
I'm going to close this since it seems like the question was answered. If you need any more help, please open a new issue so we'll see it.