<p>Heyo,</p>
<p>I've deployed a prometheus, grafana, kube-state-metrics, alertmanager, etc. setup using kubernetes in GKE v1.16.x. I've used <a href="https://github.com/do-community/doks-monitoring" rel="nofollow noreferrer">https://github.com/do-community/doks-monitoring</a> as a jumping off point for the yaml files.</p>
<p>I've been trying to debug a situation for a few days now and would be very grateful for some help. My prometheus nodes are not getting metrics from cadvisor.</p>
<ul>
<li>All the services and pods in the deployments are running. prometheus, kube-state-metrics, node-exporter, all running - no errors.</li>
<li>The cadvisor targets in prometheus UI appear as &quot;up&quot;.</li>
<li>Prometheus is able to collect other metrics from the cluster, but no pod/container level usage metrics.</li>
<li>I can see cadvisor metrics when I query <code>kubectl get --raw &quot;/api/v1/nodes/&lt;your_node&gt;/proxy/metrics/cadvisor&quot;</code>, but when I look in prometheus for <code>container_cpu_usage</code> or <code>container_memory_usage</code>, there is no data.</li>
<li>My cadvisor scrape job config in prometheus</li>
</ul>
<pre><code>    - job_name: kubernetes-cadvisor
      honor_timestamps: true
      scrape_interval: 15s
      scrape_timeout: 10s
      metrics_path: /metrics/cadvisor
      scheme: https
      bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
      tls_config:
        ca_file: /var/run/secrets/kubernetes.io/serviceaccount/ca.crt
        insecure_skip_verify: true
      kubernetes_sd_configs:
      - role: node
      relabel_configs:
        - action: labelmap
          regex: __meta_kubernetes_node_label_(.+)
</code></pre>
<p>cribbed from the prometheus/docs/examples.</p>
<p>I've tried a whole bunch of different variations on paths and scrape configs, but no luck. Based on the fact that I can query the metrics using <code>kubectl get</code> (they exist) it seems to me the issue is prometheus communicating with the cadvisor target.</p>
<p>If anyone has experience getting this configured I'd sure appreciate some help debugging.</p>
<p>Cheers</p>

user1797466
<p>I was able to dig up a blog that had an example configuration that worked for me. The GKE endpoint for cadvisor (and kubelet) metrics, is different than the standard ones that are found in documentation examples. Here's an excerpt from my working prometheus jobs:</p>
<pre><code>    - job_name: kubernetes-cadvisor
      honor_timestamps: true
      scrape_interval: 15s
      scrape_timeout: 10s
      metrics_path: /metrics/cadvisor
      scheme: https
      bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
      tls_config:
        ca_file: /var/run/secrets/kubernetes.io/serviceaccount/ca.crt
        insecure_skip_verify: true
      kubernetes_sd_configs:
      - role: node
      relabel_configs:
        - action: labelmap
          regex: __meta_kubernetes_node_label_(.+)
        - target_label: __address__
          replacement: kubernetes.default.svc.cluster.local:443
        - source_labels: [__meta_kubernetes_node_name]
          regex: (.+)
          target_label: __metrics_path__
          replacement: /api/v1/nodes/${1}/proxy/metrics/cadvisor
    - job_name: kubernetes-kubelet
      honor_timestamps: true
      scrape_interval: 15s
      scrape_timeout: 10s
      metrics_path: /metrics
      scheme: https
      bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
      tls_config:
        ca_file: /var/run/secrets/kubernetes.io/serviceaccount/ca.crt
        insecure_skip_verify: true
      kubernetes_sd_configs:
      - role: node
      relabel_configs:
      - action: labelmap
        regex: __meta_kubernetes_node_label_(.+)
      - target_label: __address__
        replacement: kubernetes.default.svc.cluster.local:443
      - target_label: __metrics_path__
        source_labels: [__meta_kubernetes_node_name]
        regex: (.+)
        replacement: /api/v1/nodes/${1}/proxy/metrics
</code></pre>
<p>Edit: here's a link to the blog post -&gt; <a href="https://medium.com/htc-research-engineering-blog/monitoring-kubernetes-clusters-with-grafana-e2a413febefd" rel="nofollow noreferrer">https://medium.com/htc-research-engineering-blog/monitoring-kubernetes-clusters-with-grafana-e2a413febefd</a>.</p>
