Skip to content

portNumber field in Prometheus Operator PodMonitor CRD is ignored #3949

Open
@benediktwerner

Description

@benediktwerner

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


Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions