Loki.write generates a page not found 505 error -- it's not Loki, it's me

I like Grafana so much, I’m trying to migrate my homelab from Graylog to Alloy/Loki. I installed Alloy and Loki on the same VM (not in Docker) using the latest versions available. Grafana is running on a different VM. I am not using SSL or authentication. Alloy looks like it is processing the test syslog feed correctly, and I can access Loki from Grafana (set up data source and “save and test” is successful). Unfortunately, my Loki.write is generating an 404 page not found error and the syslog data is not being written to Loki. I’ve been through the docs and googled for a solution, but I can’t figure it out. I would appreciate someone pointing me in the right direction.

Loki config.yaml

auth_enabled: false

server:
  http_listen_port: 3100
  grpc_listen_port: 9096
  log_level: debug
  grpc_server_max_concurrent_streams: 1000

common:
  instance_addr: 127.0.0.1
  path_prefix: /tmp/loki
  storage:
    filesystem:
      chunks_directory: /tmp/loki/chunks
      rules_directory: /tmp/loki/rules
  replication_factor: 1
  ring:
    kvstore:
      store: inmemory

ingester_rf1:
  enabled: false

query_range:
  results_cache:
    cache:
      embedded_cache:
        enabled: true
        max_size_mb: 100

schema_config:
  configs:
    - from: 2020-10-24
      store: tsdb
      object_store: filesystem
      schema: v13
      index:
        prefix: index_
        period: 24h

pattern_ingester:
  enabled: true
  metric_aggregation:
    enabled: true
    loki_address: localhost:3100

ruler:
  alertmanager_url: http://localhost:9093

frontend:
  encoding: protobuf

type or paste code here

Alloy alloy.config

loki.source.syslog "opnFilterLog" {
  listener {
    address  = "0.0.0.0:1520"
    labels = {component = "opnFilterLog"}
  }

  forward_to = [loki.write.local.receiver]
}

loki.write "local" {
  endpoint {
    url = "http://localhost:3100/api/v1/push"
  }
}

Alloy error log (repeats every couple of seconds)

Oct 16 21:17:46 Loki alloy[16791]: ts=2024-10-16T21:17:46.772337162Z level=error msg="final error sending batch" component_path=/ component_id=loki.write.local component=client host=localhost:3100 status=404 tenant="" error="server returned HTTP status 404 Not Found (404): 404 page not found"

Try http://localhost:3100/loki/api/v1/push as URL.

Also you should perform both read and write API calls to your Loki cluster to make sure it’s actually working. You can find examples here: Loki HTTP API | Grafana Loki documentation

Thank you! I used http://localhost:3100/loki/api/v1/push as the URL and it is working correctly. I can’t believe I was using the wrong URL.