
apiVersion: monitoring.coreos.com/v1kind: ServiceMonitormetadata:labels:app.kubernetes.io/name: kube-state-metricsapp.kubernetes.io/version: 1.9.7name: kube-state-metricsnamespace: kube-systemspec:endpoints:- bearerTokenSecret:key: ""interval: 15s # It indicates the collection frequency. You can increase it to reduce the data storage costs. For example, set it to `300s` for less important metrics, which can reduce the amount of monitoring data collected by 20 times.port: http-metricsscrapeTimeout: 15s # It indicates the collection timeout period. TMP configuration requires that this value does not exceed the collection interval, i.e., `scrapeTimeout` <= `interval`.jobLabel: app.kubernetes.io/namenamespaceSelector: {}selector:matchLabels:app.kubernetes.io/name: kube-state-metrics
kube_node_info and kube_node_role metrics, you need to add the metricRelabelings field to the endpoint list of the ServiceMonitor. Note that it is metricRelabelings but not relabelings.
Sample for adding metricRelabelings:apiVersion: monitoring.coreos.com/v1kind: ServiceMonitormetadata:labels:app.kubernetes.io/name: kube-state-metricsapp.kubernetes.io/version: 1.9.7name: kube-state-metricsnamespace: kube-systemspec:endpoints:- bearerTokenSecret:key: ""interval: 15s # It indicates the collection frequency. You can increase it to reduce the data storage costs. For example, set it to `300s` for less important metrics, which can reduce the amount of monitoring data collected by 20 times.port: http-metricsscrapeTimeout: 15s# The following four lines are added:metricRelabelings: # Each collected item is subject to the following processing.- sourceLabels: ["__name__"] # The name of the label to be detected. `__name__` indicates the name of the metric or any label that comes with the item.regex: kube_node_info|kube_node_role # Whether the above label satisfies this regex. Here, `__name__` should satisfy the requirements of `kube_node_info` or `kube_node_role`.action: keep # Keep the item if it meets the above conditions, or drop it otherwise.jobLabel: app.kubernetes.io/namenamespaceSelector: {}selector:
scrape_configs:- job_name: job1scrape_interval: 15s # It indicates the collection frequency. You can increase it to reduce the data storage costs. For example, set it to `300s` for less important metrics, which can reduce the amount of monitoring data collected by 20 times.static_configs:- targets:- '1.1.1.1'
kube_node_info and kube_node_role metrics, add the metric_relabel_configs field. Note that it is metric_relabel_configs but not relabel_configs.
Sample for adding metric_relabel_configs:scrape_configs:- job_name: job1scrape_interval: 15s # It indicates the collection frequency. You can increase it to reduce the data storage costs. For example, set it to `300s` for less important metrics, which can reduce the amount of monitoring data collected by 20 times.static_configs:- targets:- '1.1.1.1'# The following four lines are added:metric_relabel_configs: # Each collected item is subject to the following processing.- source_labels: ["__name__"] # The name of the label to be detected. `__name__` indicates the name of the metric or any label that comes with the item.regex: kube_node_info|kube_node_role # Whether the above label satisfies this regex. Here, `__name__` should satisfy the requirements of `kube_node_info` or `kube_node_role`.action: keep # Keep the item if it meets the above conditions, or drop it otherwise.
tps-skip-monitor: "true" as instructed in Labels and Selectors.tps-skip-monitor: "true" to these CRD resources as instructed in Labels and Selectors.Feedback