Grafana Agent Operator creating wrong config?

I’m using the Grafana Agent Operator, installed via helm chart (chart version 0.2.8).

I successfully created a GrafanaAgent via CRD. It is using the image grafana/agent:v0.30.2 as given in the example in the documentation.

Now I’m trying to create an agent with an Integration CRD.

Here is my CRD

apiVersion: monitoring.grafana.com/v1alpha1
kind: Integration
metadata:
  name: app-agent-receiver
  namespace: grafana-agent-operator
  labels:
    agent: grafana-agent-integrations
spec:
  name: agent
  type:
    unique: true
    allNodes: false
  config:
    instance: "app-agent-receiver"
    server:
      cors_allowed_origins:
        - http://localhost:3000
      rate_limiting:
        enabled: true

This indeed creates an integration deployment. This is the configuration that is created by the operator:

/ # cat /var/lib/grafana-agent/config/agent.yml
integrations:
    agent_configs:
        - instance: app-agent-receiver
          server:
            cors_allowed_origins:
                - http://localhost:3000
            rate_limiting:
                enabled: true
    metrics:
        autoscrape:
            enable: false
logs:
    positions_directory: /var/lib/grafana-agent/data
metrics:
    global:
        external_labels:
            cluster: grafana-agent-operator/grafana-agent
    wal_directory: /var/lib/grafana-agent/data
server:
    log_level: info

But the agent won’t start, all it says is the error message

2023/01/18 09:48:47 error loading config file /var/lib/grafana-agent/config/agent.yml: yaml: unmarshal errors:
  line 2: field server not found in type agent.Config

What puzzles me is line 2 of the agent.yml (“agent_configs”). My understanding is that the operator is already using integrations-next, so according to this documentation line 2 should be “agent:”

Or is there anything I did wrong in the Integrations CRD?

OK, found my error. Somehow I mixed up “app_agent_receiver” and “agent”.

Changing my CRD to

spec:
  name: app_agent_receiver

fixed it.

1 Like