How to setup Fly log shipper with Loki on Grafana Cloud

I’m trying to ship my logs to Loki on Grafana Cloud and I’ve set appropriate secrets however when the app is deployed I get :point_down:

 2022-06-30T22:04:40.625 app[c0ae4e53] lhr [info] 2022-06-30T22:04:40.625077Z ERROR sink{component_kind="sink" component_id=loki component_type=loki component_name=loki}:request{request_id=377}: vector_core::stream::driver: Service call failed. error=ServerError { code: 401 } request_id=377 

I am not sure whether I am using the incorrect fields but this is how I set

LOKI_URL
LOKI_USERNAME
LOKI_PASSWORD

╰─$ fly secrets list
Update available 0.0.337 -> v0.0.344.
Run "fly version update" to upgrade.
NAME          DIGEST                           DATE
ACCESS_TOKEN  02d262b881dfd9a06676f01481f35e8e 41m47s ago
LOKI_PASSWORD 99e3ec3204758aa99b9232b9e79d0559 40m15s ago
LOKI_URL      3fb20236273198f381409943f86fd19a 41m2s ago
LOKI_USERNAME 0acc83719e674bd9f8ccbf5d9f7abfbf 40m36s ago
ORG           71f177c46a124b665934bca6f0149a02 42m32s ago

Could you please help me understand what’s wrong?

Okay, LOKI_PASSWORD should be the API key generated as described here.

Role should be at least MetricsPublisher.

After that it just worked.