Skip to content
This repository was archived by the owner on Jul 28, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions docs/configuration/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Prometheus instances.

- [server_config]({{< relref "./server-config" >}})
- [prometheus_config]({{< relref "./prometheus-config" >}})
- [loki_config]({{< relref "./loki-config" >}})
- [logs_config]({{< relref "./logs-config.md" >}})
- [traces_config]({{< relref "./traces-config" >}})
- [integrations_config]({{< relref "./integrations/_index.md" >}})

Expand Down Expand Up @@ -103,8 +103,9 @@ Support contents and default values of `agent.yaml`:
# Configures Prometheus instances.
[prometheus: <prometheus_config>]

# Configures Loki log collection.
[loki: <loki_config>]
# Configures log collection.
# In previous versions of the Agent, this field was called "loki".
[logs: <logs_config>]

# Configures Traces trace collection.
[traces: <traces_config>]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
+++
title = "loki_config"
weight = 300
aliases = ["/docs/agent/latest/configuration/loki-config/"]
+++

# loki_config
Expand Down
14 changes: 7 additions & 7 deletions production/tanka/grafana-agent/v1/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ incompatible changes will be made.
This library is significantly more flexible than its `v0` counterpart. It tries
to allow to deploy and configure the Agent in a feature matrix:

| Mechanism | Prometheus Metrics | Loki Logs | Traces | Integrations |
| Mechanism | Prometheus Metrics | Logs | Traces | Integrations |
| ---------------- | ------------------ | --------- | ------ | ------------ |
| DaemonSet | Yes | Yes | Yes | Yes |
| Deployment | Yes | No | No | No |
Expand Down Expand Up @@ -50,13 +50,13 @@ example, you may not deploy a scraping service with Loki logs collection.
- `scrapeInstanceKubernetes`: Default Prometheus instance config to scrape from
Kubernetes.

## Configure Loki
## Configure Logs

- `withLokiConfig(config)`: Creates a Loki config block to pass to the Agent.
- `newLokiClient(client_config)`: Creates a new client configuration to pass
to `withLokiClients`.
- `withLokiClients(clients)`: Add a set of clients to a Loki config block.
- `scrapeKubernetesLogs`: Default Loki config that collects logs from Kubernetes
- `withLogsConfig(config)`: Creates a Logs config block to pass to the Agent.
- `newLogsClient(client_config)`: Creates a new client configuration to pass
to `withLogsClients`.
- `withLogsClients(clients)`: Add a set of clients to a Logs config block.
- `scrapeKubernetesLogs`: Default Logs config that collects logs from Kubernetes
pods.

## Configure Traces
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,24 @@ local k = import 'ksonnet-util/kausal.libsonnet';
local container = k.core.v1.container;

{
// withLokiConfig adds a Loki config to collect logs.
// Deprecated methods, aliases to the new names
withLokiConfig(config):: $.withLogsConfig(config),
newLokiClient(client_config):: $.newLogsClient(client_config),
withLokiClients(clients):: $.withLogsClients(clients),

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm going to remove these since the tanka lib isn't widely used (or stable)


// withLogsConfig adds a Logs config to collect logs.
//
// For the full list of options, refer to the configuration reference:
// https://github.com/grafana/agent/blob/main/docs/configuration-reference.md#loki_config
withLokiConfig(config):: {
// https://grafana.com/docs/agent/latest/configuration/logs-config/
withLogsConfig(config):: {
assert std.objectHasAll(self, '_mode') : |||
withLokiConfig must be merged with the result of calling new.
withLogsConfig must be merged with the result of calling new.
|||,
_loki_config:: config,
_logs_config:: config,
},

// newLokiClient creates a new client object. Results from this can be passed into
// withLokiClients.
// newLogsClient creates a new client object. Results from this can be passed into
// withLogsClients.
//
// client_config should be an object of the following shape:
//
Expand All @@ -27,7 +32,7 @@ local container = k.core.v1.container;
// password: '', // OPTIONAL password for Loki API connection
// external_labels: {}, // OPTIONAL labels to set for connection
// }
newLokiClient(client_config)::
newLogsClient(client_config)::
{
url: (
if std.objectHasAll(client_config, 'username') then
Expand All @@ -41,27 +46,27 @@ local container = k.core.v1.container;
else {}
),

// withLokiClients adds clients to send logs to. At least one client must be
// present. Clients can be created by calling newLokiClient or by creating
// withLogsClients adds clients to send logs to. At least one client must be
// present. Clients can be created by calling newLogsClient or by creating
// an object that conforms to the Promtail client_config schema specified
// here:
//
// https://grafana.com/docs/loki/latest/clients/promtail/configuration/#client_config
//
// withLokiClients should be merged with the result of withLokiConfig.
withLokiClients(clients):: {
assert std.objectHasAll(self, '_loki_config') : |||
withLokiClients must be merged with the result of calling withLokiConfig.
// withLogsClients should be merged with the result of withLogsConfig.
withLogsClients(clients):: {
assert std.objectHasAll(self, '_logs_config') : |||
withLogsClients must be merged with the result of calling withLogsConfig.
|||,

_loki_config+:: {
_logs_config+:: {
clients: if std.isArray(clients) then clients else [clients],
},
},

// lokiPermissionsMixin mutates the container and deployment to work with
// logsPermissionsMixin mutates the container and deployment to work with
// reading Docker container logs.
lokiPermissionsMixin:: {
logsPermissionsMixin:: {
container+::
container.mixin.securityContext.withPrivileged(true) +
container.mixin.securityContext.withRunAsUser(0),
Expand All @@ -76,7 +81,7 @@ local container = k.core.v1.container;
k.util.hostVolumeMount('etcmachineid', '/etc/machine-id', '/etc/machine-id', readOnly=true),
},

// scrapeKubernetesLogs defines a Loki config that can collect logs from
// scrapeKubernetesLogs defines a Logs config that can collect logs from
// Kubernetes pods.
scrapeKubernetesLogs: scrape_k8s_logs.newKubernetesLogsCollector(),
}
18 changes: 9 additions & 9 deletions production/tanka/grafana-agent/v1/main.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ local service = k.core.v1.service;
(import './lib/integrations.libsonnet') +
(import './lib/prometheus.libsonnet') +
(import './lib/scraping_service.libsonnet') +
(import './lib/loki.libsonnet') +
(import './lib/logs.libsonnet') +
(import './lib/traces.libsonnet') +
{
_images:: {
Expand All @@ -24,7 +24,7 @@ local service = k.core.v1.service;
// function with one or more of the following:
//
// - withPrometheusConfig, withPrometheusInstances (and optionally withRemoteWrite)
// - withLokiConfig
// - withLogsConfig
//
// When using withPrometheusInstances, a [name]-etc deployment
// with one replica will be created alongside the DaemonSet. This deployment
Expand All @@ -44,7 +44,7 @@ local service = k.core.v1.service;
_images:: $._images,
_config_hash:: true,

local has_loki_config = std.objectHasAll(self, '_loki_config'),
local has_logs_config = std.objectHasAll(self, '_logs_config'),
local has_trace_config = std.objectHasAll(self, '_trace_config'),
local has_prometheus_config = std.objectHasAll(self, '_prometheus_config'),
local has_prometheus_instances = std.objectHasAll(self, '_prometheus_instances'),
Expand All @@ -66,10 +66,10 @@ local service = k.core.v1.service;
then { prometheus: this._prometheus_config { configs: host_filter_instances } }
else {}
) + (
if has_loki_config then {
loki: {
if has_logs_config then {
logs: {
positions_directory: '/tmp/positions',
configs: [this._loki_config {
configs: [this._logs_config {
name: 'default',
}],
},
Expand All @@ -88,12 +88,12 @@ local service = k.core.v1.service;
),

etc_config:: if has_prometheus_config then this.config {
// Hide loki and integrations from our extra configs, we just want the
// Hide logs and integrations from our extra configs, we just want the
// scrape configs that wouldn't work for the DaemonSet.
prometheus+: {
configs: std.map(function(cfg) cfg { host_filter: false }, etc_instances),
},
loki:: {},
logs:: {},
traces:: {},
integrations:: {},
},
Expand All @@ -117,7 +117,7 @@ local service = k.core.v1.service;
then k.util.serviceFor(self.agent) + service.mixin.metadata.withNamespace(namespace)
else {},
} + (
if has_loki_config then $.lokiPermissionsMixin else {}
if has_logs_config then $.logsPermissionsMixin else {}
) + (
if has_integrations && std.objectHas(this._integrations, 'node_exporter') then $.integrationsMixin else {}
),
Expand Down