Use node-exporter textfile collector with prometheus-community helm chart

89 Views Asked by At

Using this Helm chart https://github.com/prometheus-community/helm-charts/tree/main/charts/prometheus-node-exporter

I would like to use the textfile collector, in order to export a directory size.

I understand I must use a CRON but how?

My config map with the script:

apiVersion: v1
kind: ConfigMap
metadata:
  name: node-exporter-custom-metrics
data:
  script.sh: |
    #!/bin/sh

    echo '# HELP node_file_size_bytes Size of specified folder in kilobytes'
    echo '# TYPE node_file_size_bytes gauge'
    echo 'node_file_size_bytes {path="/var/log"} '$(du -s /var/log 2>/dev/null | cut -f1)
    echo 'node_file_size_bytes {path="/var/lib/kubelet"} '$(du -s /var/lib/kubelet 2>/dev/null | cut -f1)
    echo 'node_file_size_bytes {path="/var/lib/containerd"} '$(du -s /var/lib/containerd 2>/dev/null | cut -f1)

  cron: |
    * * * * * /var/lib/node_exporter/custom_metrics/script.sh

My values.yaml

  prometheus-node-exporter:

    configmaps:
    - name: node-exporter-custom-metrics
      mountPath: /var/lib/node_exporter/custom_metrics

    extraArgs:
      - --collector.textfile.directory=/var/lib/node_exporter/custom_metrics
0

There are 0 best solutions below