<p>I configure all of the following configurations but the request_per_second does not appear when I type the command</p>
<blockquote>
<p>kubectl get --raw /apis/custom.metrics.k8s.io/v1beta1</p>
</blockquote>
<p>In the node.js that should be monitored I installed prom-client, I tested the /metrics and it's working very well and the metric &quot;resquest_count&quot; is the object it returns</p>
<p>Here are the important parts of that node code</p>
<pre><code>(...)
const counter = new client.Counter({
  name: 'request_count',
  help: 'The total number of processed requests'
});
(...)

router.get('/metrics', async (req, res) =&gt; {
  res.set('Content-Type', client.register.contentType)
  res.end(await client.register.metrics())
})
</code></pre>
<p>This is my service monitor configuration</p>
<pre><code>apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
  name: un1qnx-validation-service-monitor-node
  namespace: default
  labels:
    app: node-request-persistence
    release: prometheus
spec:
  selector:
    matchLabels:
      app: node-request-persistence
  endpoints:
  - interval: 5s
    path: /metrics
    port: &quot;80&quot;
    bearerTokenFile: /var/run/secrets/kubernetes.io/serviceaccount/token
  namespaceSelector:
    matchNames:
    - un1qnx-aks-development
</code></pre>
<p>This the node-request-persistence configuration</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: node-request-persistence
  namespace: un1qnx-aks-development
  name: node-request-persistence
spec:
  selector:
    matchLabels:
      app: node-request-persistence
  template:
    metadata:
      annotations:
        prometheus.io/scrape: &quot;true&quot;
        prometheus.io/path: /metrics
        prometheus.io/port: &quot;80&quot;
      labels:
        app: node-request-persistence
    spec:
      containers:
      - name: node-request-persistence
        image: node-request-persistence
        imagePullPolicy: Always # IfNotPresent
        resources:
          requests:
            memory: &quot;200Mi&quot; # Gi
            cpu: &quot;100m&quot;
          limits:
            memory: &quot;400Mi&quot;
            cpu: &quot;500m&quot;
        ports:
        - name: node-port
          containerPort: 80
</code></pre>
<p>This is the prometheus adapter</p>
<pre><code>prometheus:
  url: http://prometheus-server.default.svc.cluster.local
  port: 9090
rules:
  custom:
  - seriesQuery: 'request_count{namespace!=&quot;&quot;, pod!=&quot;&quot;}'
    resources:
      overrides:
        namespace: {resource: &quot;namespace&quot;}
        pod: {resource: &quot;pod&quot;}
    name:
      as: &quot;request_per_second&quot;
    metricsQuery: &quot;round(avg(rate(&lt;&lt;.Series&gt;&gt;{&lt;&lt;.LabelMatchers&gt;&gt;}[1m])) by (&lt;&lt;.GroupBy&gt;&gt;))&quot;
</code></pre>
<p>This is the hpa</p>
<pre><code>apiVersion: autoscaling/v2beta2
kind: HorizontalPodAutoscaler
metadata:
  name: un1qnx-validation-service-hpa-angle
  namespace: un1qnx-aks-development
spec:
  minReplicas: 1
  maxReplicas: 10
  scaleTargetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: un1qnx-validation-service-angle
  metrics:
  - type: Pods
    pods:
      metric:
        name: request_per_second
      target:
        type: AverageValue
        averageValue: &quot;5&quot;
</code></pre>
<p>The command</p>
<blockquote>
<p>kubectl get hpa -n un1qnx-aks-development</p>
</blockquote>
<p>results in &quot;unknown/5&quot;</p>
<p>Also, the command</p>
<blockquote>
<p>kubectl get --raw &quot;http://prometheus-server.default.svc.cluster.local:9090/api/v1/series&quot;</p>
</blockquote>
<p>Results in</p>
<blockquote>
<p>Error from server (NotFound): the server could not find the requested resource</p>
</blockquote>
<p>I think it should return some value about the collected metrics... I think that the problem is from the service monitor, but I am new to this</p>
<p>As you noticed I am trying to scale a deployment based on another deployment pods, don't know if there is a problem there</p>
<p>I appreciate an answer, because this is for my thesis</p>
<p>kubernetes - version 1.19.9</p>
<p>Prometheus - chart prometheus-14.2.1       app version 2.26.0</p>
<p>Prometheus Adapter - chart 2.14.2       app version 0.8.4</p>
<p>And all where installed using helm</p>

BragaMann
<p>After some time I found the problems and I changed the following</p>
<p>Changed the port on the prometheus adapter, the time on the query and the names of the resource override. But to know the names of the resources override you need to port forward to the prometheus server and check the labels on the targets page of the app that you are monitoring.</p>
<pre><code>prometheus:
  url: http://prometheus-server.default.svc.cluster.local
  port: 80
rules:
  custom:
  - seriesQuery: 'request_count{kubernetes_namespace!=&quot;&quot;, kubernetes_pod_name!=&quot;&quot;}'
    resources:
      overrides:
        kubernetes_namespace: {resource: &quot;namespace&quot;}
        kubernetes_pod_name: {resource: &quot;pod&quot;}
    name:
      matches: &quot;request_count&quot;
      as: &quot;request_count&quot;
    metricsQuery: &quot;round(avg(rate(&lt;&lt;.Series&gt;&gt;{&lt;&lt;.LabelMatchers&gt;&gt;}[5m])) by (&lt;&lt;.GroupBy&gt;&gt;))&quot;
</code></pre>
<p>I also added annotations on the deployment yaml</p>
<pre><code>spec:
  selector:
    matchLabels:
      app: node-request-persistence
  template:
    metadata:
      annotations:
        prometheus.io/scrape: &quot;true&quot;
        prometheus.io/path: /metrics
        prometheus.io/port: &quot;80&quot;
      labels:
</code></pre>
