Search code examples
google-compute-engineprometheus

Prometheus communication error with GCE service


I've installed a new prometheus v2.42.0 on debian server. My current prometheus version is 2.24.1. I've used same prometheus yml into new installation. Everything works fine except GCE configuration. I've added current credential into $HOME/.config/gcloud/application_default_credentials.json

  - job_name: cloud
    honor_labels: true
    gce_sd_configs:
       - project: 'dynamic-mystery-xxxxx'
         port: 80
         zone: 'us-west1-b'
         filter: '(status="RUNNING")'
         refresh_interval: 5s
    relabel_configs:
      - source_labels: ['__meta_gce_public_ip']
        regex: (.*)
        replacement: '${1}:80'
        target_label: '__address__'
      - source_labels: ['__meta_gce_instance_name']
        target_label: 'name'

In my newly installed prometheus log I see the following error, I see this error

caller=manager.go:317 level=error component="discovery manager scrape" msg="Cannot create service discovery" err="error setting up communication with GCE service: google>

Do you have any ideas? Thank you.


Solution

  • I got this error because it couldn't find the credential location. It worked with the credential under the root user in the old version, so that's what I set in the new version. But I tried putting the credential in the home directory of prometheus itself and it worked! Under /var/lib/prometheus in Debian. ( /var/lib/promethus/.config/gcloud/application_default_credentials.json )