google-cloud-platformprometheusprometheus-node-exporter

How to configure Prometheus to scrape new CE on GCP?


I am trying to configure a Prometheus instance on a compute engine on GCP to scrape metrics from several compute engine instances. About that, everything should be standard but how should I configure Prometheus to individuate automatically new Compute Engines instances? For the moment I am not using K8s.

For instance: I have 2 nginx instances monitored with Prometheus. If I add a new nginx instance I would like to have new metrics on Prometheus automatically.

Thanks


Solution

  • I don't know if this will solves your problem.

    I have node exporter installed on all my instances and the automatic discovery service configured for it. On top of that, a few instances have their own app_exporter that publishes app specific metrics on another port (9854).

    What I did:
    I added an extra GCP discovery scraper job for that port:

      scrape_configs:
        # Dynamic GCP service discovery for extra app-metrics
        - job_name: 'gcp_solr_discovery'
          metrics_path: "/admin/metrics"
          gce_sd_configs:
             # Europe West 1
           - project: "your-project-here"
             zone: "europe-west1-b"
             port: 9854
           - project: "your-project-here"
             zone: "europe-west1-c"
             port: 9854
    

    This will make the GCP service discovery query those ports regardless if the VMs have node exporter or not and your instances will be added dynamically.