2

I have cloned and started the

https://computingforgeeks.com/setup-prometheus-and-grafana-on-kubernetes/

kube-prometheus project on my local. I want to add additional scrap config to retrieve custom metrics from another source. I found

https://github.com/prometheus-operator/prometheus-operator/blob/main/Documentation/additional-scrape-config.md

but I cannot change the prometheus.yaml in the pods. I could not find where to change. Can anyone help me get this additional scraper configured in the kube-prometheus project?

I could not find where to add additional scraper as mentioned in the URL above:

Finally, reference this additional configuration in your prometheus.yaml CRD.

apiVersion: monitoring.coreos.com/v1 kind: Prometheus metadata: name: prometheus labels: prometheus: prometheus spec: replicas: 2 serviceAccountName: prometheus serviceMonitorSelector: matchLabels: team: frontend additionalScrapeConfigs: name: additional-scrape-configs key: prometheus-additional.yaml enter code here

The CRDs I found in the kube-prometheus project all have the informational descriptions but do not take a value. How can I add my additionalScrapeConfigs?

Thanks.

Emrah

2 Answers2

2

There are also ScrapeConfig custom resources.

For example:

apiVersion: monitoring.coreos.com/v1alpha1
kind: ScrapeConfig
metadata:
  name: test
  namespace: prometheus
spec:
  metricsPath: /metrics
  staticConfigs:
  - labels:
      foo: bar
    targets:
    - some.host.internal

Just make sure to pay attention to scrapeConfigSelector and scrapeConfigNamespaceSelector parameters to make sure that the ScrapeConfigs you create are picked up by prometheus-operator.

0x416e746f6e
  • 121
  • 4
0

I guess you may can see kubernetes secret which name is '...-prometheus-scrape-confg'. additional-scrape-configs uses this secret for setting target configs.

When you install the prometheus using 'helm install ...', you may use values.yaml in helm-charts/charts/kube-prometheus-stack/. additionalScrapeConfigs can be set in this file. check 'prometheus.prometheusSpec.additionalScrapeConfigs' in values.yaml file.

So, if you add any target addresses to additionalScrapeConfigs in values.yaml, it will be created as secret and prometheus uses it to make prometheus.yaml file. If you want to check, put some target addresses to additionalScrapeConfigs and execute 'helm upgrade ...' or 'helm install ... ' again.