# loki

Grafana Loki log store, single binary on one volume

This page is generated from [`kix/packages/experimental/loki`](https://github.com/kix-run/kix/tree/main/kix/packages/experimental/loki).

| | |
| --- | --- |
| Stability | Experimental |
| `package` value | `packages.experimental.loki` |
| Default software version | `3.7.10` |
| Default aliases | `loki` |
| Highest availability level | `none` |

## How-to guides

- [Install the monitoring stack](/docs/how-to/package-task-guides/install-the-monitoring-stack/)

## Dependencies

Kix matches each dependency below to another package instance by instance name, alias, or role. To bind a specific instance, set [`deps.<name>`](/docs/reference/instances-and-composition/#deps) in your cluster definition. See [Declaring dependencies](/docs/reference/package-anatomy/#declaring-dependencies) for how required and optional dependencies work.

| Dependency | Requirement |
| --- | --- |
| `storage` | Required |
| `prometheus` | Optional |

## Options

### `env`

Extra environment variables. A value is a string, a `fieldRef` source such as `{ valueFrom.fieldRef.fieldPath = "metadata.name"; }`, or a `secretKeyRef` source naming a Secret managed outside Kix with `kix.untrackedRef`. A credential that comes from a dependency is wired by the package. Null removes a variable the package sets by default.

- **Type:** ``attribute set of (null or string or env var source with `valueFrom`)``
- **Default:** `{ }`

### `extraArgs`

Flags appended after the package's own. Loki applies flags after
its config file, so the flags that would override a locked
`settings` path (`-auth.enabled`, `-server.http-listen-port`,
`-common.path-prefix`, `-common.storage.filesystem.*`,
`-common.storage.ring.{instance-addr,store,replication-factor}`),
`-config.file`, `-config.expand-env`, and `-target` fail
evaluation.

- **Type:** `list of string`
- **Default:** `[ ]`
- **Example:**

  ```nix
  [
    "-log.format=json"
  ]
  ```

### `healthCheck.enabled`

Run the package's post-deploy probe (kix.healthCheck) once its resources are ready. A failing probe fails the deploy before the activation switches.

- **Type:** `boolean`
- **Default:** `false`

### `healthCheck.retryFor`

Seconds the probe keeps re-checking before it gives up, so a target still restarting from the rollout does not fail the deploy. The Job's deadline is sized from it.

- **Type:** `signed integer`
- **Default:** `90`

### `image`

Container image for this instance. Set it from a pin file (`kix.pins`) so the deployed reference is committed and resolved.

- **Type:** `submodule`
- **Default:**

  ```nix
  {
    digest = "sha256:b43c257ccfc925d4a50b8717cac61a3b51df8c48d01847936057e5c4075a24a7";
    pullPolicy = "IfNotPresent";
    repository = "docker.io/grafana/loki";
    tag = "3.7.10";
  }
  ```

### `image.digest`

Resolved manifest digest, `sha256:` followed by 64 hex characters. What will actually run. Null means not resolved.

- **Type:** `null or string`
- **Default:** the package's digest while `tag` is the package's tag, otherwise null

### `image.note`

Whatever a person wanted to say about this pin. Kix never reads it and a promotion never discards it. Declared here for the same reason as the three fields above: a pin carries its own record-keeping, and the option accepts the whole pin rather than a subset of it.

- **Type:** `null or string`
- **Default:** `null`

### `image.promotedBy`

Who resolved this pin, for the record. Null when unknown.

- **Type:** `null or string`
- **Default:** `null`

### `image.pullPolicy`

imagePullPolicy for containers using this image. Null leaves it to Kubernetes.

- **Type:** `null or string`
- **Default:** `"IfNotPresent"`

### `image.repository`

Image repository, registry host included.

- **Type:** `string`
- **Default:** `"docker.io/grafana/loki"`

### `image.resolvedAt`

When this pin was resolved, RFC 3339. Null when unknown.

- **Type:** `null or string`
- **Default:** `null`

### `image.sourceRev`

Revision of the source the image was built from, when Kix built it. Null for upstream images.

- **Type:** `null or string`
- **Default:** `null`

### `image.tag`

Image tag. What was asked for.

- **Type:** `string`
- **Default:** `"3.7.10"`

### `metrics.enabled`

Enable metrics endpoint and monitoring resources (ServiceMonitor, PrometheusRules) when prometheus is available.

- **Type:** `boolean`
- **Default:** `true`

### `metrics.interval`

Scrape interval (e.g. "30s"). Null = use Prometheus default.

- **Type:** `null or string`
- **Default:** `null`

### `metrics.maxCompactionAge`

How long Loki may go without a successful compaction, or with retention on, a successful retention run, before LokiCompactionStale or LokiRetentionStale fires, as a Prometheus duration. Null derives each rule's threshold from the merged settings: twice `compactor.compaction_interval` (or `compactor.apply_retention_interval` for retention) plus one hour, and at least 3h, the Loki mixin's threshold. At the default 10m interval both are 3h.

- **Type:** `null or string matching the pattern ([0-9]+(ms|s|m|h|d|w|y))+`
- **Default:** `null`
- **Example:** `"6h"`

### `metrics.requestErrorMinRate`

Requests per second a route must serve before LokiRequestErrors considers its error ratio, so a few failures on a rarely used route do not fire it.

- **Type:** `nonnegative integer or floating point number, meaning >=0`
- **Default:** `0.1`
- **Example:** `1`

### `metrics.requestErrorRatio`

Share of a route's HTTP requests that may answer 5xx before LokiRequestErrors fires. The default is the Loki mixin's.

- **Type:** `integer or floating point number between 0 and 1 (both inclusive)`
- **Default:** `0.1`
- **Example:** `0.05`

### `resources`

Container resource requests and limits. Each field keeps its default until set, and null removes a default.

- **Type:** `submodule`
- **Default:**

  ```nix
  {
    limits = {
      cpu = "1";
      memory = "1Gi";
    };
    requests = {
      cpu = "100m";
      memory = "256Mi";
    };
  }
  ```

### `resources.claims`

Dynamic resource claims the container uses. Null leaves it unset.

- **Type:** `null or (list of (submodule))`
- **Default:** `null`

### `resources.claims.*.name`

Name of an entry in the pod's `resourceClaims`.

- **Type:** `string`

### `resources.claims.*.request`

Request within the claim to use. Null uses the whole claim.

- **Type:** `null or string`
- **Default:** `null`

### `resources.limits`

Resource quantities by name.

- **Type:** `open submodule of attribute set of Kubernetes quantity, such as "500m" or "1Gi" (a non-negative decimal or integer with an optional suffix m, k, M, G, T, P, E, Ki, Mi, Gi, Ti, Pi or Ei)`
- **Default:** `{ }`

### `resources.limits.cpu`

The cpu quantity. Null leaves it unset.

- **Type:** `null or Kubernetes quantity, such as "500m" or "1Gi" (a non-negative decimal or integer with an optional suffix m, k, M, G, T, P, E, Ki, Mi, Gi, Ti, Pi or Ei)`
- **Default:** `"1"`

### `resources.limits.ephemeral-storage`

The ephemeral-storage quantity. Null leaves it unset.

- **Type:** `null or Kubernetes quantity, such as "500m" or "1Gi" (a non-negative decimal or integer with an optional suffix m, k, M, G, T, P, E, Ki, Mi, Gi, Ti, Pi or Ei)`
- **Default:** `null`

### `resources.limits.memory`

The memory quantity. Null leaves it unset.

- **Type:** `null or Kubernetes quantity, such as "500m" or "1Gi" (a non-negative decimal or integer with an optional suffix m, k, M, G, T, P, E, Ki, Mi, Gi, Ti, Pi or Ei)`
- **Default:** `"1Gi"`

### `resources.requests`

Resource quantities by name.

- **Type:** `open submodule of attribute set of Kubernetes quantity, such as "500m" or "1Gi" (a non-negative decimal or integer with an optional suffix m, k, M, G, T, P, E, Ki, Mi, Gi, Ti, Pi or Ei)`
- **Default:** `{ }`

### `resources.requests.cpu`

The cpu quantity. Null leaves it unset.

- **Type:** `null or Kubernetes quantity, such as "500m" or "1Gi" (a non-negative decimal or integer with an optional suffix m, k, M, G, T, P, E, Ki, Mi, Gi, Ti, Pi or Ei)`
- **Default:** `"100m"`

### `resources.requests.ephemeral-storage`

The ephemeral-storage quantity. Null leaves it unset.

- **Type:** `null or Kubernetes quantity, such as "500m" or "1Gi" (a non-negative decimal or integer with an optional suffix m, k, M, G, T, P, E, Ki, Mi, Gi, Ti, Pi or Ei)`
- **Default:** `null`

### `resources.requests.memory`

The memory quantity. Null leaves it unset.

- **Type:** `null or Kubernetes quantity, such as "500m" or "1Gi" (a non-negative decimal or integer with an optional suffix m, k, M, G, T, P, E, Ki, Mi, Gi, Ti, Pi or Ei)`
- **Default:** `"256Mi"`

### `settings`

Loki configuration (`config.yaml` keys) merged over the package's
own. A null removes a key the package sets. A list replaces the
package's list whole, so a new `schema_config.configs` period
restates the earlier ones. The package locks `auth_enabled`,
`server.http_listen_port`, `common.path_prefix`,
`common.storage.filesystem`, `common.instance_addr`,
`common.ring.kvstore`, and `common.replication_factor`; setting
one, or replacing a key above it, fails evaluation. A component's
own key (for example `ingester.lifecycler.ring`) takes precedence
over its `common` default in Loki and is not locked.

Loki runs with `-config.expand-env=true`, so `${NAME}` in a value
reads the container's env var NAME (set it through `env`); an unset
variable becomes an empty string. Write `$$` for a literal `$`.

- **Type:** `attribute set of anything`
- **Default:** `{ }`
- **Example:**

  ```nix
  {
    limits_config = {
      retention_period = "720h";
    };
  }
  ```