Validation Failed for /etc/alloy/config.alloy Configuration File

cat /etc/alloy/config.alloy
# OTLP Receiver (receives logs from Faro SDK)
otelcol.receiver.otlp "react" {
  http {
    endpoint = "0.0.0.0:4318"
  }

  output {
    logs = [otelcol.exporter.loki.react_loki]
  }
}

# Batch Processor (optional)
otelcol.processor.batch "batch_logs" {
  output {
    logs = [otelcol.exporter.loki.react_loki]
  }
}

# Loki Exporter
otelcol.exporter.loki "react_loki" {
  forward_to = [loki.write.react]
}

# Loki Write
loki.write "react" {
  endpoint {
    url = "http://localhost:3100/loki/api/v1/push"
  }

  labels = {
    job         = "react"
    environment = "production"
    service     = "reactapp"
    cluster     = "dev-cluster"
  }
}
# alloy --version
alloy, version v1.10.1 (branch: HEAD, revision: 73262fc)
  build user:       root@21497d4c2e53
  build date:       2025-08-07T09:09:32Z
  go version:       go1.24.4
  platform:         linux/amd64
  tags:             netgo,builtinassets,promtail_journal_enabled
#
alloy validate /etc/alloy/config.alloy
Error: /etc/alloy/config.alloy:1:1: illegal character U+0023 '#'

1 | # OTLP Receiver (receives logs from Faro SDK)
  | ^
2 | otelcol.receiver.otlp "react" {

Error: /etc/alloy/config.alloy:1:1: expected identifier, got ILLEGAL

1 | # OTLP Receiver (receives logs from Faro SDK)
  | ^
2 | otelcol.receiver.otlp "react" {

Error: /etc/alloy/config.alloy:12:1: illegal character U+0023 '#'

11 |
12 | # Batch Processor (optional)
   | ^
13 | otelcol.processor.batch "batch_logs" {

Error: /etc/alloy/config.alloy:12:1: expected identifier, got ILLEGAL

11 |
12 | # Batch Processor (optional)
   | ^
13 | otelcol.processor.batch "batch_logs" {

Error: /etc/alloy/config.alloy:19:1: illegal character U+0023 '#'

18 |
19 | # Loki Exporter
   | ^
20 | otelcol.exporter.loki "react_loki" {

Error: /etc/alloy/config.alloy:19:1: expected identifier, got ILLEGAL

18 |
19 | # Loki Exporter
   | ^
20 | otelcol.exporter.loki "react_loki" {

Error: /etc/alloy/config.alloy:24:1: illegal character U+0023 '#'

23 |
24 | # Loki Write
   | ^
25 | loki.write "react" {

Error: /etc/alloy/config.alloy:24:1: expected identifier, got ILLEGAL

23 |
24 | # Loki Write
   | ^
25 | loki.write "react" {

Error: /etc/alloy/config.alloy:31:26: missing ',' in field list

30 |   labels = {
31 |     job         = "react"
   |
32 |     environment = "production"

Error: /etc/alloy/config.alloy:32:31: missing ',' in field list

31 |     job         = "react"
32 |     environment = "production"
   |
33 |     service     = "reactapp"

Error: /etc/alloy/config.alloy:33:29: missing ',' in field list

32 |     environment = "production"
33 |     service     = "reactapp"
   |
34 |     cluster     = "dev-cluster"

Error: /etc/alloy/config.alloy:34:32: missing ',' in field list

33 |     service     = "reactapp"
34 |     cluster     = "dev-cluster"
   |
35 |   }

Error: validation failed

I am configuring this flow → React APP logs / exceptions → Faro SDK → Alloy OTLP → Loki → Grafana

Please guide me. Thanks in advance.

Best regards,

Kaushal

Hello @kaushalshriyan,

After reviewing the issue, I believe I have identified the root cause. Below are the recommended steps that may help resolve it:

Step 1: Please follow the official Alloy configuration guide available here: