<p>I have a k8s service that is behind a load balancer and exposes a <code>/metrics</code> endpoint. However, these metrics are identical for each pod, so there is no need to collect them from each pod - rather, any pod can provide the data. Currently, this results in the same metrics being emitted with only the pod dimension changing.</p>
<p>What would be the idiomatic way to handle this? My first thought was to create a pseudo-endpoint that points to the service and collect from that, but this seems overly complicated.</p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: v1

kind: Service

metadata:
  name: {{ .Values.name }}-service
  annotations:
    service.beta.kubernetes.io/aws-load-balancer-internal: &quot;true&quot;
    prometheus.io/scrape: &quot;true&quot;
    prometheus.io/path: /metrics
    prometheus.io/port: &quot;80&quot;
  labels:
    app: {{ .Values.name }}-service

spec:
  ports:
    - name: http
      port: 80
      protocol: TCP
  type: LoadBalancer
  selector:
    app: {{ .Values.name }}-service-pod

</code></pre>

<p>Firstly, let me say that is not neccesarily the case that every pod will return the same metrics; pods might return stats on their CPU utilisation, individual jobqueues, a whole load of pod-specific stuff. If this is your own product and they currently don't; they might in the future. It's certainly useful to be able to use your metrics to spot issues in the running of a workload in kubernetes, i.e. monitor the individual pods.</p>
<p>Idiomatically, monitoring all pods is the way to go.</p>
