Dabz / ccloudexporter

Prometheus exporter for Confluent Cloud API metric
https://docs.confluent.io/current/cloud/metrics-api.html
87 stars 53 forks source link

403 when using latest image #60

Closed giladsh1 closed 3 years ago

giladsh1 commented 3 years ago

Hello,

I've followed the exact instructions for both docker and Go.

getting the following error message, even through the API key is valid:

{
   "Endpoint": "https://api.telemetry.confluent.cloud/v1/metrics/cloud/descriptors",
   "StatusCode": 403,
   "body": "eyJlcnJvciI6eyJjb2RlIjo0MDMsIm1lc3NhZ2UiOiJpbnZhbGlkIEFQSSBrZXkifX0K",
   "level": "fatal",
   "msg": "Received status code 403 instead of 200 for GET on https://api.telemetry.confluent.cloud/v1/metrics/cloud/descriptors. \n\n{\"error\":{\"code\":403,\"message\":\"invalid API key\"}}\n\n\n",
   "time": "2021-01-14T00:20:31Z"
 }

would appreciate any help with this

Dabz commented 3 years ago

Hi @giladsh1! The error message is quite explanatory, the API/Secret key set seems to be invalid.

To validate your API Key/Secret, can you do http -v "https://api.telemetry.confluent.cloud/v1/metrics/cloud/descriptors" --auth "$CCLOUD_API_KEY:$CCLOUD_API_SECRET" (or you can write an equivalent with curl ^^)

I tried locally, it seems to be working properly. As well, is your API Key linked to a Service Account or a user? You must use a Cloud API Key to communicate with the Metrics API. Using the Cluster API Key that is used to communicate with Kafka will result in an authentication error.

ccloud login
ccloud kafka cluster use lkc-XXXXX
ccloud api-key create --resource cloud
Dabz commented 3 years ago

Any news @giladsh1? Can I close this issue?

giladsh1 commented 3 years ago

hey @Dabz thank you very much for your swift reply and sorry for the late answer!

No real issue here - my bad. I was using an API key scoped to the cluster (ccloud api-key create --resource <lkc-XXXXX>) where I should have used an API key coped to the cloud with the --resource cloud flag.

This flag is shown in the instructions in your README file - however it didn't work for me at first try, since I had an old version of the ccloud CLI tool which didn't support it.

thanks again!