Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ServiceMonitor (for prometheus operator) #11

Open
leogr opened this issue Oct 22, 2019 · 1 comment
Open

ServiceMonitor (for prometheus operator) #11

leogr opened this issue Oct 22, 2019 · 1 comment
Assignees
Labels
enhancement New feature or request question Further information is requested
Milestone

Comments

@leogr
Copy link
Contributor

leogr commented Oct 22, 2019

In order to make kube-notary discovered by the prometheus operator:

  • the endpoint resource needs the following label:
  labels:
    k8s-app: kube-notary
  • the ServiceMonitor resource has to be created, as following:
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
  name: kube-notary
spec:
  endpoints:
  - interval: 15s
    port: metrics-port
  selector:
    matchLabels:
      k8s-app: kube-notary

asciicast

TODOs:

  • the required label could be set in the default setup
  • this configuration should be added to the repo
@leogr leogr added enhancement New feature or request question Further information is requested labels Oct 22, 2019
@leogr leogr self-assigned this Oct 22, 2019
@leogr leogr added this to the v0.3.0 milestone Oct 22, 2019
@dzlabsch
Copy link

I solved that differently by adding an additional Scrape Config to Prometheus operator.

create config file


- job_name: 'kubernetes-pods'
kubernetes_sd_configs:
- role: pod
relabel_configs:
- source_labels: [__meta_kubernetes_pod_annotation_prometheus_io_scrape]
action: keep
regex: true
- source_labels: [__meta_kubernetes_pod_annotation_prometheus_io_path]
action: replace
target_label: __metrics_path__
regex: (.+)
- source_labels: [__address__, __meta_kubernetes_pod_annotation_prometheus_io_port]
action: replace
regex: ([^:]+)(?::\d+)?;(\d+)
replacement: $1:$2
target_label: __address__
- action: labelmap
regex: __meta_kubernetes_pod_label_(.+)
- source_labels: [__meta_kubernetes_namespace]
action: replace
target_label: kubernetes_namespace
- source_labels: [__meta_kubernetes_pod_name]
action: replace
target_label: kubernetes_pod_name

create a secret

kubectl create secret generic additional-scrape-configs --from-file=prometheus-additional.yaml --dry-run -oyaml > additional-scrape-configs.yaml

apply the config to the namespace prometheus operator is running

kubectl apply -f additional-scrape-configs.yaml --namespace=monitoring

edit the runtime

kubectl edit Prometheus kube-prometheus --namespace=monitoring

under spec

spec:
additionalScrapeConfigs:
key: prometheus-additional.yaml
name: additional-scrape-configs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants