Skip to content

Commit

Permalink
Add Windows Exporter as a new optional metric source.
Browse files Browse the repository at this point in the history
Signed-off-by: Pete Wall <[email protected]>
Co-authored-by: Dennis <[email protected]>
  • Loading branch information
petewall and davhdavh committed Aug 2, 2023
1 parent 23cd5b1 commit 05f8671
Show file tree
Hide file tree
Showing 20 changed files with 40,865 additions and 75 deletions.
9 changes: 6 additions & 3 deletions charts/k8s-monitoring/Chart.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
dependencies:
- name: grafana-agent
repository: https://grafana.github.io/helm-charts
version: 0.18.0
version: 0.19.0
- name: kube-state-metrics
repository: https://prometheus-community.github.io/helm-charts
version: 5.10.1
Expand All @@ -11,8 +11,11 @@ dependencies:
- name: prometheus-operator-crds
repository: https://prometheus-community.github.io/helm-charts
version: 5.0.0
- name: prometheus-windows-exporter
repository: https://prometheus-community.github.io/helm-charts
version: 0.1.0
- name: opencost
repository: https://opencost.github.io/opencost-helm-chart
version: 1.18.0
digest: sha256:d645d1e833b182656a4ab8d55d3f171d35a7bf9d4d27df37202021fe2946eac9
generated: "2023-07-26T09:36:21.660604-05:00"
digest: sha256:50cebe3103d2b9b823dd783254de0640cd563a03b8dc020c3ffbae115ecdd7ac
generated: "2023-08-02T08:57:00.059065-05:00"
8 changes: 6 additions & 2 deletions charts/k8s-monitoring/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: k8s-monitoring
description: A Helm chart for gathering, scraping, and forwarding Kubernetes infrastructure metrics and logs to a Grafana Stack.
type: application

version: 0.0.12
version: 0.0.13
appVersion: 1.2.0
icon: https://raw.githubusercontent.com/grafana/grafana/main/public/img/grafana_icon.svg
maintainers:
Expand All @@ -13,7 +13,7 @@ maintainers:
name: skl
dependencies:
- name: grafana-agent
version: 0.18.0
version: 0.19.0
repository: https://grafana.github.io/helm-charts
- name: kube-state-metrics
version: 5.10.1
Expand All @@ -27,6 +27,10 @@ dependencies:
version: 5.0.0
repository: https://prometheus-community.github.io/helm-charts
condition: prometheus-operator-crds.enabled
- name: prometheus-windows-exporter
version: 0.1.0
repository: https://prometheus-community.github.io/helm-charts
condition: prometheus-windows-exporter.enabled
- name: opencost
version: 1.18.0
repository: https://opencost.github.io/opencost-helm-chart
Expand Down
18 changes: 16 additions & 2 deletions charts/k8s-monitoring/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# k8s-monitoring

![Version: 0.0.12](https://img.shields.io/badge/Version-0.0.12-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 1.2.0](https://img.shields.io/badge/AppVersion-1.2.0-informational?style=flat-square)
![Version: 0.0.13](https://img.shields.io/badge/Version-0.0.13-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 1.2.0](https://img.shields.io/badge/AppVersion-1.2.0-informational?style=flat-square)

A Helm chart for gathering, scraping, and forwarding Kubernetes infrastructure metrics and logs to a Grafana Stack.

Expand Down Expand Up @@ -55,11 +55,12 @@ The Prometheus and Loki services may be hosted on the same cluster, or remotely

| Repository | Name | Version |
|------------|------|---------|
| https://grafana.github.io/helm-charts | grafana-agent | 0.18.0 |
| https://grafana.github.io/helm-charts | grafana-agent | 0.19.0 |
| https://opencost.github.io/opencost-helm-chart | opencost | 1.18.0 |
| https://prometheus-community.github.io/helm-charts | kube-state-metrics | 5.10.1 |
| https://prometheus-community.github.io/helm-charts | prometheus-node-exporter | 4.21.0 |
| https://prometheus-community.github.io/helm-charts | prometheus-operator-crds | 5.0.0 |
| https://prometheus-community.github.io/helm-charts | prometheus-windows-exporter | 0.1.0 |

## Values

Expand Down Expand Up @@ -99,10 +100,15 @@ The Prometheus and Loki services may be hosted on the same cluster, or remotely
| metrics.node-exporter.service.isTLS | bool | `false` | Does this port use TLS? |
| metrics.podMonitors.enabled | bool | `true` | Include service discovery for PodMonitor objects |
| metrics.serviceMonitors.enabled | bool | `true` | Include service discovery for ServiceMonitor objects |
| metrics.windows-exporter.allowList | list | See [Allow List for Windows Exporter](#allow-list-for-windows-exporter) | The list of Windows Exporter metrics that will be scraped by the Agent |
| metrics.windows-exporter.enabled | bool | `false` | Scrape node metrics |
| metrics.windows-exporter.labelMatchers | object | `{"app.kubernetes.io/name":"prometheus-windows-exporter.*"}` | Label matchers used by the Grafana Agent to select the Windows Exporter pods |
| opencost.enabled | bool | `true` | Should this Helm chart deploy OpenCost to the cluster. Set this to false if your cluster already has OpenCost, or if you do not want to scrape metrics from OpenCost. |
| opencost.opencost.prometheus.external.url | string | `"https://prom.example.com/api/prom"` | The URL for Prometheus queries. It should match externalService.prometheus.host + "/api/prom" |
| prometheus-node-exporter.enabled | bool | `true` | Should this helm chart deploy Node Exporter to the cluster. Set this to false if your cluster already has Node Exporter, or if you do not want to scrape metrics from Node Exporter. |
| prometheus-operator-crds.enabled | bool | `true` | Should this helm chart deploy the Prometheus Operator CRDs to the cluster. Set this to false if your cluster already has the CRDs, or if you do not to have the Grafana Agent scrape metrics from PodMonitors or ServiceMonitors. |
| prometheus-windows-exporter.config | string | `"collectors:\n enabled: cpu,cs,container,logical_disk,memory,net,os\ncollector:\n service:\n services-where: \"Name='containerd' or Name='kubelet'\""` | |
| prometheus-windows-exporter.enabled | bool | `false` | Should this helm chart deploy Windows Exporter to the cluster. Set this to false if your cluster already has Windows Exporter, or if you do not want to scrape metrics from Windows Exporter. |

## Customizing the configuration

Expand Down Expand Up @@ -264,6 +270,14 @@ Visit the Kube State Metrics [documentation](https://github.com/kubernetes/kube-
* process_cpu_seconds_total
* process_resident_memory_bytes

### Allow List for Windows Exporter

* windows_.*
* node_cpu_seconds_total
* node_filesystem_size_bytes
* node_filesystem_avail_bytes
* container_cpu_usage_seconds_total

### Allow List for Kubelet

Visit the Kubelet [documentation](https://github.com/kubernetes/kubernetes/blob/master/test/instrumentation/documentation/documentation.md) for the full list of metrics
Expand Down
7 changes: 7 additions & 0 deletions charts/k8s-monitoring/README.md.gotmpl
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,13 @@ Visit the Kube State Metrics [documentation](https://github.com/kubernetes/kube-
* process_cpu_seconds_total
* process_resident_memory_bytes

### Allow List for Windows Exporter

* windows_.*
* node_cpu_seconds_total
* node_filesystem_size_bytes
* node_filesystem_avail_bytes
* container_cpu_usage_seconds_total

### Allow List for Kubelet

Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
{{ define "agent.config.windows_exporter" }}
// Windows Exporter
discovery.relabel "windows_exporter" {
targets = discovery.kubernetes.pods.targets
{{- if (index .Values "prometheus-windows-exporter").enabled }}
rule {
source_labels = ["__meta_kubernetes_pod_label_app_kubernetes_io_instance"]
regex = "{{ .Release.Name }}"
action = "keep"
}
{{- end }}
rule {
source_labels = ["__meta_kubernetes_pod_container_port_name"]
regex = "metrics"
action = "keep"
}
{{- range $k, $v := (index .Values.metrics "windows-exporter").labelMatchers }}
rule {
source_labels = ["__meta_kubernetes_pod_label_{{ $k | replace "." "_" | replace "/" "_" }}"]
regex = "{{ $v }}"
action = "keep"
}
{{- end }}
rule {
source_labels = ["__meta_kubernetes_pod_node_name"]
action = "replace"
target_label = "instance"
}
rule {
source_labels = ["__name__"]
replacement = local.file.cluster_name.content
target_label = "cluster"
}
}

prometheus.scrape "windows_exporter" {
job_name = "integrations/kubernetes/windows-exporter"
targets = discovery.relabel.windows_exporter.output
forward_to = [prometheus.relabel.windows_exporter.receiver]
}

prometheus.relabel "windows_exporter" {
rule {
source_labels = ["__name__"]
regex = "windows_cpu_time_total"
replacement = "node_cpu_seconds_total"
target_label = "__name__"
}
rule {
source_labels = ["volume"]
regex = "windows_logical_disk_size_bytes"
replacement = "mountpoint"
target_label = "mountpoint"
}
rule {
source_labels = ["__name__"]
regex = "windows_logical_disk_size_bytes"
replacement = "node_filesystem_size_bytes"
target_label = "__name__"
}
rule {
source_labels = ["__name__"]
regex = "windows_logical_disk_free_bytes"
replacement = "node_filesystem_avail_bytes"
target_label = "__name__"
}
{{- if (index .Values.metrics "windows-exporter").allowList }}
rule {
source_labels = ["__name__"]
regex = "up|{{ join "|" (index .Values.metrics "windows-exporter").allowList }}"
action = "keep"
}
{{- end }}
forward_to = [prometheus.remote_write.grafana_cloud_prometheus.receiver]
}
{{ end }}
4 changes: 4 additions & 0 deletions charts/k8s-monitoring/templates/grafana-agent-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ data:
{{- include "agent.config.node_exporter" . | indent 4}}
{{- end }}

{{- if (index .Values.metrics "windows-exporter").enabled }}
{{- include "agent.config.windows_exporter" . | indent 4}}
{{- end }}

{{- if .Values.metrics.cost.enabled }}
{{- include "agent.config.opencost" . | indent 4}}
{{- end }}
Expand Down
51 changes: 49 additions & 2 deletions charts/k8s-monitoring/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,24 @@ metrics:
- process_cpu_seconds_total
- process_resident_memory_bytes

# Windows Node metrics from Windows Exporter
windows-exporter:
# -- Scrape node metrics
enabled: false

# -- Label matchers used by the Grafana Agent to select the Windows Exporter pods
labelMatchers:
app.kubernetes.io/name: prometheus-windows-exporter.*

# -- The list of Windows Exporter metrics that will be scraped by the Agent
# @default -- See [Allow List for Windows Exporter](#allow-list-for-windows-exporter)
allowList:
- windows_.*
- node_cpu_seconds_total
- node_filesystem_size_bytes
- node_filesystem_avail_bytes
- container_cpu_usage_seconds_total

# Cluster metrics from the Kubelet
kubelet:
# -- Scrape cluster metrics from the Kubelet
Expand Down Expand Up @@ -267,26 +285,51 @@ logs:
extraConfig:

# Settings for the Kube State Metrics deployment
# You can use this sections to make modifications to the Kube State Metrics deployment.
# See https://github.com/prometheus-community/helm-charts/tree/main/charts/kube-state-metrics for available values.
kube-state-metrics:
# -- Should this helm chart deploy Kube State Metrics to the cluster.
# Set this to false if your cluster already has Kube State Metrics, or if you
# do not want to scrape metrics from Kube State Metrics.
enabled: true

# Settings for the Node Exporter deployment
# You can use this sections to make modifications to the Node Exporter deployment.
# See https://github.com/prometheus-community/helm-charts/tree/main/charts/prometheus-node-exporter for available values.
prometheus-node-exporter:
# -- Should this helm chart deploy Node Exporter to the cluster.
# Set this to false if your cluster already has Node Exporter, or if you do
# not want to scrape metrics from Node Exporter.
enabled: true

# Settings for the Windows Exporter deployment
# You can use this sections to make modifications to the Windows Exporter deployment.
# See https://github.com/prometheus-community/helm-charts/tree/main/charts/prometheus-windows-exporter for available values.
prometheus-windows-exporter:
# -- Should this helm chart deploy Windows Exporter to the cluster.
# Set this to false if your cluster already has Windows Exporter, or if you do
# not want to scrape metrics from Windows Exporter.
enabled: false

config: |-
collectors:
enabled: cpu,cs,container,logical_disk,memory,net,os
collector:
service:
services-where: "Name='containerd' or Name='kubelet'"
# Settings for the Prometheus Operator CRD deployment
# You can use this sections to make modifications to the Prometheus Operator CRD deployment.
# See https://github.com/prometheus-community/helm-charts/tree/main/charts/prometheus-operator-crds for available values.
prometheus-operator-crds:
# -- Should this helm chart deploy the Prometheus Operator CRDs to the cluster.
# Set this to false if your cluster already has the CRDs, or if you do not
# to have the Grafana Agent scrape metrics from PodMonitors or ServiceMonitors.
enabled: true

# Settings for the OpenCost deployment
# You can use this sections to make modifications to the OpenCost deployment.
# See https://github.com/opencost/opencost-helm-chart for available values.
opencost:
# -- Should this Helm chart deploy OpenCost to the cluster.
# Set this to false if your cluster already has OpenCost, or if you do
Expand Down Expand Up @@ -328,8 +371,9 @@ opencost:
# @ignored
enabled: false

# Settings for the Grafana Agent.
# For typical deployments, these settings can stay the way they are.
# Settings for the Grafana Agent deployment
# You can use this sections to make modifications to the Grafana Agent deployment.
# See https://github.com/grafana/agent/tree/main/operations/helm/charts/grafana-agent for available values.
# @ignored
grafana-agent:
agent:
Expand All @@ -345,6 +389,9 @@ grafana-agent:
mountPath: /etc/grafana-agent-credentials

controller:
nodeSelector:
kubernetes.io/os: linux

# This chart creates the credentials for Prometheus and Loki. This section
# connects those credentials into the Grafana Agent pod.
volumes:
Expand Down
24 changes: 13 additions & 11 deletions examples/custom-allow-lists/output.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ kind: ServiceAccount
metadata:
name: k8smon-grafana-agent
labels:
helm.sh/chart: grafana-agent-0.18.0
helm.sh/chart: grafana-agent-0.19.0
app.kubernetes.io/name: grafana-agent
app.kubernetes.io/instance: k8smon
app.kubernetes.io/version: "v0.35.1"
app.kubernetes.io/version: "v0.35.2"
app.kubernetes.io/managed-by: Helm
---
# Source: k8s-monitoring/charts/kube-state-metrics/templates/serviceaccount.yaml
Expand Down Expand Up @@ -39387,10 +39387,10 @@ kind: ClusterRole
metadata:
name: k8smon-grafana-agent
labels:
helm.sh/chart: grafana-agent-0.18.0
helm.sh/chart: grafana-agent-0.19.0
app.kubernetes.io/name: grafana-agent
app.kubernetes.io/instance: k8smon
app.kubernetes.io/version: "v0.35.1"
app.kubernetes.io/version: "v0.35.2"
app.kubernetes.io/managed-by: Helm
rules:
# Rules which allow discovery.kubernetes to function.
Expand Down Expand Up @@ -39710,10 +39710,10 @@ kind: ClusterRoleBinding
metadata:
name: k8smon-grafana-agent
labels:
helm.sh/chart: grafana-agent-0.18.0
helm.sh/chart: grafana-agent-0.19.0
app.kubernetes.io/name: grafana-agent
app.kubernetes.io/instance: k8smon
app.kubernetes.io/version: "v0.35.1"
app.kubernetes.io/version: "v0.35.2"
app.kubernetes.io/managed-by: Helm
roleRef:
apiGroup: rbac.authorization.k8s.io
Expand Down Expand Up @@ -39773,10 +39773,10 @@ kind: Service
metadata:
name: k8smon-grafana-agent
labels:
helm.sh/chart: grafana-agent-0.18.0
helm.sh/chart: grafana-agent-0.19.0
app.kubernetes.io/name: grafana-agent
app.kubernetes.io/instance: k8smon
app.kubernetes.io/version: "v0.35.1"
app.kubernetes.io/version: "v0.35.2"
app.kubernetes.io/managed-by: Helm
spec:
type: ClusterIP
Expand Down Expand Up @@ -39872,10 +39872,10 @@ kind: DaemonSet
metadata:
name: k8smon-grafana-agent
labels:
helm.sh/chart: grafana-agent-0.18.0
helm.sh/chart: grafana-agent-0.19.0
app.kubernetes.io/name: grafana-agent
app.kubernetes.io/instance: k8smon
app.kubernetes.io/version: "v0.35.1"
app.kubernetes.io/version: "v0.35.2"
app.kubernetes.io/managed-by: Helm
spec:
minReadySeconds: 10
Expand All @@ -39892,7 +39892,7 @@ spec:
serviceAccountName: k8smon-grafana-agent
containers:
- name: grafana-agent
image: docker.io/grafana/agent:v0.35.1
image: docker.io/grafana/agent:v0.35.2
imagePullPolicy: IfNotPresent
args:
- run
Expand Down Expand Up @@ -39934,6 +39934,8 @@ spec:
cpu: 1m
memory: 5Mi
dnsPolicy: ClusterFirst
nodeSelector:
kubernetes.io/os: linux
volumes:
- name: config
configMap:
Expand Down
Loading

0 comments on commit 05f8671

Please sign in to comment.