Good morning, I’ve managed to get Prometheus metrics through to my Grafana Cloud by using the Grafana Agent instead of standard Prometheus. Now I want to get logs into Loki. Is there a custom agent for that as well?
Good morning! Grafana Cloud Agent can also send logs to your Loki instance in the Cloud. If you’re using k8s, then you can take a look at the manifest (https://github.com/grafana/agent/blob/master/production/kubernetes/agent-loki.yaml), installation script (https://github.com/grafana/agent/blob/master/production/kubernetes/install-loki.sh) or general k8s docs - https://github.com/grafana/agent/tree/master/production/kubernetes.
Here’s a bit more info regarding sending logs - https://github.com/grafana/agent/blob/master/docs/getting-started.md#loki-configmigrating-from-promtail.
Aha cool, so it’s just a matter of extending the config yaml?
I want to try it on my dev box first
Yeah, it’s just the matter of configuration
Ok but the agent currently scrapes the metrics by calling the /metrics endpoint on the server. How does it get the logs?
I’m using slf4j with logback
Also, this config looks different to what the wizard generates
are you saying the agent has promtail inside it?
- mind me asking - which wizard are you refering to ?
The one in the lightning menu
Walkthrough, it’s called
Ok from what I can read, I need logback to write a file and I simply tell the agent config what the file is, and it ships it to the cloud?
the agent uses the same logic as promtail, yes, albeit the config is slightly different. As far as promtail configuration goes, you can check out https://grafana.com/docs/loki/latest/getting-started/get-logs-into-loki/
Tl;dr you need to figure out proper promtail config for your use-case and then add it to grafana cloud agent config (possibly with minor adjustments).
Now I’m more confused. I already have a working Prometheus metrics config that uses the agent. I can add a section and that will use the agent’s built-in promtails?
> I can add a section and that will use the agent’s built-in promtails?
Yes.
So in your agent config you have a prometheus
section. To get the agent to scrape logs, you’d need to add a loki
section. Here’s an example from the docs (https://github.com/grafana/agent/blob/master/docs/getting-started.md):
configs:
- name: default
positions:
filename: /tmp/positions.yaml
scrape_configs:
- job_name: varlogs
static_configs:
- targets: [localhost]
labels:
job: varlogs
__path__: /var/log/*log
clients:
- url: [http://localhost:3100/loki/api/v1/push](http://localhost:3100/loki/api/v1/push)```
Cool thanks. Sorry I was away earlier. I’ll check it out.
My main question is the URL it pushes to. Should that be replaced by some grafana cloud URL?