Cannot see json logs when using alloy to forward logs to Loki

I am new to Grafana Loki and Alloy and I want to get logs from disk to Loki using Alloy. (And possibly create traces from logs if possible.)

I have json logs on this format:
{“@timestamp”:“2025-03-27T10:49:50.975150682+01:00”,“@version”:“1”,“message”:“Received Temp = 0.0°C, Humidity = 0.0%”,“logger_name”:“com.home.ClimateController”,“thread_name”:“pool-3-thread-4”,“level”:“INFO”,“level_value”:20000,“trace_id”:“390c7258c294f9451ce2e7c030c34a2a”,“trace_flags”:“01”,“span_id”:“dd5a4e0331d48324”}
{“@timestamp”:“2025-03-27T10:49:50.983169077+01:00”,“@version”:“1”,“message”:“Temp changed by -0.0°C → 26.48°C”,“logger_name”:“com.home.ClimateController”,“thread_name”:“pool-3-thread-4”,“level”:“INFO”,“level_value”:20000,“trace_id”:“390c7258c294f9451ce2e7c030c34a2a”,“trace_flags”:“01”,“span_id”:“bc541a4adb9c2496”}

And have alloy running with this config:

local.file_match “applogs” {
path_targets = [{ path = “/home/test/dev/SmartHome/logs/*.json” }]
}

loki.source.file “local_files” {
targets = local.file_match.applogs.targets
forward_to = [loki.write.local_loki.receiver]
}

loki.write “local_loki” {
endpoint {
url = “http://localhost:3100/loki/api/v1/push
}
}

Loki has the following config:

auth_enabled: false

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

common:
ring:
instance_addr: 127.0.0.1
kvstore:
store: inmemory
replication_factor: 1
path_prefix: /tmp/loki

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

limits_config:
metric_aggregation_enabled: true

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

storage_config:
filesystem:
directory: /tmp/loki/chunks

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

ruler:
alertmanager_url: http://localhost:9093

frontend:
encoding: protobuf

I cannot see any logs in Grafana Loki. Not sure where I am going wrong. Is there need for any mapping of labels or other?

Also is it possible to visualize traces/spans only through the logs and how can that be done if so?

This is most likely wrong unless you are running Loki and Alloy on the same host.

Check your logs on both Alloy and Loki. Check connectivity. Make sure Loki is functional with an API call.

Thank you for the answer, it was nothing wrong with the endpoint but there was a root permission issue.