The "hosted logs" page generates wrong Loki push API token?

  • What Grafana version and what operating system are you using?

Grafana Cloud

  • What are you trying to achieve?

Ship logs from OpenWRT to Grafana Cloud loki instance

  • How are you trying to achieve it?

Following the instructions for logs under my instance, I tried to follow the “Generate Now” button and the pop-up window to generate an API token to be used by openwrt-loki-exporter to push logs from OpenWRT to Grafana Cloud Loki (it’s a shell script which uses curl to achieve that)

  • What happened?

The pop-up window offers to generate a token with many read access but not the necessary write access:

With this token, the script failed to push logs to Loki, generating the following errors:

curl: (22) The requested URL returned error: 401
POST FAILED: '{"streams": [{"stream": {"job": "openwrt_loki_exporter", "host": "OpenWrt"}, "values": [["1744528214519000000", "daemon.info dnsmasq-dhcp[1]: DHCPACK ..."]]}]}'

I found the list of tokens of my instance under the Access Policies tab and changed the permissions on this token to contain ONLY logs:write (I removed all the previous scopes)

After that, the script started posting the logs successfully and I could see them in a query of Loki.

I’m writing here to suggest that the automatic token generation button be updated to include the logs:write only. It would save time and confusion from future users.

  • What did you expect to happen?

The script should be able to push logs to the Grafana Cloud Loki instance using this token.

  • Can you copy/paste the configuration(s) that you are having problems with?

  • Did you receive any errors in the Grafana UI or in related logs? If so, please tell us exactly what they were.

  • Did you follow any online instructions? If so, what is the URL?