0

I have a Prometheus Server Configuration and it looks like this...

(Actually a snippet of it)

scrape_configs:

        - job_name: 'kubernetes-services-endpoints' 
          scrape_interval: 5s 

          action: keep 
          regex: true 
          source_labels: [__meta_kubernetes_service_annotation_prometheus_io_scrape]

          # Microservices Metrics Jobs Goes There....
        - job_name: 'customers-registered-prometheus-job'
          scrape_interval: 5s
          static_configs:
            - targets: ["store-service.store-namespace.svc:8000"]

          metrics_path: /metrics 
          scheme: http 
          scrape_timeout: 10s 

        - job_name: 'customers-online-prometheus-job' 
          scrape_interval: 5s 
          static_configs:
            - targets: ["store-service.store-namespace.svc:8000"]

          metrics_path: /metrics 
          scheme: http 
          scrape_timeout: 10s 

So when I run it with Kubernetes it cannot find Some Fields for Some Reason But When I see other People running the familiar configuration everything works fine...

line 10: field action not found in type config.ScrapeConfig\n 

 line 11: field regex not found in type config.ScrapeConfig\n

  line 12: field source_labels not found in type

 config.ScrapeConfig\n  line 25: field scrape_internal not found in type 

config.ScrapeConfig\n  line 81: field scrape_internal not found in type 

config.ScrapeConfig\n  line 111: field scrape_internal not found in type config.ScrapeConfig"


What can cause following output? Am I need to specify some extra fields?

CraZyCoDer
  • 367
  • 1
  • 2
  • 16
  • `But When I see other People running the familiar configuration everything works fine...` Could you share an example? – tkausl Jul 24 '22 at 18:52
  • link to another stack overflow issue with similar config https://stackoverflow.com/questions/52167869/scrape-interval-and-evaluation-interval-in-prometheus – CraZyCoDer Jul 24 '22 at 18:55
  • The configuration in the other question has _none_ of those erroneous fields in the `scrape_configs` section. – tkausl Jul 24 '22 at 18:58
  • Okay, if just throw away fields like `action`, `regex`, `source_labels` (which has been picked up from there https://fabianlee.org/2022/07/08/prometheus-monitoring-services-using-additional-scrape-config-for-prometheus-operator/, why does it triggers for fields like `scrape_interval`? If it does set up correctly – CraZyCoDer Jul 24 '22 at 19:02
  • Because you wrote `scrape_internal`, not `scrape_interval`. – tkausl Jul 24 '22 at 19:09
  • Oh, thanks, haven't noticed it :) – CraZyCoDer Jul 24 '22 at 19:44

1 Answers1

1

This:

- action: keep 
  regex: true 
  source_labels: [__meta_kubernetes_service_annotation_prometheus_io_scrape]

should be under either relabel_configs: or metric_relabel_configs: (https://prometheus.io/docs/prometheus/latest/configuration/configuration/#relabel_config). And it only works with Kubernetes service discovery (that job has nothing at all).

anemyte
  • 17,618
  • 1
  • 24
  • 45