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 all 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
2 changes: 1 addition & 1 deletion docs/api/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ URL-encoded names are stored in decoded form. e.g., `hello%2Fworld` will
represent the config named `hello/world`.

The request body passed to this endpoint must match the format of
[prometheus_instance_config]({{< relref "../configuration/prometheus-config" >}})
[metrics_instance_config]({{< relref "../configuration/metrics-config" >}})
defined in the Configuration Reference. The name field of the configuration is
ignored and the name in the URL takes precedence. The request body must be
formatted as YAML.
Expand Down
12 changes: 7 additions & 5 deletions docs/configuration/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ weight = 300

The Grafana Agent is configured in a YAML file (usually called
`agent.yaml`) which contains information on the Grafana Agent and its
Prometheus instances.
metrics instances.

- [server_config]({{< relref "./server-config" >}})
- [prometheus_config]({{< relref "./prometheus-config" >}})
- [metrics_config]({{< relref "./metrics-config" >}})
- [logs_config]({{< relref "./logs-config.md" >}})
- [traces_config]({{< relref "./traces-config" >}})
- [integrations_config]({{< relref "./integrations/_index.md" >}})
Expand Down Expand Up @@ -100,14 +100,16 @@ Support contents and default values of `agent.yaml`:
# Configures the server of the Agent used to enable self-scraping.
[server: <server_config>]

# Configures Prometheus instances.
[prometheus: <prometheus_config>]
# Configures metric collection.
# In previous versions of the agent, this field was called "prometheus".
[prometheus: <metrics_config>]

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

# Configures Traces trace collection.
# In previous versions of the agent, this field was called "tempo".
[traces: <traces_config>]

# Configures integrations for the Agent.
Expand Down
12 changes: 6 additions & 6 deletions docs/configuration/integrations/mongodb_exporter-config.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ The second one is mongodb_cluster, which is the name of your mongodb cluster, an
Here`s an example:

```yaml
relabel_configs:
relabel_configs:
- source_labels: [__address__]
target_label: service_name
replacement: 'replicaset1-node1'
replacement: 'replicaset1-node1'
- source_labels: [__address__]
target_label: mongodb_cluster
replacement: 'prod-cluster'
replacement: 'prod-cluster'
```

Besides that, there's not much to configure. Please refer to the full reference of options:
Expand All @@ -37,11 +37,11 @@ Besides that, there's not much to configure. Please refer to the full reference
[scrape_integration: <boolean> | default = <integrations_config.scrape_integrations>]

# How often should the metrics be collected? Defaults to
# prometheus.global.scrape_interval.
# metrics.global.scrape_interval.
[scrape_interval: <duration> | default = <global_config.scrape_interval>]

# The timeout before considering the scrape a failure. Defaults to
# prometheus.global.scrape_timeout.
# metrics.global.scrape_timeout.
[scrape_timeout: <duration> | default = <global_config.scrape_timeout>]

# Allows for relabeling labels on the target.
Expand All @@ -65,4 +65,4 @@ Besides that, there's not much to configure. Please refer to the full reference

# MongoDB node connection URL, which must be in the [`Standard Connection String Format`](https://docs.mongodb.com/manual/reference/connection-string/#std-label-connections-standard-connection-string-format)
[mongodb_uri: <string>]
```
```
20 changes: 10 additions & 10 deletions docs/configuration/logs-config.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
+++
title = "loki_config"
title = "logs_config"
weight = 300
aliases = ["/docs/agent/latest/configuration/loki-config/"]
+++

# loki_config
# logs_config

The `loki_config` block configures how the Agent collects logs and sends them to
a Loki push API endpoint. `loki_config` is identical to how Promtail is
The `logs_config` block configures how the Agent collects logs and sends them to
a Loki push API endpoint. `logs_config` is identical to how Promtail is
configured, except deprecated fields have been removed and the server_config is
not supported.

Expand All @@ -19,7 +19,7 @@ for the supported values for these fields.
# Directory to store Loki Promtail positions files in. Positions files are
# required to read logs, and are used to store the last read offset of log
# sources. The positions files will be stored in
# <positions_directory>/<loki_instance_config.name>.yml.
# <positions_directory>/<logs_instance_config.name>.yml.
#
# Optional only if every config has a positions.filename manually provided.
#
Expand All @@ -28,19 +28,19 @@ for the supported values for these fields.

# Loki Promtail instances to run for log collection.
configs:
- [<loki_instance_config>]
- [<logs_instance_config>]
```

## loki_instance_config
## logs_instance_config

The `loki_instance_config` block is an individual instance of Promtail with its
The `logs_instance_config` block is an individual instance of Promtail with its
own set of scrape rules and where to forward logs. It is identical to how
Promtail is configured, except deprecated fields have been removed and the
`server_config` block is not supported.

```yaml
# Name of this config. Required, and must be unique across all Loki configs.
# The name of the config will be the value of a loki_config label for all
# The name of the config will be the value of a logs_config label for all
# Loki Promtail metrics.
name: <string>

Expand All @@ -49,7 +49,7 @@ clients:

# Optional configuration for where to store the positions files. If
# positions.filename is left empty, the file will be stored in
# <loki_config.positions_directory>/<loki_instance_config.name>.yml.
# <logs_config.positions_directory>/<logs_instance_config.name>.yml.
#
# The directory of the positions file will automatically be created on start up
# if it doesn't already exist..
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
+++
title = "prometheus_config"
title = "metrics_config"
weight = 200
aliases = ["/docs/agent/latest/configuration/prometheus-config/"]
+++

# prometheus_config
# metrics_config

The `prometheus_config` block is used to define a collection of Prometheus
Instances, each of which is its own mini-Agent. Most users will only need to
The `metrics_config` block is used to define a collection of metrics
instances. Each instance defines a collection of Prometheus-compatible
scrape_configs and remote_write rules. Most users will only need to
define one instance.

```yaml
Expand Down Expand Up @@ -37,7 +39,7 @@ define one instance.

# The list of Prometheus instances to launch with the agent.
configs:
[- <prometheus_instance_config>]
[- <metrics_instance_config>]

# If an instance crashes abnormally, how long should we wait before trying
# to restart it. 0s disables the backoff period and restarts the agent
Expand Down Expand Up @@ -68,7 +70,7 @@ agents distribute discovery and scrape load between nodes.
# events are not sent by an agent.
[reshard_interval: <duration> | default = "1m"]

# The timeout for configuration refreshes. This can occur on cluster events or
# The timeout for configuration refreshes. This can occur on cluster events or
# on the reshard interval. A timeout of 0 indicates no timeout.
[reshard_timeout: <duration> | default = "30s"]

Expand Down Expand Up @@ -248,10 +250,11 @@ remote_write:

> **Note:** For more informaton on remote_write, refer to the [Prometheus documentation](https://prometheus.io/docs/prometheus/2.27/configuration/configuration/#remote_write)

## prometheus_instance_config
## metrics_instance_config

The `prometheus_instance_config` block configures an individual Prometheus
instance, which acts as its own mini Prometheus agent.
The `metrics_instance_config` block configures an individual metrics
instance, which acts as its own mini Prometheus-compatible agent, though
without support for the TSDB.

```yaml
# Name of the instance. Must be present. Will be added as a label to agent
Expand Down
2 changes: 1 addition & 1 deletion docs/operation-guide/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ from that `remote_write` config separated by a `-`.
The shared instances mode is the new default, and the previous behavior is
deprecated. If you wish to restore the old behavior, set `instance_mode:
distinct` in the
[`prometheus_config`]({{< relref "../configuration/prometheus-config" >}}) block of
[`metrics_config`]({{< relref "../configuration/metrics-config" >}}) block of
your config file.

Shared instances are completely transparent to the user with the exception of
Expand Down
10 changes: 5 additions & 5 deletions example/k3d/environment/main.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ local images = {

grafana_agent.new('grafana-agent', 'default') +
grafana_agent.withImages(images) +
grafana_agent.withPrometheusConfig({
grafana_agent.withMetricsConfig({
wal_directory: '/var/lib/agent/data',
global: {
scrape_interval: '15s',
Expand All @@ -49,7 +49,7 @@ local images = {
},
},
}) +
grafana_agent.withPrometheusInstances(grafana_agent.scrapeInstanceKubernetes {
grafana_agent.withMetricsInstances(grafana_agent.scrapeInstanceKubernetes {
// We want our cluster and label to remain static for this deployment, so
// if they are overwritten by a metric we will change them to the values
// set by external_labels.
Expand All @@ -63,8 +63,8 @@ local images = {
grafana_agent.withRemoteWrite([{
url: 'http://cortex.default.svc.cluster.local/api/prom/push',
}]) +
grafana_agent.withLokiConfig(loki_config) +
grafana_agent.withLokiClients(grafana_agent.newLokiClient({
grafana_agent.withLogsConfig(loki_config) +
grafana_agent.withLogsClients(grafana_agent.newLogsClient({
scheme: 'http',
hostname: 'loki.default.svc.cluster.local',
external_labels: { cluster: cluster_label },
Expand Down Expand Up @@ -136,7 +136,7 @@ local images = {

local cluster_label = 'k3d-agent/cluster',
agent_config+: {
prometheus+: {
metrics+: {
global+: {
external_labels+: {
cluster: cluster_label,
Expand Down
18 changes: 9 additions & 9 deletions pkg/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
// when parsing the config.
func TestConfig_FlagDefaults(t *testing.T) {
cfg := `
prometheus:
metrics:
wal_directory: /tmp/wal
global:
scrape_timeout: 33s`
Expand All @@ -38,7 +38,7 @@ prometheus:

func TestConfig_OverrideDefaultsOnLoad(t *testing.T) {
cfg := `
prometheus:
metrics:
wal_directory: /tmp/wal
global:
scrape_timeout: 33s`
Expand All @@ -60,7 +60,7 @@ prometheus:

func TestConfig_OverrideByEnvironmentOnLoad(t *testing.T) {
cfg := `
prometheus:
metrics:
wal_directory: /tmp/wal
global:
scrape_timeout: ${SCRAPE_TIMEOUT}`
Expand All @@ -83,7 +83,7 @@ prometheus:

func TestConfig_OverrideByEnvironmentOnLoad_NoDigits(t *testing.T) {
cfg := `
prometheus:
metrics:
wal_directory: /tmp/wal
global:
external_labels:
Expand All @@ -100,14 +100,14 @@ prometheus:

func TestConfig_FlagsAreAccepted(t *testing.T) {
cfg := `
prometheus:
metrics:
global:
scrape_timeout: 33s`

fs := flag.NewFlagSet("test", flag.ExitOnError)
args := []string{
"-config.file", "test",
"-prometheus.wal-directory", "/tmp/wal",
"-metrics.wal-directory", "/tmp/wal",
"-config.expand-env",
}

Expand All @@ -121,7 +121,7 @@ prometheus:
func TestConfig_StrictYamlParsing(t *testing.T) {
t.Run("duplicate key", func(t *testing.T) {
cfg := `
prometheus:
metrics:
wal_directory: /tmp/wal
global:
scrape_timeout: 10s
Expand All @@ -133,7 +133,7 @@ prometheus:

t.Run("non existing key", func(t *testing.T) {
cfg := `
prometheus:
metrics:
wal_directory: /tmp/wal
global:
scrape_timeout: 10s`
Expand Down Expand Up @@ -232,7 +232,7 @@ func TestConfig_PrometheusNonNil(t *testing.T) {
},
{
name: "null",
input: `prometheus: null`,
input: `metrics: null`,
},
}

Expand Down
1 change: 1 addition & 0 deletions pkg/metrics/cluster/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ func (c *Config) UnmarshalYAML(unmarshal func(interface{}) error) error {
// RegisterFlags registers flags to the provided flag set.
func (c *Config) RegisterFlags(f *flag.FlagSet) {
c.RegisterFlagsWithPrefix("prometheus.", f)
c.RegisterFlagsWithPrefix("metrics.", f)
}

// RegisterFlagsWithPrefix registers flags to the provided flag set with the
Expand Down
6 changes: 3 additions & 3 deletions pkg/operator/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func TestBuildConfigMetrics(t *testing.T) {
http_listen_port: 8080
log_level: debug

prometheus:
metrics:
wal_directory: /var/lib/grafana-agent/data
global:
scrape_interval: 15s
Expand Down Expand Up @@ -101,7 +101,7 @@ func TestBuildConfigMetrics(t *testing.T) {
http_listen_port: 8080
log_level: debug

prometheus:
metrics:
wal_directory: /var/lib/grafana-agent/data
global:
scrape_interval: 15s
Expand Down Expand Up @@ -190,7 +190,7 @@ func TestAdditionalScrapeConfigsMetrics(t *testing.T) {
server:
http_listen_port: 8080

prometheus:
metrics:
wal_directory: /var/lib/grafana-agent/data
global:
external_labels:
Expand Down
6 changes: 3 additions & 3 deletions pkg/operator/config/templates/agent-metrics.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
local marshal = import 'ext/marshal.libsonnet';
local optionals = import 'ext/optionals.libsonnet';

local new_prometheus_instance = import './prometheus.libsonnet';
local new_metrics_instance = import './metrics.libsonnet';
local new_external_labels = import 'component/metrics/external_labels.libsonnet';
local new_remote_write = import 'component/metrics/remote_write.libsonnet';

Expand All @@ -35,7 +35,7 @@ function(ctx) marshal.YAML(optionals.trim({
log_format: optionals.string(spec.LogFormat),
},

prometheus: {
metrics: {
wal_directory: '/var/lib/grafana-agent/data',
global: {
external_labels: optionals.object(new_external_labels(ctx)),
Expand All @@ -47,7 +47,7 @@ function(ctx) marshal.YAML(optionals.trim({
)),
},
configs: optionals.array(std.map(
function(inst) new_prometheus_instance(
function(inst) new_metrics_instance(
agentNamespace=ctx.Agent.ObjectMeta.Namespace,
instance=inst,
apiServer=spec.APIServerConfig,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ local new_probe = import 'component/metrics/probe.libsonnet';
local new_remote_write = import 'component/metrics/remote_write.libsonnet';
local new_service_monitor = import 'component/metrics/service_monitor.libsonnet';

// Generates a prometheus_instance.
// Generates a metrics_instance.
//
// @param {string} agentNamespace - namespace of the GrafanaAgent
// @param {MetricsInstance} instance
Expand Down
4 changes: 2 additions & 2 deletions pkg/traces/contextkeys/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ const (
// Logs is used to pass *logs.Logs through the context
Logs key = iota

// Prometheus is used to pass instance.Manager through the context
Prometheus
// Metrics is used to pass instance.Manager through the context
Metrics
)
Loading