> ## 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.

# Demo Loki Installation

> Guide to manually install Loki on Ubuntu, configure Grafana as a Loki datasource, and use Promtail to collect and forward logs between nodes.

This guide shows how to install a standalone Loki instance and configure Grafana to query logs from it. The demo uses two Ubuntu nodes:

* node01 — runs Grafana (already installed) and will host Loki in this tutorial.
* node02 — a separate Ubuntu node from which we will collect logs using an agent.

Note: Installing Grafana and Loki on the same machine is purely for demo convenience. In production, run them on separate hosts or in a distributed setup.

This lesson demonstrates a manual Loki installation using the binary download. You can also [install Loki via your package manager (apt/dnf) or follow the installation options](https://grafana.com/docs/loki/latest/installation/) or run it in Kubernetes.

Prerequisites

* SSH access to `node01` and `node02`.
* Example: SSH from node01 to node02:

```bash theme={null}
bob@node01:~$ ssh node02
Welcome to Ubuntu 20.04.3 LTS (GNU/Linux 6.8.0-124-generic x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

Last login: Sun Jul 26 13:59:37 2026 from 10.244.51.183

bob@node02:~$
```

Quick reference — default ports and paths

| Component | Default port / path | Notes |
| - | - | - |
| Loki HTTP API | `3100` | API & Grafana queries |
| Loki gRPC | `9096` | Used by some clients |
| Local TSDB path in example | `/tmp/loki` | Demo-only filesystem storage |
| Promtail push endpoint | `http://node01:3100/loki/api/v1/push` | Used by promtail on node02 |

Downloading the Loki release (manual install)

1. Browse the [Loki releases](https://github.com/grafana/loki/releases) and pick the Linux AMD64 asset for your desired version. On the release page select the `loki-linux-amd64.zip` file and copy its download URL.

![A dark-themed screenshot of a software "Release list" page showing version entries on the left and a list of downloadable build assets (zip/exe files) on the right with SHA256 hashes, file sizes, and recent timestamps.](https://mintcdn.com/kodekloud-c4ac6d9a/dEcIUoAxuol-3ZBK/images/Grafana-Loki/Grafana-Loki-Essentials/Demo-Loki-Installation/release-list-build-assets-screenshot.jpg?fit=max\&auto=format\&n=dEcIUoAxuol-3ZBK\&q=85\&s=d7a1f331c9013de95a014eabf012b510)

2. On `node01`, download the zip, unzip it, and make the binary executable:

```bash theme={null}
# download (example URL)
bob@node01:~$ wget https://github.com/grafana/loki/releases/download/v3.6.13/loki-linux-amd64.zip

# list and unzip
bob@node01:~$ ls
loki-linux-amd64.zip

bob@node01:~$ unzip loki-linux-amd64.zip
Archive:  loki-linux-amd64.zip
  inflating: loki-linux-amd64

bob@node01:~$ ls
loki-linux-amd64  loki-linux-amd64.zip

# make executable
bob@node01:~$ chmod +x loki-linux-amd64
```

Tip: Optionally move the binary to a system path, for example `/usr/local/bin`, so you can run `loki-linux-amd64` from any directory.

Download and review a sample configuration

Loki ships a sample local configuration you can use to get started:

```bash theme={null}
bob@node01:~$ wget https://raw.githubusercontent.com/grafana/loki/main/cmd/loki/loki-local-config.yaml
```

Open the sample config to review or edit. A trimmed excerpt showing important sections:

```yaml theme={null}
server:
  http_listen_port: 3100
  grpc_listen_port: 9096
  log_level: debug
  grpc_server_max_concurrent_streams: 1000

common:
  instance_addr: 127.0.0.1
  path_prefix: /tmp/loki
  storage:
    filesystem:
      chunks_directory: /tmp/loki/chunks
      rules_directory: /tmp/loki/rules
  replication_factor: 1
  ring:
    kvstore:
      store: inmemory

query_range:
  results_cache:
    cache:
      embedded_cache:
        enabled: true
        max_size_mb: 100

limits_config:
  metric_aggregation_enabled: true
  enable_multi_variant_queries: true

schema_config:
  configs:
    - from: 2020-10-24
      store: tsdb
      object_store: filesystem
      schema: v13
      index:
        prefix: index_
        period: 24h

ruler:
  alertmanager_url: http://localhost:9093

frontend:
  encoding: protobuf
```

This sample binds the HTTP API on port `3100` and gRPC on `9096`, stores data under `/tmp/loki`, and uses the filesystem TSDB — appropriate only for demos and evaluation.

Start Loki with the config file

Run Loki and point it to the downloaded configuration file:

```bash theme={null}
bob@node01:~$ ./loki-linux-amd64 --config.file=loki-local-config.yaml
```

If you want to run Loki in the background or as a service, create a systemd unit or use a process manager (not covered in detail here). Using systemd is recommended for production-style deployments.

Verify Loki is running

Loki exposes Prometheus-style metrics at `/metrics`. From `node01` check:

```bash theme={null}
bob@node01:~$ curl -s http://localhost:3100/metrics | head -n 20
# HELP deprecated_flags_inuse_total The number of deprecated flags currently set.
# TYPE deprecated_flags_inuse_total counter
deprecated_flags_inuse_total 0
# HELP go_cgo_go_to_c_calls_calls_total Count of calls made from Go to C by the current process. Sourced from /cgo/go-to-c-calls:calls.
# TYPE go_cgo_go_to_c_calls_calls_total counter
go_cgo_go_to_c_calls_calls_total 0
# HELP go_cpu_classes_gc_mark_assist_cpu_seconds_total Estimated total CPU time goroutines spent performing GC tasks to assist the GC and prevent it from falling behind the application.
# TYPE go_cpu_classes_gc_mark_assist_cpu_seconds_total counter
go_cpu_classes_gc_mark_assist_cpu_seconds_total 0.000561987
```

If you see similar output, Loki is running and responding on `http://localhost:3100`.

Connect Grafana to Loki

1. In Grafana (running on `node01` in this demo), add a new data source of type "Loki" — see the official docs: [Grafana Loki datasource](https://grafana.com/docs/grafana/latest/datasources/loki/).
2. Set the URL to `http://localhost:3100` and click "Save & Test". Grafana should report a successful connection.
3. Open Explore, select the Loki data source, and start running log queries.

![A dark-themed Grafana Explore screen using the Loki datasource, showing a query builder with label filters and a large "No data" panel. The left sidebar displays navigation items like Home, Dashboards, Explore, and Connections.](https://mintcdn.com/kodekloud-c4ac6d9a/dEcIUoAxuol-3ZBK/images/Grafana-Loki/Grafana-Loki-Essentials/Demo-Loki-Installation/grafana-explore-loki-no-data-panel.jpg?fit=max\&auto=format\&n=dEcIUoAxuol-3ZBK\&q=85\&s=66956ce2a89f7a995e5e0ae081248057)

Collecting logs from node02 (install an agent)

Grafana can query Loki now, but Loki has no log streams yet. To forward logs from `node02` to `node01`, install a log shipper such as Promtail on `node02`.

A minimal `promtail` configuration that pushes logs to the Loki HTTP endpoint:

```yaml theme={null}
server:
  http_listen_port: 9080

clients:
  - url: http://node01:3100/loki/api/v1/push

scrape_configs:
  - job_name: system
    static_configs:
      - targets:
          - localhost
        labels:
          job: varlogs
          __path__: /var/log/*.log
```

Steps to install Promtail on node02:

1. Download the matching Promtail release (from the official releases), unzip, and make the binary executable.
2. Save the YAML config above as `promtail-config.yaml` on `node02`.
3. Start promtail pointing to the config file, for example:

```bash theme={null}
bob@node02:~$ ./promtail-linux-amd64 -config.file=promtail-config.yaml
```

Promtail will tail `/var/log/*.log` (or any paths you configure) and push log streams to `http://node01:3100/loki/api/v1/push`. Once promtail is running and sending logs, refresh Grafana Explore — log labels and messages should appear.

Closing notes and production considerations

* For production, use durable object stores such as S3 or GCS instead of the local filesystem and configure retention, replication, and authentication accordingly.
* To scale Loki and make it discoverable or load-balanced across instances, review Loki's storage and ring configuration in the [official docs](https://grafana.com/docs/loki/latest/operations/).
* You can point Loki at multiple configuration files by passing a comma-separated list to `--config.file`. Use `--verify-config` to validate configuration before starting.

Example flags:

```bash theme={null}
bob@node01:~$ ./loki-linux-amd64 --help | grep config
--config.file string       configuration file to load, can be a comma separated list of paths, first existing file will be used (default "config.yaml,config/config.yaml")
--runtime-config.file value Comma separated list of yaml files with the configuration that can be updated at runtime.
--schema-config-file string Path to the schema config file.
--verify-config             Verify config file and exit
```

This tutorial uses local filesystem storage and runs components on the same host for simplicity. Do not use this setup for production workloads — configure durable object storage, secure networking, and proper service management.

Links and references

* Grafana Loki documentation — [https://grafana.com/docs/loki/latest/](https://grafana.com/docs/loki/latest/)
* Promtail (Loki client) docs — [https://grafana.com/docs/loki/latest/clients/promtail/](https://grafana.com/docs/loki/latest/clients/promtail/)
* Loki releases — [https://github.com/grafana/loki/releases](https://github.com/grafana/loki/releases)

That completes the basic manual installation and Grafana integration steps for Loki.

> **[Watch Video](https://learn.kodekloud.com/user/courses/grafana-loki/module/d9262c89-9213-4e21-8599-d54b9c773885/lesson/22be9fc8-4328-4bf9-9574-bf708b5d45b0)**


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