<p>I have several nodejs microservices which are running dev namespace which I expose metrics and able to access via <a href="http://localhost:9187/metrics" rel="nofollow noreferrer">http://localhost:9187/metrics</a>.</p>

<p>But when I deploy prometheus server which is running monitoring namespace I received an below error in Targets page.</p>

<blockquote>
  <p><strong>Get <a href="http://1.../metrics" rel="nofollow noreferrer">http://1.../metrics</a>: context deadline exceeded</strong>.</p>
</blockquote>

<p>I assume none of these allow access from the namespace monitoring
so need to add an additional one into the namespace dev to allow the prometheus pod from namespace monitoring to scrape the below pod or what might be the reason of this error?</p>

<p>What is the best way to add netpol to my application to allow prometheus from namespace monitoring?</p>

<hr>

<p><strong>kubectl get netpol -n dev</strong></p>

<pre><code>myapp-api-dev       app.kubernetes.io/instance=myapp-api-dev,app.kubernetes.io/name=oneapihub-api           5h33m
myapp-auth-dev      app.kubernetes.io/instance=myapp-auth-dev,app.kubernetes.io/name=oneapihub-auth         56m
myapp-backend-dev   app.kubernetes.io/instance=myapp-backend-dev,app.kubernetes.io/name=oneapihub-backend   5h42m
redis               app=redis,release=redis                                                                     33d
</code></pre>

<p><strong>kubectl get pods -n monitoring</strong></p>

<pre><code>NAME                                            READY   STATUS    RESTARTS   AGE
monitoring-prometheus-server-6cc796c4db-hp4rg   2/2     Running   0          2d4h
</code></pre>

semural
<p>I guess you have kube-prometheus installed. In this case you need to create custom roles and role bindings to let Prometheus to monitor other namespaces, see <a href="https://github.com/coreos/kube-prometheus/blob/master/docs/monitoring-other-namespaces.md" rel="nofollow noreferrer">here</a></p>
