Grafana agent config.river errors

Im trying to get grafana agent in flow to collect from local endpoint
agent ui works ok localhost:12345
metrics are visible at localhost:1235/actuator/prometheus

ts=2023-11-30T10:39:19.831915338Z level=info “boringcrypto enabled”=false
ts=2023-11-30T10:39:19.832332284Z level=info msg=“starting complete graph evaluation” controller_id=“” trace_id=4e99a6232be4b0b10ae995687556a012

ts=2023-11-30T10:39:24.848534831Z level=error msg=“Creating target failed” component=prometheus.scrape.api scrape_pool=prometheus.scrape.api err=“"localhost:1235/actuator/prometheus" is not a valid hostname\ninstance 0 in group prometheus.scrape.api\\n\t/go/pkg/mod/\*scrapePool).Sync\n\t/go/pkg/mod/\*Manager).reload.func1\n\t/go/pkg/mod/\nruntime.goexit\n\t/usr/local/go/src/runtime/asm_amd64.s:1650”

cat config.river
prometheus.remote_write “default” {
endpoint {
url = “

// Get basic authentication based on environment variables.
basic_auth {
  username = env("111111")
  password = env("xxxxxx")


prometheus.scrape “api” {
// Collect metrics from Grafana Agent’s default listen address.
targets = [{
address = “localhost:1235/actuator/prometheus”,
“app” = “api”,
“env” = “dev”,
forward_to = [prometheus.remote_write.default.receiver]

agent.yaml is not required if using config.river ?
**using config genarator used below but getting errors **

module.git “grafana_cloud” {
** repository = “GitHub - grafana/agent-modules: A repository of public agent modules”**
** path = “modules/grafana-cloud/autoconfigure/module.river”**
** revision = “main”**
** pull_frequency = “0s”**
** arguments {**
** stack_name = “11111”**
** token = env(“GRAFANA_CLOUD_TOKEN”)**
** }**
prometheus.scrape “static” {
** forward_to = [**
** module.git.grafana_cloud.exports.metrics_receiver,**
** ]**
** targets = [**
** {**
** “address” = “localhost:1235/actuator/prometheus”,**
** “app” = “api”,**
** “env” = “dev”**
** }**
** ]**

ts=2023-11-30T09:10:05.121595901Z level=info msg=“finished complete graph evaluation” controller_id=“” trace_id=8da826d6c15e6c085dcaa86e85060e96 duration=1.069815994s
Error: module.git.grafana_cloud:36:1: Failed to build component: building component: unexpected status code 401 Unauthorized

Error: module.git.grafana_cloud:74:14: json_decode unexpected end of JSON input

Error: module.git.grafana_cloud:80:16: json_decode unexpected end of JSON input

Error: module.git.grafana_cloud:88:11: json_decode unexpected end of JSON input

Error: module.git.grafana_cloud:28:1: Failed to evaluate node for config block: decoding River: module.git.grafana_cloud:29:11: json_decode unexpected end of JSON input

Error: module.git.grafana_cloud:63:11: json_decode unexpected end of JSON input

Error: module.git.grafana_cloud:51:11: json_decode unexpected end of JSON input
ts=2023-11-30T09:10:05.12169305Z level=error msg=“failed to start reporter” err=“context canceled”
interrupt received
Error: could not perform the initial load successfully

In case anyone else is trying to figure this out, the error “json_decode unexpected end of JSON input” is likely because your GRAFANA_CLOUD_TOKEN does not have read permissions on the stack. You can fix this by editing the access policy for the token and adding stacks:read.