Menu
Grafana Cloud

Configure Windows Exporter to monitor Windows Nodes

Kubernetes Monitoring supports monitoring Windows Nodes within an AWS EKS cluster and then send to Grafana Cloud the following data for each Node:

  • CPU
  • Memory
  • Storage

To configure monitoring for Windows Nodes, complete the following instructions.

Before you begin

Prior to the configuration steps, you must:

  1. Configure Kubernetes Monitoring on your Cluster.

  2. Enable Windows support for your Amazon EKS cluster.

  3. Ensure you have appropriate versions of items related to:

    • kube-state-metrics: Uses client-go to communicate with Clusters. For Kubernetes client-go version compatibility and any other related details, refer to kube-state-metrics.
    • OpenCost: Requires Kubernetes 1.8+ clusters.
    • Windows Exporter: Requires Kubernetes 1.22+. Refer to windows_exporter on Kubernetes for any additional requirements.

Configure Kubernetes Monitoring to monitor Windows Nodes

To set up monitoring for Windows Nodes:

  1. Install the windows-exporter Daemonset.

  2. Create the windows-exporter ServiceMonitor.

Install windows-exporter with appropriate collectors

Install the windows-exporter Daemonset, which deploys to every Windows Node on the cluster to ensure metrics are available to be scraped.

The image specified in initContainers must match the version of Windows that is running on the Node, such as ltsc2019. For more information, refer to the tag list.

Install the following file:

yaml
cat <<'EOF' | kubectl apply -f -
apiVersion: apps/v1
kind: DaemonSet
metadata:
  labels:
    app: windows-exporter
  name: windows-exporter
  namespace: default
spec:
  selector:
    matchLabels:
      app: windows-exporter
  template:
    metadata:
      labels:
        app: windows-exporter
    spec:
      securityContext:
        windowsOptions:
          hostProcess: true
          runAsUserName: "NT AUTHORITY\\system"
      hostNetwork: true
      initContainers:
        - name: configure-firewall
          image: mcr.microsoft.com/windows/nanoserver:ltsc2019
          command: ["powershell"]
          args: ["New-NetFirewallRule", "-DisplayName", "'windows-exporter'", "-Direction", "inbound", "-Profile", "Any", "-Action", "Allow", "-LocalPort", "9182", "-Protocol", "TCP"]
      containers:
      - args:
        - --config.file=%CONTAINER_SANDBOX_MOUNT_POINT%/config.yml
        name: windows-exporter
        image: ghcr.io/prometheus-community/windows-exporter:latest
        imagePullPolicy: Always
        ports:
        - containerPort: 9182
          hostPort: 9182
          name: http
        volumeMounts:
        - name:  windows-exporter-config
          mountPath: /config.yml
          subPath: config.yml
      nodeSelector:
        kubernetes.io/os: windows
      volumes:
      - name: windows-exporter-config
        configMap:
          name: windows-exporter-config
---
kind: ConfigMap
apiVersion: v1
metadata:
  name: windows-exporter-config
  namespace: default
  labels:
    app: windows-exporter
data:
  config.yml: |
    collectors:
      enabled: cpu,cs,container,logical_disk,memory,net,os
    collector:
      service:
        services-where: "Name='containerd' or Name='kubelet'"

EOF

Create windows-exporter service monitor

Create a windows-exporter service and ServiceMonitor to:

  • Scrape the available metrics.
  • Ensure compatibility with Kubernetes Monitoring by using relabeling rules.

Install the following file:

yaml
cat <<'EOF' | kubectl apply -f -
apiVersion: v1
kind: Service
metadata:
  name: windows-exporter
  labels:
    name: windows-exporter
spec:
  selector:
    app: windows-exporter
  ports:
  - name: http
    protocol: TCP
    port: 9182
    targetPort: 9182
---
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
  labels:
    instance: primary
  name: windows-exporter
  namespace: default
spec:
  endpoints:
    - honorLabels: true
      interval: 60s
      path: /metrics
      port: http
      relabelings:
        - replacement: integrations/kubernetes/windows-exporter
          targetLabel: job
        - sourceLabels: [__meta_kubernetes_pod_node_name]
          targetLabel: instance
      metricRelabelings:
        - action: replace
          replacement: node_cpu_seconds_total
          regex: windows_cpu_time_total
          sourceLabels: [__name__]
          targetLabel: __name__
        - action: replace
          replacement: mountpoint
          regex: windows_logical_disk_size_bytes
          sourceLabels: [volume]
          targetLabel: mountpoint
        - action: replace
          replacement: node_filesystem_size_bytes
          regex: windows_logical_disk_size_bytes
          sourceLabels: [__name__]
          targetLabel: __name__
        - action: replace
          replacement: node_filesystem_avail_bytes
          regex: windows_logical_disk_free_bytes
          sourceLabels: [__name__]
          targetLabel: __name__
        - action: keep
          regex: windows_.*|node_cpu_seconds_total|node_filesystem_size_bytes|node_filesystem_avail_bytes|container_cpu_usage_seconds_total
          sourceLabels: [__name__]
      scheme: http
  namespaceSelector:
    matchNames:
      - default
  selector:
    matchLabels:
      name: windows-exporter

EOF

Done

To view the status of data collection, at Kubernetes Monitoring, click Configuration on the main menu, then click the Metrics status tab. Your data becomes populated as the system components begin scraping and sending data to Grafana Cloud. This view shows the health of the different sources of metrics, logs, and events, as well as any applicable version numbers.

Descriptions and statuses for each item chosen to be configured and whether they are online
Metrics status tab