> ## Documentation Index
> Fetch the complete documentation index at: https://notes.kodekloud.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Installing the Grafana Alloy Agent

> Guide to installing and configuring Grafana Alloy agents to discover, tail, batch, and ship host logs to Loki as the supported replacement for Promtail

We built the sorting center. Now we need the couriers.

Picture a courier stationed at each building. Their whole job is to pick up the mail as it arrives and deliver it to the sorting center repeatedly, without anyone having to ask each time.

![A slide titled "Now we need couriers" showing three building icons with courier avatars and mail icons on the left, and a large illustrated "sorting center" building on the right.](https://mintcdn.com/kodekloud-c4ac6d9a/dEcIUoAxuol-3ZBK/images/Grafana-Loki/Grafana-Loki-Essentials/Installing-the-Grafana-Alloy-Agent/couriers-buildings-mail-sorting-center.jpg?fit=max\&auto=format\&n=dEcIUoAxuol-3ZBK\&q=85\&s=a973d7df45d6bf8a7da1c27c4161ccb0)

Your machines need the same thing.

Loki is running, but it will remain empty until something sends logs to it. On each host, your applications write log files; you need an agent to watch those files and forward every new line to Loki as it appears.

That role is fulfilled by Grafana Alloy.

Alloy is a lightweight, host-level agent you install on every machine — like a courier at each building — which ships logs to Loki on your behalf. If you’ve used Promtail in older guides, note that Promtail has been deprecated; Grafana now recommends Alloy as the supported successor.

![A simple architecture diagram titled "Meet Grafana Alloy" showing logs (app.log, syslog) on "your server" collected by an Alloy agent and sent along a line to a Loki inbox on the right. The image also notes Promtail as retired and Alloy as the replacement.](https://mintcdn.com/kodekloud-c4ac6d9a/dEcIUoAxuol-3ZBK/images/Grafana-Loki/Grafana-Loki-Essentials/Installing-the-Grafana-Alloy-Agent/grafana-alloy-agent-logs-to-loki.jpg?fit=max\&auto=format\&n=dEcIUoAxuol-3ZBK\&q=85\&s=f0307e27c41fd90b28ebb1c6d1cfeee3)

We will use Alloy for the rest of this lesson.

How Alloy works (high level)

* Alloy’s configuration is built from small, focused components. You connect these components into a pipeline so that the output of one is the input of the next.
* Typical pipeline stages:
  * File discovery — find the log files to read (for example, everything under `/var/log`).
  * File tailing — follow files and emit each new line as it is written.
  * Batching and shipping — group entries and forward them to your Loki server endpoint.

Think of it as a conveyor belt: discovery feeds tailing, tailing feeds batching, and batching pushes into Loki.

Table — Alloy pipeline components (overview)

| Pipeline stage | Purpose | Example / Notes |
| -: | - | - |
| File discovery | Locate files to ingest (paths, glob patterns) | Common paths: `/var/log`, application log directories |
| File tailing | Read files line-by-line and produce log entries | Handles rotated files and new data appended to files |
| Batching & shipping | Buffer entries and send them to Loki over HTTP | Sends to Loki push endpoint (e.g. `https://loki.example.com/loki/api/v1/push`) |

Promtail — which you may see in older guides — is deprecated. Use Alloy as the supported replacement for tailing and shipping logs to Loki. For official docs and migration guidance, see the Grafana Alloy and Loki documentation.

Simple, conceptual example configuration

The exact syntax of Alloy configuration depends on the agent version and installer you use. The snippet below is a simplified conceptual example to illustrate the pipeline idea:

```yaml theme={null}
# Conceptual example only — check official docs for real syntax
components:
  - type: file_discovery
    paths:
      - /var/log/*.log
      - /srv/app/logs/*.log

  - type: file_tailer
    follow: true
    encoding: utf-8

  - type: loki_shipper
    url: "https://loki.example.com/loki/api/v1/push"
    batch:
      max_size: 1048576
      timeout: 5s
```

Next steps

* Install Alloy on each host you want to collect logs from.
* Configure discovery patterns to include your application and system logs.
* Point Alloy at your Loki instance (use the Loki push endpoint).
* Test by generating log lines and verifying they appear in Loki / Grafana.

Links and references

* Grafana Alloy documentation: [https://grafana.com/docs/alloy](https://grafana.com/docs/alloy)
* Grafana Loki documentation: [https://grafana.com/docs/loki](https://grafana.com/docs/loki)

This establishes the courier pattern: lightweight agents on each host continuously collect and forward logs into the sorting center (Loki), so you can search, visualize, and alert on your logs centrally.

> **[Watch Video](https://learn.kodekloud.com/user/courses/grafana-loki/module/d9262c89-9213-4e21-8599-d54b9c773885/lesson/8972dda1-ff7d-4ebf-aab9-5ba23a7a0029)**


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.