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

[Kubernetes] Expand condition support to remaining inputs #7395

Merged
merged 12 commits into from
Nov 10, 2023

Conversation

BenB196
Copy link
Contributor

@BenB196 BenB196 commented Aug 16, 2023

What does this PR do?

Enhancement - This change expands the ability to set condition to the remaining inputs within the Kubernetes integration.

The main driving factor behind this change is to allow for creating more dynamic Elastic Agent policies which can be used to monitor multiple different Kubernetes setups (ex: different distro's - RKE2, EKS, AKS, etc...; different IP schemas - IPv4 vs IPv6) from a single Elastic Agent policy that contains conditionally defined Kubernetes integration inputs.

Checklist

  • I have reviewed tips for building integrations and this pull request is aligned with them.
  • I have verified that all data streams collect metrics or logs.
  • I have added an entry to my package's changelog.yml file.
  • I have verified that Kibana version constraints are current according to guidelines.

Author's Checklist

  • All condition fields added are hidden/advanced, they're targeted at more edge-case needs I believe, so I don't think it makes sense to show them
  • For the Kubelet API metrics I opted to do a top-level condition field
    • I don't realistically see a need to be able to see condition on each metric input individually
  • For the kube-state-metrics I opted to do a top-level condition field
    • I don't realistically see a need to be able to see condition on each metric input individually
  • For Kubernetes API Server, Proxy, Scheduler and controller-manager the main goal behind the condition field here is to be able to support host values that need to target either IPv4 or IPv6 (host values in IPv6 need to be wrapped in [] when also specifying a port)
  • For Kubernetes audit logs the main goal behind the condition field is to be able to support different Kubernetes distro's where their audit log location is different

How to test this PR locally

  1. Upgrade to the latest version
  2. Add condition values as needed
  3. Confirm that the condition values are added appropriately

Below are configs which demonstrate that the condition functionality has been tested at a configuration level. I've broken the evidence down by input (group) as this is a somewhat large change.

Kubelet API ---
No `condition` set
inputs:
  - id: kubernetes/metrics-kubelet-b6ebc720-3bc7-11ee-a0fc-f5e8b9d3c066
    name: kubernetes-1
    revision: 1
    type: kubernetes/metrics
    use_output: default
    meta:
      package:
        name: kubernetes
        version: 1.44.5
    data_stream:
      namespace: default
    package_policy_id: b6ebc720-3bc7-11ee-a0fc-f5e8b9d3c066
    streams:
      - id: >-
          kubernetes/metrics-kubernetes.container-b6ebc720-3bc7-11ee-a0fc-f5e8b9d3c066
        data_stream:
          dataset: kubernetes.container
          type: metrics
        metricsets:
          - container
        add_metadata: true
        hosts:
          - 'https://${env.NODE_NAME}:10250'
        period: 10s
        bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
        ssl.verification_mode: none
      - id: >-
          kubernetes/metrics-kubernetes.node-b6ebc720-3bc7-11ee-a0fc-f5e8b9d3c066
        data_stream:
          dataset: kubernetes.node
          type: metrics
        metricsets:
          - node
        add_metadata: true
        hosts:
          - 'https://${env.NODE_NAME}:10250'
        period: 10s
        bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
        ssl.verification_mode: none
      - id: kubernetes/metrics-kubernetes.pod-b6ebc720-3bc7-11ee-a0fc-f5e8b9d3c066
        data_stream:
          dataset: kubernetes.pod
          type: metrics
        metricsets:
          - pod
        add_metadata: true
        hosts:
          - 'https://${env.NODE_NAME}:10250'
        period: 10s
        bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
        ssl.verification_mode: none
      - id: >-
          kubernetes/metrics-kubernetes.system-b6ebc720-3bc7-11ee-a0fc-f5e8b9d3c066
        data_stream:
          dataset: kubernetes.system
          type: metrics
        metricsets:
          - system
        add_metadata: true
        hosts:
          - 'https://${env.NODE_NAME}:10250'
        period: 10s
        bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
        ssl.verification_mode: none
      - id: >-
          kubernetes/metrics-kubernetes.volume-b6ebc720-3bc7-11ee-a0fc-f5e8b9d3c066
        data_stream:
          dataset: kubernetes.volume
          type: metrics
        metricsets:
          - volume
        add_metadata: true
        hosts:
          - 'https://${env.NODE_NAME}:10250'
        period: 10s
        bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
        ssl.verification_mode: none
`condition` set
inputs:
  - id: kubernetes/metrics-kubelet-b6ebc720-3bc7-11ee-a0fc-f5e8b9d3c066
    name: kubernetes-1
    revision: 2
    type: kubernetes/metrics
    use_output: default
    meta:
      package:
        name: kubernetes
        version: 1.44.5
    data_stream:
      namespace: default
    package_policy_id: b6ebc720-3bc7-11ee-a0fc-f5e8b9d3c066
    streams:
      - id: >-
          kubernetes/metrics-kubernetes.container-b6ebc720-3bc7-11ee-a0fc-f5e8b9d3c066
        data_stream:
          dataset: kubernetes.container
          type: metrics
        period: 10s
        condition: '${host.name} == "testing"'
        add_metadata: true
        hosts:
          - 'https://${env.NODE_NAME}:10250'
        ssl.verification_mode: none
        metricsets:
          - container
        bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
      - id: >-
          kubernetes/metrics-kubernetes.node-b6ebc720-3bc7-11ee-a0fc-f5e8b9d3c066
        data_stream:
          dataset: kubernetes.node
          type: metrics
        period: 10s
        condition: '${host.name} == "testing"'
        add_metadata: true
        hosts:
          - 'https://${env.NODE_NAME}:10250'
        ssl.verification_mode: none
        metricsets:
          - node
        bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
      - id: kubernetes/metrics-kubernetes.pod-b6ebc720-3bc7-11ee-a0fc-f5e8b9d3c066
        data_stream:
          dataset: kubernetes.pod
          type: metrics
        period: 10s
        condition: '${host.name} == "testing"'
        add_metadata: true
        hosts:
          - 'https://${env.NODE_NAME}:10250'
        ssl.verification_mode: none
        metricsets:
          - pod
        bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
      - id: >-
          kubernetes/metrics-kubernetes.system-b6ebc720-3bc7-11ee-a0fc-f5e8b9d3c066
        data_stream:
          dataset: kubernetes.system
          type: metrics
        period: 10s
        condition: '${host.name} == "testing"'
        add_metadata: true
        hosts:
          - 'https://${env.NODE_NAME}:10250'
        ssl.verification_mode: none
        metricsets:
          - system
        bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
      - id: >-
          kubernetes/metrics-kubernetes.volume-b6ebc720-3bc7-11ee-a0fc-f5e8b9d3c066
        data_stream:
          dataset: kubernetes.volume
          type: metrics
        period: 10s
        condition: '${host.name} == "testing"'
        add_metadata: true
        hosts:
          - 'https://${env.NODE_NAME}:10250'
        ssl.verification_mode: none
        metricsets:
          - volume
        bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
---
kube-state-metrics ---
No `condition` set, but leader election set
inputs:
  - id: kubernetes/metrics-kube-state-metrics-b6ebc720-3bc7-11ee-a0fc-f5e8b9d3c066
    name: kubernetes-1
    revision: 3
    type: kubernetes/metrics
    use_output: default
    meta:
      package:
        name: kubernetes
        version: 1.44.5
    data_stream:
      namespace: default
    package_policy_id: b6ebc720-3bc7-11ee-a0fc-f5e8b9d3c066
    streams:
      - id: >-
          kubernetes/metrics-kubernetes.state_container-b6ebc720-3bc7-11ee-a0fc-f5e8b9d3c066
        data_stream:
          dataset: kubernetes.state_container
          type: metrics
        period: 10s
        condition: '${kubernetes_leaderelection.leader} == true'
        add_metadata: true
        hosts:
          - 'kube-state-metrics:8080'
        metricsets:
          - state_container
        bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
      - id: >-
          kubernetes/metrics-kubernetes.state_cronjob-b6ebc720-3bc7-11ee-a0fc-f5e8b9d3c066
        data_stream:
          dataset: kubernetes.state_cronjob
          type: metrics
        period: 10s
        condition: '${kubernetes_leaderelection.leader} == true'
        add_metadata: true
        hosts:
          - 'kube-state-metrics:8080'
        metricsets:
          - state_cronjob
        bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
      - id: >-
          kubernetes/metrics-kubernetes.state_daemonset-b6ebc720-3bc7-11ee-a0fc-f5e8b9d3c066
        data_stream:
          dataset: kubernetes.state_daemonset
          type: metrics
        period: 10s
        condition: '${kubernetes_leaderelection.leader} == true'
        add_metadata: true
        hosts:
          - 'kube-state-metrics:8080'
        metricsets:
          - state_daemonset
        bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
      - id: >-
          kubernetes/metrics-kubernetes.state_deployment-b6ebc720-3bc7-11ee-a0fc-f5e8b9d3c066
        data_stream:
          dataset: kubernetes.state_deployment
          type: metrics
        period: 10s
        condition: '${kubernetes_leaderelection.leader} == true'
        add_metadata: true
        hosts:
          - 'kube-state-metrics:8080'
        metricsets:
          - state_deployment
        bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
      - id: >-
          kubernetes/metrics-kubernetes.state_job-b6ebc720-3bc7-11ee-a0fc-f5e8b9d3c066
        data_stream:
          dataset: kubernetes.state_job
          type: metrics
        period: 10s
        condition: '${kubernetes_leaderelection.leader} == true'
        add_metadata: true
        hosts:
          - 'kube-state-metrics:8080'
        metricsets:
          - state_job
        bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
      - id: >-
          kubernetes/metrics-kubernetes.state_node-b6ebc720-3bc7-11ee-a0fc-f5e8b9d3c066
        data_stream:
          dataset: kubernetes.state_node
          type: metrics
        period: 10s
        condition: '${kubernetes_leaderelection.leader} == true'
        add_metadata: true
        hosts:
          - 'kube-state-metrics:8080'
        metricsets:
          - state_node
        bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
      - id: >-
          kubernetes/metrics-kubernetes.state_persistentvolume-b6ebc720-3bc7-11ee-a0fc-f5e8b9d3c066
        data_stream:
          dataset: kubernetes.state_persistentvolume
          type: metrics
        period: 10s
        condition: '${kubernetes_leaderelection.leader} == true'
        add_metadata: true
        hosts:
          - 'kube-state-metrics:8080'
        metricsets:
          - state_persistentvolume
        bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
      - id: >-
          kubernetes/metrics-kubernetes.state_persistentvolumeclaim-b6ebc720-3bc7-11ee-a0fc-f5e8b9d3c066
        data_stream:
          dataset: kubernetes.state_persistentvolumeclaim
          type: metrics
        period: 10s
        condition: '${kubernetes_leaderelection.leader} == true'
        add_metadata: true
        hosts:
          - 'kube-state-metrics:8080'
        metricsets:
          - state_persistentvolumeclaim
        bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
      - id: >-
          kubernetes/metrics-kubernetes.state_pod-b6ebc720-3bc7-11ee-a0fc-f5e8b9d3c066
        data_stream:
          dataset: kubernetes.state_pod
          type: metrics
        period: 10s
        condition: '${kubernetes_leaderelection.leader} == true'
        add_metadata: true
        hosts:
          - 'kube-state-metrics:8080'
        metricsets:
          - state_pod
        bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
      - id: >-
          kubernetes/metrics-kubernetes.state_replicaset-b6ebc720-3bc7-11ee-a0fc-f5e8b9d3c066
        data_stream:
          dataset: kubernetes.state_replicaset
          type: metrics
        period: 10s
        condition: '${kubernetes_leaderelection.leader} == true'
        add_metadata: true
        hosts:
          - 'kube-state-metrics:8080'
        metricsets:
          - state_replicaset
        bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
      - id: >-
          kubernetes/metrics-kubernetes.state_resourcequota-b6ebc720-3bc7-11ee-a0fc-f5e8b9d3c066
        data_stream:
          dataset: kubernetes.state_resourcequota
          type: metrics
        period: 10s
        condition: '${kubernetes_leaderelection.leader} == true'
        add_metadata: true
        hosts:
          - 'kube-state-metrics:8080'
        metricsets:
          - state_resourcequota
        bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
      - id: >-
          kubernetes/metrics-kubernetes.state_service-b6ebc720-3bc7-11ee-a0fc-f5e8b9d3c066
        data_stream:
          dataset: kubernetes.state_service
          type: metrics
        period: 10s
        condition: '${kubernetes_leaderelection.leader} == true'
        add_metadata: true
        hosts:
          - 'kube-state-metrics:8080'
        metricsets:
          - state_service
        bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
      - id: >-
          kubernetes/metrics-kubernetes.state_statefulset-b6ebc720-3bc7-11ee-a0fc-f5e8b9d3c066
        data_stream:
          dataset: kubernetes.state_statefulset
          type: metrics
        period: 10s
        condition: '${kubernetes_leaderelection.leader} == true'
        add_metadata: true
        hosts:
          - 'kube-state-metrics:8080'
        metricsets:
          - state_statefulset
        bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
      - id: >-
          kubernetes/metrics-kubernetes.state_storageclass-b6ebc720-3bc7-11ee-a0fc-f5e8b9d3c066
        data_stream:
          dataset: kubernetes.state_storageclass
          type: metrics
        period: 10s
        condition: '${kubernetes_leaderelection.leader} == true'
        add_metadata: true
        hosts:
          - 'kube-state-metrics:8080'
        metricsets:
          - state_storageclass
        bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
`condition` set, and leader election set
inputs:
  - id: kubernetes/metrics-kube-state-metrics-b6ebc720-3bc7-11ee-a0fc-f5e8b9d3c066
    name: kubernetes-1
    revision: 4
    type: kubernetes/metrics
    use_output: default
    meta:
      package:
        name: kubernetes
        version: 1.44.5
    data_stream:
      namespace: default
    package_policy_id: b6ebc720-3bc7-11ee-a0fc-f5e8b9d3c066
    streams:
      - id: >-
          kubernetes/metrics-kubernetes.state_container-b6ebc720-3bc7-11ee-a0fc-f5e8b9d3c066
        data_stream:
          dataset: kubernetes.state_container
          type: metrics
        period: 10s
        condition: >-
          ${kubernetes_leaderelection.leader} == true and ${host.name} ==
          'testing'
        add_metadata: true
        hosts:
          - 'kube-state-metrics:8080'
        metricsets:
          - state_container
        bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
      - id: >-
          kubernetes/metrics-kubernetes.state_cronjob-b6ebc720-3bc7-11ee-a0fc-f5e8b9d3c066
        data_stream:
          dataset: kubernetes.state_cronjob
          type: metrics
        period: 10s
        condition: >-
          ${kubernetes_leaderelection.leader} == true and ${host.name} ==
          'testing'
        add_metadata: true
        hosts:
          - 'kube-state-metrics:8080'
        metricsets:
          - state_cronjob
        bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
      - id: >-
          kubernetes/metrics-kubernetes.state_daemonset-b6ebc720-3bc7-11ee-a0fc-f5e8b9d3c066
        data_stream:
          dataset: kubernetes.state_daemonset
          type: metrics
        period: 10s
        condition: >-
          ${kubernetes_leaderelection.leader} == true and ${host.name} ==
          'testing'
        add_metadata: true
        hosts:
          - 'kube-state-metrics:8080'
        metricsets:
          - state_daemonset
        bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
      - id: >-
          kubernetes/metrics-kubernetes.state_deployment-b6ebc720-3bc7-11ee-a0fc-f5e8b9d3c066
        data_stream:
          dataset: kubernetes.state_deployment
          type: metrics
        period: 10s
        condition: >-
          ${kubernetes_leaderelection.leader} == true and ${host.name} ==
          'testing'
        add_metadata: true
        hosts:
          - 'kube-state-metrics:8080'
        metricsets:
          - state_deployment
        bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
      - id: >-
          kubernetes/metrics-kubernetes.state_job-b6ebc720-3bc7-11ee-a0fc-f5e8b9d3c066
        data_stream:
          dataset: kubernetes.state_job
          type: metrics
        period: 10s
        condition: >-
          ${kubernetes_leaderelection.leader} == true and ${host.name} ==
          'testing'
        add_metadata: true
        hosts:
          - 'kube-state-metrics:8080'
        metricsets:
          - state_job
        bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
      - id: >-
          kubernetes/metrics-kubernetes.state_node-b6ebc720-3bc7-11ee-a0fc-f5e8b9d3c066
        data_stream:
          dataset: kubernetes.state_node
          type: metrics
        period: 10s
        condition: >-
          ${kubernetes_leaderelection.leader} == true and ${host.name} ==
          'testing'
        add_metadata: true
        hosts:
          - 'kube-state-metrics:8080'
        metricsets:
          - state_node
        bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
      - id: >-
          kubernetes/metrics-kubernetes.state_persistentvolume-b6ebc720-3bc7-11ee-a0fc-f5e8b9d3c066
        data_stream:
          dataset: kubernetes.state_persistentvolume
          type: metrics
        period: 10s
        condition: >-
          ${kubernetes_leaderelection.leader} == true and ${host.name} ==
          'testing'
        add_metadata: true
        hosts:
          - 'kube-state-metrics:8080'
        metricsets:
          - state_persistentvolume
        bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
      - id: >-
          kubernetes/metrics-kubernetes.state_persistentvolumeclaim-b6ebc720-3bc7-11ee-a0fc-f5e8b9d3c066
        data_stream:
          dataset: kubernetes.state_persistentvolumeclaim
          type: metrics
        period: 10s
        condition: >-
          ${kubernetes_leaderelection.leader} == true and ${host.name} ==
          'testing'
        add_metadata: true
        hosts:
          - 'kube-state-metrics:8080'
        metricsets:
          - state_persistentvolumeclaim
        bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
      - id: >-
          kubernetes/metrics-kubernetes.state_pod-b6ebc720-3bc7-11ee-a0fc-f5e8b9d3c066
        data_stream:
          dataset: kubernetes.state_pod
          type: metrics
        period: 10s
        condition: >-
          ${kubernetes_leaderelection.leader} == true and ${host.name} ==
          'testing'
        add_metadata: true
        hosts:
          - 'kube-state-metrics:8080'
        metricsets:
          - state_pod
        bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
      - id: >-
          kubernetes/metrics-kubernetes.state_replicaset-b6ebc720-3bc7-11ee-a0fc-f5e8b9d3c066
        data_stream:
          dataset: kubernetes.state_replicaset
          type: metrics
        period: 10s
        condition: >-
          ${kubernetes_leaderelection.leader} == true and ${host.name} ==
          'testing'
        add_metadata: true
        hosts:
          - 'kube-state-metrics:8080'
        metricsets:
          - state_replicaset
        bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
      - id: >-
          kubernetes/metrics-kubernetes.state_resourcequota-b6ebc720-3bc7-11ee-a0fc-f5e8b9d3c066
        data_stream:
          dataset: kubernetes.state_resourcequota
          type: metrics
        period: 10s
        condition: >-
          ${kubernetes_leaderelection.leader} == true and ${host.name} ==
          'testing'
        add_metadata: true
        hosts:
          - 'kube-state-metrics:8080'
        metricsets:
          - state_resourcequota
        bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
      - id: >-
          kubernetes/metrics-kubernetes.state_service-b6ebc720-3bc7-11ee-a0fc-f5e8b9d3c066
        data_stream:
          dataset: kubernetes.state_service
          type: metrics
        period: 10s
        condition: >-
          ${kubernetes_leaderelection.leader} == true and ${host.name} ==
          'testing'
        add_metadata: true
        hosts:
          - 'kube-state-metrics:8080'
        metricsets:
          - state_service
        bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
      - id: >-
          kubernetes/metrics-kubernetes.state_statefulset-b6ebc720-3bc7-11ee-a0fc-f5e8b9d3c066
        data_stream:
          dataset: kubernetes.state_statefulset
          type: metrics
        period: 10s
        condition: >-
          ${kubernetes_leaderelection.leader} == true and ${host.name} ==
          'testing'
        add_metadata: true
        hosts:
          - 'kube-state-metrics:8080'
        metricsets:
          - state_statefulset
        bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
      - id: >-
          kubernetes/metrics-kubernetes.state_storageclass-b6ebc720-3bc7-11ee-a0fc-f5e8b9d3c066
        data_stream:
          dataset: kubernetes.state_storageclass
          type: metrics
        period: 10s
        condition: >-
          ${kubernetes_leaderelection.leader} == true and ${host.name} ==
          'testing'
        add_metadata: true
        hosts:
          - 'kube-state-metrics:8080'
        metricsets:
          - state_storageclass
        bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
`condition` set, no leader election set
inputs:
  - id: kubernetes/metrics-kube-state-metrics-b6ebc720-3bc7-11ee-a0fc-f5e8b9d3c066
    name: kubernetes-1
    revision: 5
    type: kubernetes/metrics
    use_output: default
    meta:
      package:
        name: kubernetes
        version: 1.44.5
    data_stream:
      namespace: default
    package_policy_id: b6ebc720-3bc7-11ee-a0fc-f5e8b9d3c066
    streams:
      - id: >-
          kubernetes/metrics-kubernetes.state_container-b6ebc720-3bc7-11ee-a0fc-f5e8b9d3c066
        data_stream:
          dataset: kubernetes.state_container
          type: metrics
        period: 10s
        condition: '${host.name} == ''testing'''
        add_metadata: true
        hosts:
          - 'kube-state-metrics:8080'
        metricsets:
          - state_container
        bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
      - id: >-
          kubernetes/metrics-kubernetes.state_cronjob-b6ebc720-3bc7-11ee-a0fc-f5e8b9d3c066
        data_stream:
          dataset: kubernetes.state_cronjob
          type: metrics
        period: 10s
        condition: '${host.name} == ''testing'''
        add_metadata: true
        hosts:
          - 'kube-state-metrics:8080'
        metricsets:
          - state_cronjob
        bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
      - id: >-
          kubernetes/metrics-kubernetes.state_daemonset-b6ebc720-3bc7-11ee-a0fc-f5e8b9d3c066
        data_stream:
          dataset: kubernetes.state_daemonset
          type: metrics
        period: 10s
        condition: '${host.name} == ''testing'''
        add_metadata: true
        hosts:
          - 'kube-state-metrics:8080'
        metricsets:
          - state_daemonset
        bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
      - id: >-
          kubernetes/metrics-kubernetes.state_deployment-b6ebc720-3bc7-11ee-a0fc-f5e8b9d3c066
        data_stream:
          dataset: kubernetes.state_deployment
          type: metrics
        period: 10s
        condition: '${host.name} == ''testing'''
        add_metadata: true
        hosts:
          - 'kube-state-metrics:8080'
        metricsets:
          - state_deployment
        bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
      - id: >-
          kubernetes/metrics-kubernetes.state_job-b6ebc720-3bc7-11ee-a0fc-f5e8b9d3c066
        data_stream:
          dataset: kubernetes.state_job
          type: metrics
        period: 10s
        condition: '${host.name} == ''testing'''
        add_metadata: true
        hosts:
          - 'kube-state-metrics:8080'
        metricsets:
          - state_job
        bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
      - id: >-
          kubernetes/metrics-kubernetes.state_node-b6ebc720-3bc7-11ee-a0fc-f5e8b9d3c066
        data_stream:
          dataset: kubernetes.state_node
          type: metrics
        period: 10s
        condition: '${host.name} == ''testing'''
        add_metadata: true
        hosts:
          - 'kube-state-metrics:8080'
        metricsets:
          - state_node
        bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
      - id: >-
          kubernetes/metrics-kubernetes.state_persistentvolume-b6ebc720-3bc7-11ee-a0fc-f5e8b9d3c066
        data_stream:
          dataset: kubernetes.state_persistentvolume
          type: metrics
        period: 10s
        condition: '${host.name} == ''testing'''
        add_metadata: true
        hosts:
          - 'kube-state-metrics:8080'
        metricsets:
          - state_persistentvolume
        bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
      - id: >-
          kubernetes/metrics-kubernetes.state_persistentvolumeclaim-b6ebc720-3bc7-11ee-a0fc-f5e8b9d3c066
        data_stream:
          dataset: kubernetes.state_persistentvolumeclaim
          type: metrics
        period: 10s
        condition: '${host.name} == ''testing'''
        add_metadata: true
        hosts:
          - 'kube-state-metrics:8080'
        metricsets:
          - state_persistentvolumeclaim
        bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
      - id: >-
          kubernetes/metrics-kubernetes.state_pod-b6ebc720-3bc7-11ee-a0fc-f5e8b9d3c066
        data_stream:
          dataset: kubernetes.state_pod
          type: metrics
        period: 10s
        condition: '${host.name} == ''testing'''
        add_metadata: true
        hosts:
          - 'kube-state-metrics:8080'
        metricsets:
          - state_pod
        bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
      - id: >-
          kubernetes/metrics-kubernetes.state_replicaset-b6ebc720-3bc7-11ee-a0fc-f5e8b9d3c066
        data_stream:
          dataset: kubernetes.state_replicaset
          type: metrics
        period: 10s
        condition: '${host.name} == ''testing'''
        add_metadata: true
        hosts:
          - 'kube-state-metrics:8080'
        metricsets:
          - state_replicaset
        bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
      - id: >-
          kubernetes/metrics-kubernetes.state_resourcequota-b6ebc720-3bc7-11ee-a0fc-f5e8b9d3c066
        data_stream:
          dataset: kubernetes.state_resourcequota
          type: metrics
        period: 10s
        condition: '${host.name} == ''testing'''
        add_metadata: true
        hosts:
          - 'kube-state-metrics:8080'
        metricsets:
          - state_resourcequota
        bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
      - id: >-
          kubernetes/metrics-kubernetes.state_service-b6ebc720-3bc7-11ee-a0fc-f5e8b9d3c066
        data_stream:
          dataset: kubernetes.state_service
          type: metrics
        period: 10s
        condition: '${host.name} == ''testing'''
        add_metadata: true
        hosts:
          - 'kube-state-metrics:8080'
        metricsets:
          - state_service
        bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
      - id: >-
          kubernetes/metrics-kubernetes.state_statefulset-b6ebc720-3bc7-11ee-a0fc-f5e8b9d3c066
        data_stream:
          dataset: kubernetes.state_statefulset
          type: metrics
        period: 10s
        condition: '${host.name} == ''testing'''
        add_metadata: true
        hosts:
          - 'kube-state-metrics:8080'
        metricsets:
          - state_statefulset
        bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
      - id: >-
          kubernetes/metrics-kubernetes.state_storageclass-b6ebc720-3bc7-11ee-a0fc-f5e8b9d3c066
        data_stream:
          dataset: kubernetes.state_storageclass
          type: metrics
        period: 10s
        condition: '${host.name} == ''testing'''
        add_metadata: true
        hosts:
          - 'kube-state-metrics:8080'
        metricsets:
          - state_storageclass
        bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
No `condition` set, no leader election set
inputs:
  - id: kubernetes/metrics-kube-state-metrics-b6ebc720-3bc7-11ee-a0fc-f5e8b9d3c066
    name: kubernetes-1
    revision: 6
    type: kubernetes/metrics
    use_output: default
    meta:
      package:
        name: kubernetes
        version: 1.44.5
    data_stream:
      namespace: default
    package_policy_id: b6ebc720-3bc7-11ee-a0fc-f5e8b9d3c066
    streams:
      - id: >-
          kubernetes/metrics-kubernetes.state_container-b6ebc720-3bc7-11ee-a0fc-f5e8b9d3c066
        data_stream:
          dataset: kubernetes.state_container
          type: metrics
        period: 10s
        add_metadata: true
        hosts:
          - 'kube-state-metrics:8080'
        metricsets:
          - state_container
        bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
      - id: >-
          kubernetes/metrics-kubernetes.state_cronjob-b6ebc720-3bc7-11ee-a0fc-f5e8b9d3c066
        data_stream:
          dataset: kubernetes.state_cronjob
          type: metrics
        period: 10s
        add_metadata: true
        hosts:
          - 'kube-state-metrics:8080'
        metricsets:
          - state_cronjob
        bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
      - id: >-
          kubernetes/metrics-kubernetes.state_daemonset-b6ebc720-3bc7-11ee-a0fc-f5e8b9d3c066
        data_stream:
          dataset: kubernetes.state_daemonset
          type: metrics
        period: 10s
        add_metadata: true
        hosts:
          - 'kube-state-metrics:8080'
        metricsets:
          - state_daemonset
        bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
      - id: >-
          kubernetes/metrics-kubernetes.state_deployment-b6ebc720-3bc7-11ee-a0fc-f5e8b9d3c066
        data_stream:
          dataset: kubernetes.state_deployment
          type: metrics
        period: 10s
        add_metadata: true
        hosts:
          - 'kube-state-metrics:8080'
        metricsets:
          - state_deployment
        bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
      - id: >-
          kubernetes/metrics-kubernetes.state_job-b6ebc720-3bc7-11ee-a0fc-f5e8b9d3c066
        data_stream:
          dataset: kubernetes.state_job
          type: metrics
        period: 10s
        add_metadata: true
        hosts:
          - 'kube-state-metrics:8080'
        metricsets:
          - state_job
        bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
      - id: >-
          kubernetes/metrics-kubernetes.state_node-b6ebc720-3bc7-11ee-a0fc-f5e8b9d3c066
        data_stream:
          dataset: kubernetes.state_node
          type: metrics
        period: 10s
        add_metadata: true
        hosts:
          - 'kube-state-metrics:8080'
        metricsets:
          - state_node
        bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
      - id: >-
          kubernetes/metrics-kubernetes.state_persistentvolume-b6ebc720-3bc7-11ee-a0fc-f5e8b9d3c066
        data_stream:
          dataset: kubernetes.state_persistentvolume
          type: metrics
        period: 10s
        add_metadata: true
        hosts:
          - 'kube-state-metrics:8080'
        metricsets:
          - state_persistentvolume
        bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
      - id: >-
          kubernetes/metrics-kubernetes.state_persistentvolumeclaim-b6ebc720-3bc7-11ee-a0fc-f5e8b9d3c066
        data_stream:
          dataset: kubernetes.state_persistentvolumeclaim
          type: metrics
        period: 10s
        add_metadata: true
        hosts:
          - 'kube-state-metrics:8080'
        metricsets:
          - state_persistentvolumeclaim
        bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
      - id: >-
          kubernetes/metrics-kubernetes.state_pod-b6ebc720-3bc7-11ee-a0fc-f5e8b9d3c066
        data_stream:
          dataset: kubernetes.state_pod
          type: metrics
        period: 10s
        add_metadata: true
        hosts:
          - 'kube-state-metrics:8080'
        metricsets:
          - state_pod
        bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
      - id: >-
          kubernetes/metrics-kubernetes.state_replicaset-b6ebc720-3bc7-11ee-a0fc-f5e8b9d3c066
        data_stream:
          dataset: kubernetes.state_replicaset
          type: metrics
        period: 10s
        add_metadata: true
        hosts:
          - 'kube-state-metrics:8080'
        metricsets:
          - state_replicaset
        bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
      - id: >-
          kubernetes/metrics-kubernetes.state_resourcequota-b6ebc720-3bc7-11ee-a0fc-f5e8b9d3c066
        data_stream:
          dataset: kubernetes.state_resourcequota
          type: metrics
        period: 10s
        add_metadata: true
        hosts:
          - 'kube-state-metrics:8080'
        metricsets:
          - state_resourcequota
        bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
      - id: >-
          kubernetes/metrics-kubernetes.state_service-b6ebc720-3bc7-11ee-a0fc-f5e8b9d3c066
        data_stream:
          dataset: kubernetes.state_service
          type: metrics
        period: 10s
        add_metadata: true
        hosts:
          - 'kube-state-metrics:8080'
        metricsets:
          - state_service
        bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
      - id: >-
          kubernetes/metrics-kubernetes.state_statefulset-b6ebc720-3bc7-11ee-a0fc-f5e8b9d3c066
        data_stream:
          dataset: kubernetes.state_statefulset
          type: metrics
        period: 10s
        add_metadata: true
        hosts:
          - 'kube-state-metrics:8080'
        metricsets:
          - state_statefulset
        bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
      - id: >-
          kubernetes/metrics-kubernetes.state_storageclass-b6ebc720-3bc7-11ee-a0fc-f5e8b9d3c066
        data_stream:
          dataset: kubernetes.state_storageclass
          type: metrics
        period: 10s
        add_metadata: true
        hosts:
          - 'kube-state-metrics:8080'
        metricsets:
          - state_storageclass
        bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
---
Kubernetes API Server ---
No `condition`, but leader election set
inputs:
  - id: kubernetes/metrics-kube-apiserver-b6ebc720-3bc7-11ee-a0fc-f5e8b9d3c066
    name: kubernetes-1
    revision: 7
    type: kubernetes/metrics
    use_output: default
    meta:
      package:
        name: kubernetes
        version: 1.44.5
    data_stream:
      namespace: default
    package_policy_id: b6ebc720-3bc7-11ee-a0fc-f5e8b9d3c066
    streams:
      - id: >-
          kubernetes/metrics-kubernetes.apiserver-b6ebc720-3bc7-11ee-a0fc-f5e8b9d3c066
        data_stream:
          dataset: kubernetes.apiserver
          type: metrics
        period: 30s
        condition: '${kubernetes_leaderelection.leader} == true'
        hosts:
          - >-
            https://${env.KUBERNETES_SERVICE_HOST}:${env.KUBERNETES_SERVICE_PORT}
        metricsets:
          - apiserver
        ssl.certificate_authorities:
          - /var/run/secrets/kubernetes.io/serviceaccount/ca.crt
        bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
`condition` set, and leader election set
inputs:
  - id: kubernetes/metrics-kube-apiserver-b6ebc720-3bc7-11ee-a0fc-f5e8b9d3c066
    name: kubernetes-1
    revision: 8
    type: kubernetes/metrics
    use_output: default
    meta:
      package:
        name: kubernetes
        version: 1.44.5
    data_stream:
      namespace: default
    package_policy_id: b6ebc720-3bc7-11ee-a0fc-f5e8b9d3c066
    streams:
      - id: >-
          kubernetes/metrics-kubernetes.apiserver-b6ebc720-3bc7-11ee-a0fc-f5e8b9d3c066
        data_stream:
          dataset: kubernetes.apiserver
          type: metrics
        period: 30s
        condition: >-
          ${kubernetes_leaderelection.leader} == true and ${host.name} ==
          'testing'
        hosts:
          - >-
            https://${env.KUBERNETES_SERVICE_HOST}:${env.KUBERNETES_SERVICE_PORT}
        metricsets:
          - apiserver
        ssl.certificate_authorities:
          - /var/run/secrets/kubernetes.io/serviceaccount/ca.crt
        bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
`condition` set, but leader election not set
inputs:
  - id: kubernetes/metrics-kube-apiserver-b6ebc720-3bc7-11ee-a0fc-f5e8b9d3c066
    name: kubernetes-1
    revision: 9
    type: kubernetes/metrics
    use_output: default
    meta:
      package:
        name: kubernetes
        version: 1.44.5
    data_stream:
      namespace: default
    package_policy_id: b6ebc720-3bc7-11ee-a0fc-f5e8b9d3c066
    streams:
      - id: >-
          kubernetes/metrics-kubernetes.apiserver-b6ebc720-3bc7-11ee-a0fc-f5e8b9d3c066
        data_stream:
          dataset: kubernetes.apiserver
          type: metrics
        period: 30s
        condition: '${host.name} == ''testing'''
        hosts:
          - >-
            https://${env.KUBERNETES_SERVICE_HOST}:${env.KUBERNETES_SERVICE_PORT}
        metricsets:
          - apiserver
        ssl.certificate_authorities:
          - /var/run/secrets/kubernetes.io/serviceaccount/ca.crt
        bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
No `condition` set, no leader election set
inputs:
  - id: kubernetes/metrics-kube-apiserver-b6ebc720-3bc7-11ee-a0fc-f5e8b9d3c066
    name: kubernetes-1
    revision: 10
    type: kubernetes/metrics
    use_output: default
    meta:
      package:
        name: kubernetes
        version: 1.44.5
    data_stream:
      namespace: default
    package_policy_id: b6ebc720-3bc7-11ee-a0fc-f5e8b9d3c066
    streams:
      - id: >-
          kubernetes/metrics-kubernetes.apiserver-b6ebc720-3bc7-11ee-a0fc-f5e8b9d3c066
        data_stream:
          dataset: kubernetes.apiserver
          type: metrics
        period: 30s
        hosts:
          - >-
            https://${env.KUBERNETES_SERVICE_HOST}:${env.KUBERNETES_SERVICE_PORT}
        metricsets:
          - apiserver
        ssl.certificate_authorities:
          - /var/run/secrets/kubernetes.io/serviceaccount/ca.crt
        bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
---
Kubernetes Proxy ---
No `condition` set
inputs:
  - id: kubernetes/metrics-kube-proxy-b6ebc720-3bc7-11ee-a0fc-f5e8b9d3c066
    name: kubernetes-1
    revision: 11
    type: kubernetes/metrics
    use_output: default
    meta:
      package:
        name: kubernetes
        version: 1.44.5
    data_stream:
      namespace: default
    package_policy_id: b6ebc720-3bc7-11ee-a0fc-f5e8b9d3c066
    streams:
      - id: >-
          kubernetes/metrics-kubernetes.proxy-b6ebc720-3bc7-11ee-a0fc-f5e8b9d3c066
        data_stream:
          dataset: kubernetes.proxy
          type: metrics
        period: 10s
        hosts:
          - 'localhost:10249'
        metricsets:
          - proxy
`condition` set
inputs:
  - id: kubernetes/metrics-kube-proxy-b6ebc720-3bc7-11ee-a0fc-f5e8b9d3c066
    name: kubernetes-1
    revision: 12
    type: kubernetes/metrics
    use_output: default
    meta:
      package:
        name: kubernetes
        version: 1.44.5
    data_stream:
      namespace: default
    package_policy_id: b6ebc720-3bc7-11ee-a0fc-f5e8b9d3c066
    streams:
      - id: >-
          kubernetes/metrics-kubernetes.proxy-b6ebc720-3bc7-11ee-a0fc-f5e8b9d3c066
        data_stream:
          dataset: kubernetes.proxy
          type: metrics
        period: 10s
        condition: '${host.name} == ''testing'''
        hosts:
          - 'localhost:10249'
        metricsets:
          - proxy
---
Kubernetes Scheduler ---
No `condition` set
inputs:
  - id: kubernetes/metrics-kube-scheduler-b6ebc720-3bc7-11ee-a0fc-f5e8b9d3c066
    name: kubernetes-1
    revision: 13
    type: kubernetes/metrics
    use_output: default
    meta:
      package:
        name: kubernetes
        version: 1.44.5
    data_stream:
      namespace: default
    package_policy_id: b6ebc720-3bc7-11ee-a0fc-f5e8b9d3c066
    streams:
      - id: >-
          kubernetes/metrics-kubernetes.scheduler-b6ebc720-3bc7-11ee-a0fc-f5e8b9d3c066
        data_stream:
          dataset: kubernetes.scheduler
          type: metrics
        period: 10s
        condition: '${kubernetes.labels.component} == ''kube-scheduler'''
        hosts:
          - 'https://0.0.0.0:10259'
        ssl.verification_mode: none
        metricsets:
          - scheduler
        bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
`condition` set
inputs:
  - id: kubernetes/metrics-kube-scheduler-b6ebc720-3bc7-11ee-a0fc-f5e8b9d3c066
    name: kubernetes-1
    revision: 14
    type: kubernetes/metrics
    use_output: default
    meta:
      package:
        name: kubernetes
        version: 1.44.5
    data_stream:
      namespace: default
    package_policy_id: b6ebc720-3bc7-11ee-a0fc-f5e8b9d3c066
    streams:
      - id: >-
          kubernetes/metrics-kubernetes.scheduler-b6ebc720-3bc7-11ee-a0fc-f5e8b9d3c066
        data_stream:
          dataset: kubernetes.scheduler
          type: metrics
        period: 10s
        condition: >-
          ${kubernetes.labels.component} == 'kube-scheduler' and ${host.name} ==
          'testing'
        hosts:
          - 'https://0.0.0.0:10259'
        ssl.verification_mode: none
        metricsets:
          - scheduler
        bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
---
Kubernetes controller-manager ---
No `condition`
inputs:
  - id: >-
      kubernetes/metrics-kube-controller-manager-b6ebc720-3bc7-11ee-a0fc-f5e8b9d3c066
    name: kubernetes-1
    revision: 15
    type: kubernetes/metrics
    use_output: default
    meta:
      package:
        name: kubernetes
        version: 1.44.5
    data_stream:
      namespace: default
    package_policy_id: b6ebc720-3bc7-11ee-a0fc-f5e8b9d3c066
    streams:
      - id: >-
          kubernetes/metrics-kubernetes.controllermanager-b6ebc720-3bc7-11ee-a0fc-f5e8b9d3c066
        data_stream:
          dataset: kubernetes.controllermanager
          type: metrics
        period: 10s
        condition: '${kubernetes.labels.component} == ''kube-controller-manager'''
        hosts:
          - 'https://0.0.0.0:10257'
        ssl.verification_mode: none
        metricsets:
          - controllermanager
        bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
`condition` set
inputs:
  - id: >-
      kubernetes/metrics-kube-controller-manager-b6ebc720-3bc7-11ee-a0fc-f5e8b9d3c066
    name: kubernetes-1
    revision: 16
    type: kubernetes/metrics
    use_output: default
    meta:
      package:
        name: kubernetes
        version: 1.44.5
    data_stream:
      namespace: default
    package_policy_id: b6ebc720-3bc7-11ee-a0fc-f5e8b9d3c066
    streams:
      - id: >-
          kubernetes/metrics-kubernetes.controllermanager-b6ebc720-3bc7-11ee-a0fc-f5e8b9d3c066
        data_stream:
          dataset: kubernetes.controllermanager
          type: metrics
        period: 10s
        condition: >-
          ${kubernetes.labels.component} == 'kube-controller-manager' and
          ${host.name} == 'testing'
        hosts:
          - 'https://0.0.0.0:10257'
        ssl.verification_mode: none
        metricsets:
          - controllermanager
        bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
---
Kubernetes API Server ---
No `condition`, but with leader election
inputs:
  - id: kubernetes/metrics-events-b6ebc720-3bc7-11ee-a0fc-f5e8b9d3c066
    name: kubernetes-1
    revision: 17
    type: kubernetes/metrics
    use_output: default
    meta:
      package:
        name: kubernetes
        version: 1.44.5
    data_stream:
      namespace: default
    package_policy_id: b6ebc720-3bc7-11ee-a0fc-f5e8b9d3c066
    streams:
      - id: >-
          kubernetes/metrics-kubernetes.event-b6ebc720-3bc7-11ee-a0fc-f5e8b9d3c066
        data_stream:
          dataset: kubernetes.event
          type: metrics
        period: 10s
        condition: '${kubernetes_leaderelection.leader} == true'
        add_metadata: true
        metricsets:
          - event
        skip_older: true
`condition` set, and leader election set
inputs:
  - id: kubernetes/metrics-events-b6ebc720-3bc7-11ee-a0fc-f5e8b9d3c066
    name: kubernetes-1
    revision: 18
    type: kubernetes/metrics
    use_output: default
    meta:
      package:
        name: kubernetes
        version: 1.44.5
    data_stream:
      namespace: default
    package_policy_id: b6ebc720-3bc7-11ee-a0fc-f5e8b9d3c066
    streams:
      - id: >-
          kubernetes/metrics-kubernetes.event-b6ebc720-3bc7-11ee-a0fc-f5e8b9d3c066
        data_stream:
          dataset: kubernetes.event
          type: metrics
        period: 10s
        condition: >-
          ${kubernetes_leaderelection.leader} == true and ${host.name} ==
          'testing'
        add_metadata: true
        metricsets:
          - event
        skip_older: true
`condition` set, but leader election not set
inputs:
  - id: kubernetes/metrics-events-b6ebc720-3bc7-11ee-a0fc-f5e8b9d3c066
    name: kubernetes-1
    revision: 19
    type: kubernetes/metrics
    use_output: default
    meta:
      package:
        name: kubernetes
        version: 1.44.5
    data_stream:
      namespace: default
    package_policy_id: b6ebc720-3bc7-11ee-a0fc-f5e8b9d3c066
    streams:
      - id: >-
          kubernetes/metrics-kubernetes.event-b6ebc720-3bc7-11ee-a0fc-f5e8b9d3c066
        data_stream:
          dataset: kubernetes.event
          type: metrics
        period: 10s
        condition: '${host.name} == ''testing'''
        add_metadata: true
        metricsets:
          - event
        skip_older: true
No `condition` set, and leader election not set
inputs:
  - id: kubernetes/metrics-events-b6ebc720-3bc7-11ee-a0fc-f5e8b9d3c066
    name: kubernetes-1
    revision: 20
    type: kubernetes/metrics
    use_output: default
    meta:
      package:
        name: kubernetes
        version: 1.44.5
    data_stream:
      namespace: default
    package_policy_id: b6ebc720-3bc7-11ee-a0fc-f5e8b9d3c066
    streams:
      - id: >-
          kubernetes/metrics-kubernetes.event-b6ebc720-3bc7-11ee-a0fc-f5e8b9d3c066
        data_stream:
          dataset: kubernetes.event
          type: metrics
        period: 10s
        add_metadata: true
        metricsets:
          - event
        skip_older: true
---
Kubernetes audit logs ---
No `condition` set
inputs:
  - id: filestream-audit-logs-b6ebc720-3bc7-11ee-a0fc-f5e8b9d3c066
    name: kubernetes-1
    revision: 21
    type: filestream
    use_output: default
    meta:
      package:
        name: kubernetes
        version: 1.44.5
    data_stream:
      namespace: default
    package_policy_id: b6ebc720-3bc7-11ee-a0fc-f5e8b9d3c066
    streams:
      - id: filestream-kubernetes.audit_logs-b6ebc720-3bc7-11ee-a0fc-f5e8b9d3c066
        data_stream:
          dataset: kubernetes.audit_logs
          type: logs
        exclude_files:
          - .gz$
        paths:
          - /var/log/kubernetes/kube-apiserver-audit.log
        parsers:
          - ndjson:
              add_error_key: true
              target: kubernetes_audit
        processors:
          - rename:
              fields:
                - from: kubernetes_audit
                  to: kubernetes.audit
          - drop_fields:
              fields:
                - kubernetes.audit.responseObject.metadata
              when:
                has_fields: kubernetes.audit.responseObject
          - drop_fields:
              fields:
                - kubernetes.audit.requestObject.metadata
              when:
                has_fields: kubernetes.audit.requestObject
          - script:
              id: dedot_annotations
              source: |
                function process(event) {
                  var audit = event.Get("kubernetes.audit");
                  for (var annotation in audit["annotations"]) {
                    var annotation_dedoted = annotation.replace(/\./g,'_')
                    event.Rename("kubernetes.audit.annotations."+annotation, "kubernetes.audit.annotations."+annotation_dedoted)
                  }
                  return event;
                } function test() {
                  var event = process(new Event({ "kubernetes": { "audit": { "annotations": { "authorization.k8s.io/decision": "allow", "authorization.k8s.io/reason": "RBAC: allowed by ClusterRoleBinding \"system:kube-scheduler\" of ClusterRole \"system:kube-scheduler\" to User \"system:kube-scheduler\"" } } } }));
                  if (event.Get("kubernetes.audit.annotations.authorization_k8s_io/decision") !== "allow") {
                      throw "expected kubernetes.audit.annotations.authorization_k8s_io/decision === allow";
                  }
                }
              lang: javascript
`condition` set
inputs:
  - id: filestream-audit-logs-b6ebc720-3bc7-11ee-a0fc-f5e8b9d3c066
    name: kubernetes-1
    revision: 22
    type: filestream
    use_output: default
    meta:
      package:
        name: kubernetes
        version: 1.44.5
    data_stream:
      namespace: default
    package_policy_id: b6ebc720-3bc7-11ee-a0fc-f5e8b9d3c066
    streams:
      - id: filestream-kubernetes.audit_logs-b6ebc720-3bc7-11ee-a0fc-f5e8b9d3c066
        data_stream:
          dataset: kubernetes.audit_logs
          type: logs
        exclude_files:
          - .gz$
        condition: '${host.name} == ''testing'''
        paths:
          - /var/log/kubernetes/kube-apiserver-audit.log
        parsers:
          - ndjson:
              add_error_key: true
              target: kubernetes_audit
        processors:
          - rename:
              fields:
                - from: kubernetes_audit
                  to: kubernetes.audit
          - drop_fields:
              fields:
                - kubernetes.audit.responseObject.metadata
              when:
                has_fields: kubernetes.audit.responseObject
          - drop_fields:
              fields:
                - kubernetes.audit.requestObject.metadata
              when:
                has_fields: kubernetes.audit.requestObject
          - script:
              id: dedot_annotations
              source: |
                function process(event) {
                  var audit = event.Get("kubernetes.audit");
                  for (var annotation in audit["annotations"]) {
                    var annotation_dedoted = annotation.replace(/\./g,'_')
                    event.Rename("kubernetes.audit.annotations."+annotation, "kubernetes.audit.annotations."+annotation_dedoted)
                  }
                  return event;
                } function test() {
                  var event = process(new Event({ "kubernetes": { "audit": { "annotations": { "authorization.k8s.io/decision": "allow", "authorization.k8s.io/reason": "RBAC: allowed by ClusterRoleBinding \"system:kube-scheduler\" of ClusterRole \"system:kube-scheduler\" to User \"system:kube-scheduler\"" } } } }));
                  if (event.Get("kubernetes.audit.annotations.authorization_k8s_io/decision") !== "allow") {
                      throw "expected kubernetes.audit.annotations.authorization_k8s_io/decision === allow";
                  }
                }
              lang: javascript
---

Related issues

Screenshots

@BenB196 BenB196 requested a review from a team as a code owner August 16, 2023 00:24
@elasticmachine
Copy link

elasticmachine commented Aug 16, 2023

💚 Build Succeeded

the below badges are clickable and redirect to their specific view in the CI or DOCS
Pipeline View Test View Changes Artifacts preview preview

Expand to view the summary

Build stats

  • Start Time: 2023-11-10T12:13:34.398+0000

  • Duration: 117 min 18 sec

Test stats 🧪

Test Results
Failed 0
Passed 97
Skipped 0
Total 97

🤖 GitHub comments

Expand to view the GitHub comments

To re-run your PR in the CI, just comment with:

  • /test : Re-trigger the build.

@MichaelKatsoulis MichaelKatsoulis requested review from MichaelKatsoulis and removed request for gsantoro August 17, 2023 07:48
@ChrsMark
Copy link
Member

ChrsMark commented Aug 21, 2023

@BenB196 thank's for adding this!

@mlunadia since this adds an advanced "hidden" setting (which makes sense) I wonder how those "features" are/should be reflected in the docs (mostly a heads'up).

@gizas
Copy link
Contributor

gizas commented Aug 22, 2023

@BenB196 thank you for this. I also think we needed this.

I added a small update for kubelet to show the condition to users

Second and most important I believe that kube-state-metrics wont need a global condition, the opposite only specific ones per datastream. Main reason is that I would like to avoid users setting leader off in the global condition and keep leader flag open to all sub datastreams. So I would sugest to remove global condition from kube-state-metrics and introduce one per ksm datastream.

Apart from that, the tests and all checks seem ok! Thank you again

BenB196 and others added 2 commits August 22, 2023 06:38
Co-authored-by: Andrew Gizas <andreas.gkizas@elastic.co>
Copy link
Contributor Author

@BenB196 BenB196 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I retested the Kubelet section as this was the only part the experienced change.

No top-level condition, not per stream condition
inputs:
  - id: kubernetes/metrics-kubelet-dfd54600-4141-11ee-b801-0987c2093460
    name: kubernetes-1
    revision: 1
    type: kubernetes/metrics
    use_output: default
    meta:
      package:
        name: kubernetes
        version: 1.44.0
    data_stream:
      namespace: default
    package_policy_id: dfd54600-4141-11ee-b801-0987c2093460
    streams:
      - id: >-
          kubernetes/metrics-kubernetes.container-dfd54600-4141-11ee-b801-0987c2093460
        data_stream:
          dataset: kubernetes.container
          type: metrics
        metricsets:
          - container
        add_metadata: true
        hosts:
          - 'https://${env.NODE_NAME}:10250'
        period: 10s
        bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
        ssl.verification_mode: none
      - id: >-
          kubernetes/metrics-kubernetes.node-dfd54600-4141-11ee-b801-0987c2093460
        data_stream:
          dataset: kubernetes.node
          type: metrics
        metricsets:
          - node
        add_metadata: true
        hosts:
          - 'https://${env.NODE_NAME}:10250'
        period: 10s
        bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
        ssl.verification_mode: none
      - id: kubernetes/metrics-kubernetes.pod-dfd54600-4141-11ee-b801-0987c2093460
        data_stream:
          dataset: kubernetes.pod
          type: metrics
        metricsets:
          - pod
        add_metadata: true
        hosts:
          - 'https://${env.NODE_NAME}:10250'
        period: 10s
        bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
        ssl.verification_mode: none
      - id: >-
          kubernetes/metrics-kubernetes.system-dfd54600-4141-11ee-b801-0987c2093460
        data_stream:
          dataset: kubernetes.system
          type: metrics
        metricsets:
          - system
        add_metadata: true
        hosts:
          - 'https://${env.NODE_NAME}:10250'
        period: 10s
        bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
        ssl.verification_mode: none
      - id: >-
          kubernetes/metrics-kubernetes.volume-dfd54600-4141-11ee-b801-0987c2093460
        data_stream:
          dataset: kubernetes.volume
          type: metrics
        metricsets:
          - volume
        add_metadata: true
        hosts:
          - 'https://${env.NODE_NAME}:10250'
        period: 10s
        bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
        ssl.verification_mode: none
Top level condition, and per stream condition
inputs:
  - id: kubernetes/metrics-kubelet-dfd54600-4141-11ee-b801-0987c2093460
    name: kubernetes-1
    revision: 3
    type: kubernetes/metrics
    use_output: default
    meta:
      package:
        name: kubernetes
        version: 1.44.0
    data_stream:
      namespace: default
    package_policy_id: dfd54600-4141-11ee-b801-0987c2093460
    streams:
      - id: >-
          kubernetes/metrics-kubernetes.container-dfd54600-4141-11ee-b801-0987c2093460
        data_stream:
          dataset: kubernetes.container
          type: metrics
        period: 10s
        condition: '${host.name} == ''testing'' and ${pod.name} == ''hello-world'''
        add_metadata: true
        hosts:
          - 'https://${env.NODE_NAME}:10250'
        ssl.verification_mode: none
        metricsets:
          - container
        bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
      - id: >-
          kubernetes/metrics-kubernetes.node-dfd54600-4141-11ee-b801-0987c2093460
        data_stream:
          dataset: kubernetes.node
          type: metrics
        period: 10s
        condition: '${host.name} == ''testing'' and ${pod.name} == ''hello-world'''
        add_metadata: true
        hosts:
          - 'https://${env.NODE_NAME}:10250'
        ssl.verification_mode: none
        metricsets:
          - node
        bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
      - id: kubernetes/metrics-kubernetes.pod-dfd54600-4141-11ee-b801-0987c2093460
        data_stream:
          dataset: kubernetes.pod
          type: metrics
        period: 10s
        condition: '${host.name} == ''testing'' and ${pod.name} == ''hello-world'''
        add_metadata: true
        hosts:
          - 'https://${env.NODE_NAME}:10250'
        ssl.verification_mode: none
        metricsets:
          - pod
        bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
      - id: >-
          kubernetes/metrics-kubernetes.system-dfd54600-4141-11ee-b801-0987c2093460
        data_stream:
          dataset: kubernetes.system
          type: metrics
        period: 10s
        condition: '${host.name} == ''testing'' and ${pod.name} == ''hello-world'''
        add_metadata: true
        hosts:
          - 'https://${env.NODE_NAME}:10250'
        ssl.verification_mode: none
        metricsets:
          - system
        bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
      - id: >-
          kubernetes/metrics-kubernetes.volume-dfd54600-4141-11ee-b801-0987c2093460
        data_stream:
          dataset: kubernetes.volume
          type: metrics
        period: 10s
        condition: '${host.name} == ''testing'' and ${pod.name} == ''hello-world'''
        add_metadata: true
        hosts:
          - 'https://${env.NODE_NAME}:10250'
        ssl.verification_mode: none
        metricsets:
          - volume
        bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
No top level condition, per stream condition
inputs:
  - id: kubernetes/metrics-kubelet-dfd54600-4141-11ee-b801-0987c2093460
    name: kubernetes-1
    revision: 4
    type: kubernetes/metrics
    use_output: default
    meta:
      package:
        name: kubernetes
        version: 1.44.0
    data_stream:
      namespace: default
    package_policy_id: dfd54600-4141-11ee-b801-0987c2093460
    streams:
      - id: >-
          kubernetes/metrics-kubernetes.container-dfd54600-4141-11ee-b801-0987c2093460
        data_stream:
          dataset: kubernetes.container
          type: metrics
        period: 10s
        condition: '${pod.name} == ''hello-world'''
        add_metadata: true
        hosts:
          - 'https://${env.NODE_NAME}:10250'
        ssl.verification_mode: none
        metricsets:
          - container
        bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
      - id: >-
          kubernetes/metrics-kubernetes.node-dfd54600-4141-11ee-b801-0987c2093460
        data_stream:
          dataset: kubernetes.node
          type: metrics
        period: 10s
        condition: '${pod.name} == ''hello-world'''
        add_metadata: true
        hosts:
          - 'https://${env.NODE_NAME}:10250'
        ssl.verification_mode: none
        metricsets:
          - node
        bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
      - id: kubernetes/metrics-kubernetes.pod-dfd54600-4141-11ee-b801-0987c2093460
        data_stream:
          dataset: kubernetes.pod
          type: metrics
        period: 10s
        condition: '${pod.name} == ''hello-world'''
        add_metadata: true
        hosts:
          - 'https://${env.NODE_NAME}:10250'
        ssl.verification_mode: none
        metricsets:
          - pod
        bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
      - id: >-
          kubernetes/metrics-kubernetes.system-dfd54600-4141-11ee-b801-0987c2093460
        data_stream:
          dataset: kubernetes.system
          type: metrics
        period: 10s
        condition: '${pod.name} == ''hello-world'''
        add_metadata: true
        hosts:
          - 'https://${env.NODE_NAME}:10250'
        ssl.verification_mode: none
        metricsets:
          - system
        bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
      - id: >-
          kubernetes/metrics-kubernetes.volume-dfd54600-4141-11ee-b801-0987c2093460
        data_stream:
          dataset: kubernetes.volume
          type: metrics
        period: 10s
        condition: '${pod.name} == ''hello-world'''
        add_metadata: true
        hosts:
          - 'https://${env.NODE_NAME}:10250'
        ssl.verification_mode: none
        metricsets:
          - volume
        bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
Top level condition, no per stream condition
inputs:
  - id: kubernetes/metrics-kubelet-dfd54600-4141-11ee-b801-0987c2093460
    name: kubernetes-1
    revision: 5
    type: kubernetes/metrics
    use_output: default
    meta:
      package:
        name: kubernetes
        version: 1.44.0
    data_stream:
      namespace: default
    package_policy_id: dfd54600-4141-11ee-b801-0987c2093460
    streams:
      - id: >-
          kubernetes/metrics-kubernetes.container-dfd54600-4141-11ee-b801-0987c2093460
        data_stream:
          dataset: kubernetes.container
          type: metrics
        period: 10s
        condition: '${host.name} == ''testing'''
        add_metadata: true
        hosts:
          - 'https://${env.NODE_NAME}:10250'
        ssl.verification_mode: none
        metricsets:
          - container
        bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
      - id: >-
          kubernetes/metrics-kubernetes.node-dfd54600-4141-11ee-b801-0987c2093460
        data_stream:
          dataset: kubernetes.node
          type: metrics
        period: 10s
        condition: '${host.name} == ''testing'''
        add_metadata: true
        hosts:
          - 'https://${env.NODE_NAME}:10250'
        ssl.verification_mode: none
        metricsets:
          - node
        bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
      - id: kubernetes/metrics-kubernetes.pod-dfd54600-4141-11ee-b801-0987c2093460
        data_stream:
          dataset: kubernetes.pod
          type: metrics
        period: 10s
        condition: '${host.name} == ''testing'''
        add_metadata: true
        hosts:
          - 'https://${env.NODE_NAME}:10250'
        ssl.verification_mode: none
        metricsets:
          - pod
        bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
      - id: >-
          kubernetes/metrics-kubernetes.system-dfd54600-4141-11ee-b801-0987c2093460
        data_stream:
          dataset: kubernetes.system
          type: metrics
        period: 10s
        condition: '${host.name} == ''testing'''
        add_metadata: true
        hosts:
          - 'https://${env.NODE_NAME}:10250'
        ssl.verification_mode: none
        metricsets:
          - system
        bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
      - id: >-
          kubernetes/metrics-kubernetes.volume-dfd54600-4141-11ee-b801-0987c2093460
        data_stream:
          dataset: kubernetes.volume
          type: metrics
        period: 10s
        condition: '${host.name} == ''testing'''
        add_metadata: true
        hosts:
          - 'https://${env.NODE_NAME}:10250'
        ssl.verification_mode: none
        metricsets:
          - volume
        bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token

packages/kubernetes/manifest.yml Show resolved Hide resolved
Comment on lines +41 to +43
description: |
Condition to filter when to collect this input. See [Dynamic Input Configuration](https://www.elastic.co/guide/en/fleet/current/dynamic-input-configuration.html) for details.
Note: This condition value will be appended to the individual metric condition values by an "and" clause if defined.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've expanded the description of this field a bit to highlight how this condition interacts with the individual metric conditions so people don't need to go looking/guess.

@BenB196 BenB196 requested a review from gizas August 22, 2023 23:28
@BenB196
Copy link
Contributor Author

BenB196 commented Sep 15, 2023

Hi @gizas, don't mean to pester, but was curious if there is anything blocking this PR from being reviewed/merged?

@BenB196
Copy link
Contributor Author

BenB196 commented Sep 21, 2023

Hi @MichaelKatsoulis @tetianakravchenko I see you're marked as a requested review on this PR. I don't mean to bother, but would it be possible to get the PR reviewed? Also, it looks like the test never was run on this PR.

It would be nice to have this PR merged as it would greatly reduce some operational overhead.

@elasticmachine
Copy link

elasticmachine commented Oct 21, 2023

🌐 Coverage report

Name Metrics % (covered/total) Diff
Packages 100.0% (1/1) 💚
Files 100.0% (1/1) 💚 3.79
Classes 100.0% (1/1) 💚 3.79
Methods 96.386% (80/83) 👍 4.0
Lines 100.0% (22/22) 💚 11.267
Conditionals 100.0% (0/0) 💚

@pierrehilbert pierrehilbert added the Team:Cloudnative-Monitoring Label for the Cloud Native Monitoring team [elastic/obs-cloudnative-monitoring] label Nov 10, 2023
@pierrehilbert
Copy link
Contributor

@MichaelKatsoulis @tetianakravchenko could you please have a look?

Copy link
Contributor

@MichaelKatsoulis MichaelKatsoulis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@MichaelKatsoulis MichaelKatsoulis merged commit 367dc62 into elastic:main Nov 10, 2023
3 checks passed
@elasticmachine
Copy link

Package kubernetes - 1.54.0 containing this change is available at https://epr.elastic.co/search?package=kubernetes

@BenB196 BenB196 deleted the kubernetes-condition branch November 29, 2023 12:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Integration:kubernetes Kubernetes Team:Cloudnative-Monitoring Label for the Cloud Native Monitoring team [elastic/obs-cloudnative-monitoring]
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants