grafana / loki

Like Prometheus, but for logs.
https://grafana.com/loki
GNU Affero General Public License v3.0
23.79k stars 3.43k forks source link

Default Loki ServiceMonitor is trying to scrape gateways non-existent /metrics endpoint #13201

Open den-is opened 4 months ago

den-is commented 4 months ago

Describe the bug Default Loki's ServiceMonitor is making Prometheus to scrape loki-gateway's non-existent /metrics endpoint

To Reproduce Steps to reproduce the behavior:

  1. Install stand loki installation deploymentMode: SimpleScalable, with gateway enabled
  2. Install simple kube-prometheus-stack
  3. Check ServiceMonitor for loki
  4. Check Prometheus targets for loki - there will be

Expected behavior No red/down targets in prometheus.
No 404 errors in loki-gateway logs.
Ignore loki-gateway in ServiceMonitor or fix /metrics endpoint for loki-gateway.

Environment:

Screenshots, Promtail config, or terminal output

<

404 Not Found

404 Not Found


nginx/1.24.0
strowi commented 4 months ago

Ran into the same problem...

The serviceMonitor scrapes all "http-metrics"-ports and the gateway has mistakenly (?) been namend the same instead of {{ include "loki.gatewayFullname" . }} (can't speak to the enterprise-version though).

I fixed it here

den-is commented 4 months ago

@strowi thanks! I am not 100% sure that this is exactly authentic fix for my exact issue. Just my IMHO. I don't like when ports are not names after generic protocol names. (http, grpc, etc with whatever prefixes/suffixes)

But it 100% fits the original port name issue https://github.com/grafana/loki/issues/12963 and probably your naming strategy can be discussed there.

strowi commented 4 months ago

@den-is totally agree! And i didn't know about the original issue. I just had to quick-fix it in out deployment and used a the service-name/var from the ingress-definition ;)

Skaronator commented 4 months ago

I created an PR to fix this. As a temporary workaround you could just set these label on the service:

gateway:
  service:
    labels:
      prometheus.io/service-monitor: "false"
TimJongerius commented 1 week ago

We've just upgraded to the latest Loki version (was a pain by the way). The default service monitor still tries to scrape metrics from the non existent metrics endpoint of the gateway.

Can you please provide the endpoint or update the servicemonitor?

This issue is open since Jun 12. What is keeping you from fixing it?