github.com/yankunsam/loki/v2@v2.6.3-0.20220817130409-389df5235c27/production/docker/README.md (about)

     1  # Loki with docker-compose
     2  
     3  You can use this `docker-compose` setup to run Docker for development or in production.
     4  
     5  ## Features
     6  
     7  - Running in [Simple Scalable Deployment](https://grafana.com/docs/loki/latest/fundamentals/architecture/deployment-modes/#simple-scalable-deployment-mode) mode with 3 replicas for `read` and `write` targets
     8  - Memberlist for [consistent hash](https://grafana.com/docs/loki/latest/fundamentals/architecture/rings/) ring
     9  - [Minio](https://min.io/) for S3-compatible storage for chunks & indexes
    10  - nginx gateway which acts as a reverse-proxy to the read/write paths
    11  - Promtail for logs
    12    - An optional log-generator
    13  - Multi-tenancy enabled (`docker` as the tenant ID)
    14  - Configuration for interactive debugging (see [Debugging](#debugging) section below)
    15  - Prometheus for metric collection
    16  
    17  ## Diagram
    18  
    19  The below diagram describes the various components of this deployment, and how data flows between them.
    20  
    21  ```mermaid
    22  graph LR
    23      Grafana --> |Query logs| nginx["nginx (port: 8080)"]
    24      Promtail -->|Send logs| nginx
    25  
    26      nginx -.-> |read path| QueryFrontend["query-frontend"]
    27      nginx -.-> |write path| Distributor
    28  
    29      QueryFrontend -.-> Querier
    30  
    31      subgraph LokiRead["loki -target=read"]
    32          Querier["querier"]
    33      end
    34  
    35      subgraph Minio["Minio Storage"]
    36          Chunks
    37          Indexes
    38      end
    39  
    40      subgraph LokiWrite["loki -target=write"]
    41          Distributor["distributor"] -.-> Ingester["ingester"]
    42          Ingester
    43      end
    44  
    45      Querier --> |reads| Chunks & Indexes
    46      Ingester --> |writes| Chunks & Indexes
    47  ```
    48  
    49  ## Getting Started
    50  
    51  Simply run `docker-compose up` and all the components will start.
    52  
    53  It'll take a few seconds for all the components to start up and register in the [ring](http://localhost:8080/ring). Once all instances are `ACTIVE`, Loki will start accepting reads and writes. All logs will be stored with the tenant ID `docker`.
    54  
    55  All data will be stored in the `.data` directory.
    56  
    57  The nginx gateway runs on port `8080` and you can access Loki through it.
    58  
    59  Prometheus runs on port `9090`, and you can access all metrics from Loki & Promtail here.
    60  
    61  Grafana runs on port `3000`, and there are Loki & Prometheus datasources enabled by default.
    62  
    63  ## Endpoints
    64  
    65  - [`/ring`](http://localhost:8080/ring) - view all components registered in the hash ring
    66  - [`/config`](http://localhost:8080/config) - view the configuration used by Loki
    67  - [`/memberlist`](http://localhost:8080/memberlist) - view all components in the memberlist cluster
    68  - [all other Loki API endpoints](https://grafana.com/docs/loki/latest/api/)
    69  
    70  ## Debugging
    71  
    72  First, you'll need to build a Loki image that includes and runs [delve](https://github.com/go-delve/delve).
    73  
    74  Run `make loki-debug-image` from the root of this project. Grab the image name from the output (it'll look like `grafana/loki:...-debug`) and replace the Loki images in `docker-compose.yaml`.
    75  
    76  Next, view the `docker-compose.yaml` file and uncomment the sections related to debugging.
    77  
    78  You can follow [this guide](https://blog.jetbrains.com/go/2020/05/06/debugging-a-go-application-inside-a-docker-container/) to enable debugging in GoLand, but the basic steps are:
    79  
    80  1. Bind a host port to one of the Loki services
    81  2. Add a _Go Remote_ debug configuration in GoLand and use that port
    82  3. Run `docker-compose up`
    83  4. Set a breakpoint and start the debug configuration
    84  5. Build/debug something awesome :)