Open
Description
What's wrong?
The Prometheus Operator PodMonitor CRD (or rather the PodMetricsEndpoint CRD therein) has a portNumber field to allow setting the port number of the metrics endpoint to scrape: https://prometheus-operator.dev/docs/api-reference/api/#monitoring.coreos.com/v1.PodMetricsEndpoint
Alloy seems to ignore this configuration and only recognizes port
(which can only reference named ports) and the deprecated targetPort
(which can be used instead of portNumber
but is deprecated):
Probably because portNumber
is somewhat new.
Steps to reproduce
Have a pod with two ports, e.g. 8080 and 9091, where 9091 should be used for metrics.
Create a PodMonitor resource something like this:
apiVersion: monitoring.coreos.com/v1
kind: PodMonitor
metadata:
name: my-metrics
namespace: default
spec:
podMetricsEndpoints:
- path: /metrics
portNumber: 9091
Observe that Alloy tries to scrape metrics via port 8080.
System information
No response
Software version
Grafana Alloy 1.7.4
Configuration
Logs