Skip to content

Instantly share code, notes, and snippets.

@f41gh7
Last active August 21, 2023 10:31
Show Gist options
  • Save f41gh7/1fed801c5e288e8a6bdbd931ae0f74fd to your computer and use it in GitHub Desktop.
Save f41gh7/1fed801c5e288e8a6bdbd931ae0f74fd to your computer and use it in GitHub Desktop.
vm operator configuration examples
apiVersion: operator.victoriametrics.com/v1beta1
kind: VMServiceScrape
metadata:
name: apiserver
namespace: monitoring-system
spec:
endpoints:
- bearerTokenFile: /var/run/secrets/kubernetes.io/serviceaccount/token
bearerTokenSecret:
key: ""
port: https
scheme: https
tlsConfig:
ca: {}
caFile: /var/run/secrets/kubernetes.io/serviceaccount/ca.crt
cert: {}
serverName: kubernetes
jobLabel: component
namespaceSelector:
matchNames:
- default
selector:
matchLabels:
component: apiserver
provider: kubernetes
apiVersion: operator.victoriametrics.com/v1beta1
kind: VMNodeScrape
metadata:
name: cadvisor
namespace: monitoring-system
spec:
scheme: "https"
interval: "30s"
scrapeTimeout: "5s"
selector: {}
tlsConfig:
insecureSkipVerify: true
caFile: "/var/run/secrets/kubernetes.io/serviceaccount/ca.crt"
bearerTokenFile: "/var/run/secrets/kubernetes.io/serviceaccount/token"
relabelConfigs:
- action: labelmap
regex: __meta_kubernetes_node_label_(.+)
- targetLabel: __address__
replacement: kubernetes.default.svc:443
- sourceLabels: [__meta_kubernetes_node_name]
regex: (.+)
targetLabel: __metrics_path__
replacement: /api/v1/nodes/$1/proxy/metrics/cadvisor
- targetLabel: "job"
replacement: "cadvisor"
apiVersion: operator.victoriametrics.com/v1beta1
kind: VMServiceScrape
metadata:
name: kube-state-metrics
namespace: monitoring-system
spec:
endpoints:
- bearerTokenSecret:
key: ""
honorLabels: true
port: http
jobLabel: app.kubernetes.io/name
namespaceSelector: {}
selector:
matchLabels:
app.kubernetes.io/instance: kube-state-metrics
app.kubernetes.io/name: kube-state-metrics
apiVersion: operator.victoriametrics.com/v1beta1
kind: VMNodeScrape
metadata:
name: kubelet
namespace: monitoring-system
spec:
scheme: "https"
interval: "30s"
scrapeTimeout: "5s"
selector: {}
tlsConfig:
insecureSkipVerify: true
caFile: "/var/run/secrets/kubernetes.io/serviceaccount/ca.crt"
bearerTokenFile: "/var/run/secrets/kubernetes.io/serviceaccount/token"
relabelConfigs:
- action: labelmap
regex: __meta_kubernetes_node_label_(.+)
- targetLabel: __address__
replacement: kubernetes.default.svc:443
- sourceLabels: [__meta_kubernetes_node_name]
regex: (.+)
targetLabel: __metrics_path__
replacement: /api/v1/nodes/$1/proxy/metrics
- targetLabel: "job"
replacement: "kubelet"
apiVersion: operator.victoriametrics.com/v1beta1
kind: VMServiceScrape
metadata:
name: services
namespace: monitoring-system
spec:
discoveryRole: "endpoints"
jobLabel: "app.kubernetes.io/name"
endpoints:
- port: metrics
relabelConfigs:
- sourceLabels:
[__meta_kubernetes_service_annotation_prometheus_io_scrape]
action: keep
regex: "true"
- sourceLabels:
[__meta_kubernetes_service_annotation_prometheus_io_scheme]
action: replace
targetLabel: __scheme__
regex: (https?)
- sourceLabels:
[__meta_kubernetes_service_annotation_prometheus_io_path]
action: replace
targetLabel: __metrics_path__
regex: (.+)
- sourceLabels:
[
__address__,
__meta_kubernetes_service_annotation_prometheus_io_port,
]
action: replace
targetLabel: __address__
regex: ([^:]+)(?::\d+)?;(\d+)
replacement: $1:$2
namespaceSelector:
any: true
selector: {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment