# yaml-language-server: $schema=./values.schema.json
image:
  repository: docker.io/prom/graphite-exporter
  pullPolicy: IfNotPresent
  tag: v0.16.0@sha256:e54bca6645ea8a9e8c52312a8540de98ad08819d38476c021d77a0eae75bc797

service:
  main:
    ports:
      main:
        protocol: tcp
        port: 9109
      main-udp:
        enabled: true
        protocol: udp
        port: 9109
  metrics:
    enabled: true
    ports:
      metrics:
        enabled: true
        protocol: http
        port: 9108

workload:
  main:
    podSpec:
      containers:
        main:
          args:
            - "--graphite.mapping-config=/config/graphite_mapping.conf"

metrics:
  main:
    enabled: true
    targetSelector: metrics
    endpoints:
      - port: metrics

persistence:
  config:
    enabled: true
    type: configmap
    mountPath: /config/graphite_mapping.conf
    objectName: config
    readOnly: true
    subPath: graphite_mapping.conf

configmap:
  dashboard:
    enabled: true
    labels:
      grafana_dashboard: "1"
    data:
      truenasexporter.json: >-
        {{ .Files.Get "dashboard.json" | indent 8 }}
  config:
    enabled: true
    data:
      graphite_mapping.conf: >-
        mappings:

        ################################################
        # memory mapping
        ################################################

        - match: 'truenas\.(.*)\.system\.ram\.(.*)'
          match_type: "regex"
          name: "physical_memory"
          labels:
            job: "truenas"
            instance: "${1}"
            kind: "${2}"

        - match: 'truenas\.(.*)\.mem\.(.*)\.(.*)'
          match_type: "regex"
          name: "memory_${2}"
          labels:
            job: "truenas"
            instance: "${1}"
            kind: "${3}"

        - match: 'truenas\.(.*)\.system\.swap\.(.*)'
          match_type: "regex"
          name: "swap"
          labels:
            job: "truenas"
            instance: "${1}"
            kind: "${2}"

        ################################################
        # service mapping
        ################################################

        - match: 'truenas\.(.*)\.services\.cpu\.(.*)'
          match_type: "regex"
          name: "services_cpu"
          labels:
            job: "truenas"
            instance: "${1}"
            service: "${2}"

        - match: 'truenas\.(.*)\.services\.io_ops_read\.(.*)'
          match_type: "regex"
          name: "services_iops"
          labels:
            job: "truenas"
            instance: "${1}"
            op: "read"
            service: "${2}"

        - match: 'truenas\.(.*)\.services\.io_ops_write\.(.*)'
          match_type: "regex"
          name: "services_iops"
          labels:
            job: "truenas"
            instance: "${1}"
            op: "write"
            service: "${2}"

        - match: 'truenas\.(.*)\.services\.io_read\.(.*)'
          match_type: "regex"
          name: "services_io"
          labels:
            job: "truenas"
            instance: "${1}"
            op: "read"
            service: "${2}"

        - match: 'truenas\.(.*)\.services\.io_write\.(.*)'
          match_type: "regex"
          name: "services_io"
          labels:
            job: "truenas"
            instance: "${1}"
            op: "write"
            service: "${2}"

        - match: 'truenas\.(.*)\.services\.mem_usage\.(.*)'
          match_type: "regex"
          name: "services_mem"
          labels:
            job: "truenas"
            instance: "${1}"
            service: "${2}"

        ################################################
        # disk smart metrics
        ################################################

        - match: 'truenas\.(.*)\.smart\.log\.smart\.disktemp\.(.*)\.(.*)'
          match_type: "regex"
          name: "disk_temperature"
          labels:
            job: "truenas"
            instance: "${1}"
            serial: "${2}"

        - match: 'truenas\.(.*)\.smart_log_smart\.disktemp\.(.*)\.(.*)'
          match_type: "regex"
          name: "disk_temperature"
          labels:
            job: "truenas"
            instance: "${1}"
            serial: "${2}"

        ################################################
        # disk operation mappings
        ################################################

        - match: 'truenas\.(.*)\.disk\.(.*)\.(.*)'
          match_type: "regex"
          name: "disk_io"
          labels:
            job: "truenas"
            instance: "${1}"
            disk: "${2}"
            op: "${3}"

        - match: 'truenas\.(.*)\.disk_ops\.(.*)\.(.*)'
          match_type: "regex"
          name: "disk_io_ops"
          labels:
            job: "truenas"
            instance: "${1}"
            disk: "${2}"
            op: "${3}"

        - match: 'truenas\.(.*)\.disk_ext\.(.*)\.(.*)'
          match_type: "regex"
          name: "disk_io"
          labels:
            job: "truenas"
            instance: "${1}"
            disk: "${2}"
            op: "${3}"

        - match: 'truenas\.(.*)\.disk_ext_ops\.(.*)\.(.*)'
          match_type: "regex"
          name: "disk_io_ops"
          labels:
            job: "truenas"
            instance: "${1}"
            disk: "${2}"
            op: "${3}"

        - match: 'truenas\.(.*)\.disk_backlog\.(.*)\.backlog'
          match_type: "regex"
          name: "disk_io_backlog"
          labels:
            job: "truenas"
            instance: "${1}"
            disk: "${2}"

        - match: 'truenas\.(.*)\.disk_busy\.(.*)\.busy'
          match_type: "regex"
          name: "disk_busy"
          labels:
            job: "truenas"
            instance: "${1}"
            disk: "${2}"

        - match: 'truenas\.(.*)\.disk_util\.(.*)\.utilization'
          match_type: "regex"
          name: "disk_utilization"
          labels:
            job: "truenas"
            instance: "${1}"
            disk: "${2}"

        - match: 'truenas\.(.*)\.disk_mops\.(.*)\.(.*)'
          match_type: "regex"
          name: "disk_io"
          labels:
            job: "truenas"
            instance: "${1}"
            disk: "${2}"
            op: "merged_${3}"

        - match: 'truenas\.(.*)\.disk_ext_mops\.(.*)\.(.*)'
          match_type: "regex"
          name: "disk_io"
          labels:
            job: "truenas"
            instance: "${1}"
            disk: "${2}"
            op: "merged_${3}"

        - match: 'truenas\.(.*)\.disk_iotime\.(.*)\.(.*)'
          match_type: "regex"
          name: "disk_iotime"
          labels:
            job: "truenas"
            instance: "${1}"
            disk: "${2}"
            op: "${3}"

        - match: 'truenas\.(.*)\.disk_ext_iotime\.(.*)\.(.*)'
          match_type: "regex"
          name: "disk_iotime"
          labels:
            job: "truenas"
            instance: "${1}"
            disk: "${2}"
            op: "${3}"

        - match: 'truenas\.(.*)\.disk_qops\.(.*)\.operations'
          match_type: "regex"
          name: "disk_qops"
          labels:
            job: "truenas"
            instance: "${1}"
            disk: "${2}"

        - match: 'truenas\.(.*)\.disk_await\.(.*)\.(.*)'
          match_type: "regex"
          name: "disk_await"
          labels:
            job: "truenas"
            instance: "${1}"
            disk: "${2}"
            op: "${3}"

        - match: 'truenas\.(.*)\.disk_ext_await\.(.*)\.(.*)'
          match_type: "regex"
          name: "disk_await"
          labels:
            job: "truenas"
            instance: "${1}"
            disk: "${2}"
            op: "${3}"

        - match: 'truenas\.(.*)\.disk_avgsz\.(.*)\.(.*)'
          match_type: "regex"
          name: "disk_io_size"
          labels:
            job: "truenas"
            instance: "${1}"
            disk: "${2}"
            op: "${3}"

        - match: 'truenas\.(.*)\.disk_ext_avgsz\.(.*)\.(.*)'
          match_type: "regex"
          name: "disk_io_size"
          labels:
            job: "truenas"
            instance: "${1}"
            disk: "${2}"
            op: "${3}"

        - match: 'truenas\.(.*)\.disk_svctm\.(.*)\.svctm'
          match_type: "regex"
          name: "disk_svctm"
          labels:
            job: "truenas"
            instance: "${1}"
            disk: "${2}"

        - match: 'truenas\.(.*)\.system\.io\.(.*)'
          match_type: "regex"
          name: "system_io"
          labels:
            job: "truenas"
            instance: "${1}"
            op: "${2}"

        ################################################
        # CPU mapping
        ################################################

        - match: 'truenas\.(.*)\.system\.intr\.interrupts'
          match_type: "regex"
          name: "interrupts"
          labels:
            job: "truenas"
            instance: "${1}"
            kind: "hard"

        - match: 'truenas\.(.*)\.system\.cpu\.softirq'
          match_type: "regex"
          name: "interrupts"
          labels:
            job: "truenas"
            instance: "${1}"
            kind: "soft"

        - match: 'truenas\.(.*)\.cpu\.(.*)\.softirq'
          match_type: "regex"
          name: "cpu_softirq"
          labels:
            job: "truenas"
            instance: "${1}"
            cpu: "${2}"

        - match: 'truenas\.(.*)\.system\.ctxt\.switches'
          match_type: "regex"
          name: "context_switches"
          labels:
            job: "truenas"
            instance: "${1}"

        - match: 'truenas\.(.*)\.system\.cpu\.(.*)'
          match_type: "regex"
          name: "cpu_total"
          labels:
            job: "truenas"
            instance: "${1}"
            kind: "${2}"

        - match: 'truenas\.(.*)\.cputemp\.temperatures\.(.*)'
          match_type: "regex"
          name: "cpu_temperature"
          labels:
            job: "truenas"
            instance: "${1}"
            cpu: "cpu${2}"

        - match: 'truenas\.(.*)\.cpu\.core_throttling\.(.*)'
          match_type: "regex"
          name: "cpu_throttling"
          labels:
            job: "truenas"
            instance: "${1}"
            cpu: "${2}"

        - match: 'truenas\.(.*)\.cpu\.cpufreq\.(.*)'
          match_type: "regex"
          name: "cpu_frequency"
          labels:
            job: "truenas"
            instance: "${1}"
            cpu: "${2}"

        - match: 'truenas\.(.*)\.cpu\.(.*)_cpuidle\.(.*)'
          match_type: "regex"
          name: "cpu_idlestate"
          labels:
            job: "truenas"
            instance: "${1}"
            cpu: "${2}"
            state: "${3}"

        - match: 'truenas\.(.*)\.cpu\.(.*)\.(.*)'
          match_type: "regex"
          name: "cpu_usage"
          labels:
            job: "truenas"
            instance: "${1}"
            cpu: "${2}"
            kind: "${3}"

        ################################################
        # process mapping
        ################################################

        - match: 'truenas\.(.*)\.system\.forks\.started'
          match_type: "regex"
          name: "processes_forks"
          labels:
            job: "truenas"
            instance: "${1}"

        - match: 'truenas\.(.*)\.system\.processes\.(.*)'
          match_type: "regex"
          name: "processes"
          labels:
            job: "truenas"
            instance: "${1}"
            kind: "${2}"

        - match: 'truenas\.(.*)\.system\.active_processes\.(.*)'
          match_type: "regex"
          name: "processes"
          labels:
            job: "truenas"
            instance: "${1}"
            kind: "${2}"

        ################################################
        # uptime mapping
        ################################################

        - match: 'truenas\.(.*)\.system\.uptime\.uptime'
          match_type: "regex"
          name: "uptime"
          labels:
            job: "truenas"
            instance: "${1}"

        - match: 'truenas\.(.*)\.system\.clock_sync_state\.state'
          match_type: "regex"
          name: "clock_synced"
          labels:
            job: "truenas"
            instance: "${1}"

        - match: 'truenas\.(.*)\.system\.clock_status\.(.*)'
          match_type: "regex"
          name: "clock_status"
          labels:
            job: "truenas"
            instance: "${1}"
            state: "${2}"

        - match: 'truenas\.(.*)\.system\.clock_sync_offset\.offset'
          match_type: "regex"
          name: "clock_offset"
          labels:
            job: "truenas"
            instance: "${1}"

        ################################################
        # load mapping
        ################################################

        - match: 'truenas\.(.*)\.system\.load\.(.*)'
          match_type: "regex"
          name: "system_load"
          labels:
            job: "truenas"
            instance: "${1}"
            kind: "${2}"

        ################################################
        # nsfd mappings
        ################################################

        - match: 'truenas\.(.*)\.nfsd\.(.*)\.(.*)'
          match_type: "regex"
          name: "nfs_${2}"
          labels:
            job: "truenas"
            instance: "${1}"
            op: "${3}"

        ################################################
        # zfs mappings
        ################################################

        - match: 'truenas\.(.*)\.zfs\.(.*)\.(.*)'
          match_type: "regex"
          name: "zfs_${2}"
          labels:
            job: "truenas"
            instance: "${1}"
            op: "${3}"

        - match: 'truenas\.(.*)\.zfspool\.state_(.*)\.(.*)'
          match_type: "regex"
          name: "zfs_pool"
          labels:
            job: "truenas"
            instance: "${1}"
            pool: "${2}"
            state: "${3}"

        ################################################
        # network mappings
        ################################################

        - match: 'truenas\.(.*)\.net\.(.*)\.(.*)'
          match_type: "regex"
          name: "interface_io"
          labels:
            job: "truenas"
            instance: "${1}"
            interface: "${2}"
            op: "${3}"

        - match: 'truenas\.(.*)\.net_speed\.(.*)\.speed'
          match_type: "regex"
          name: "interface_speed"
          labels:
            job: "truenas"
            instance: "${1}"
            interface: "${2}"

        - match: 'truenas\.(.*)\.net_duplex\.(.*)\.(.*)'
          match_type: "regex"
          name: "interface_duplex"
          labels:
            job: "truenas"
            instance: "${1}"
            interface: "${2}"
            state: "${3}"

        - match: 'truenas\.(.*)\.net_operstate\.(.*)\.(.*)'
          match_type: "regex"
          name: "interface_operationstate"
          labels:
            job: "truenas"
            instance: "${1}"
            interface: "${2}"
            state: "${3}"

        - match: 'truenas\.(.*)\.net_carrier\.(.*)\.(.*)'
          match_type: "regex"
          name: "interface_carrierstate"
          labels:
            job: "truenas"
            instance: "${1}"
            interface: "${2}"
            state: "${3}"

        - match: 'truenas\.(.*)\.net_mtu\.(.*)\.mtu'
          match_type: "regex"
          name: "interface_mtu"
          labels:
            job: "truenas"
            instance: "${1}"
            interface: "${2}"

        - match: 'truenas\.(.*)\.net_packets\.(.*)\.(.*)'
          match_type: "regex"
          name: "interface_packets"
          labels:
            job: "truenas"
            instance: "${1}"
            interface: "${2}"
            op: "${3}"

        - match: 'truenas\.(.*)\.net_errors\.(.*)\.(.*)'
          match_type: "regex"
          name: "interface_errors"
          labels:
            job: "truenas"
            instance: "${1}"
            interface: "${2}"
            op: "${3}"

        - match: 'truenas\.(.*)\.net_drops\.(.*)\.(.*)'
          match_type: "regex"
          name: "interface_drops"
          labels:
            job: "truenas"
            instance: "${1}"
            interface: "${2}"
            op: "${3}"

        - match: 'truenas\.(.*)\.system\.net\.(.*)'
          match_type: "regex"
          name: "system_net_io"
          labels:
            job: "truenas"
            instance: "${1}"
            op: "${2}"

        ################################################
        # k3s mappings
        ################################################

        - match: 'truenas\.(.*)\.k3s_stats\.k3s_pod_stats\.(.*)\.cpu'
          match_type: "regex"
          name: "k3s_pod_cpu"
          labels:
            job: "truenas"
            instance: "${1}"
            pod: "${2}"

        - match: 'truenas\.(.*)\.k3s_stats\.k3s_pod_stats\.(.*)\.mem'
          match_type: "regex"
          name: "k3s_pod_mem"
          labels:
            job: "truenas"
            instance: "${1}"
            pod: "${2}"

        - match: 'truenas\.(.*)\.k3s_stats\.k3s_pod_stats\.(.*)\.net\.(.*)'
          match_type: "regex"
          name: "k3s_pod_net"
          labels:
            job: "truenas"
            instance: "${1}"
            pod: "${2}"
            direction: "${3}"

        ################################################
        # cgroup mappings
        ################################################

        - match: 'truenas\.(.*)\.(.*)\.cpu_full_pressure\.(.*)'
          match_type: "regex"
          name: "cgroup_cpu_full_pressure"
          labels:
            job: "truenas"
            dimension: "${3}"
            instance: "${1}"
            cgroup: "${2}"
            unit: "percent"

        - match: 'truenas\.(.*)\.(.*)\.cpu_full_pressure_stall_time\.time'
          match_type: "regex"
          name: "cgroup_cpu_full_pressure_stall_time"
          labels:
            job: "truenas"
            dimension: "${3}"
            instance: "${1}"
            cgroup: "${2}"
            unit: "ms"

        - match: 'truenas\.(.*)\.(.*)\.cpu_limit\.used'
          match_type: "regex"
          name: "cgroup_cpu_limit"
          labels:
            job: "truenas"
            instance: "${1}"
            cgroup: "${2}"
            unit: "percent"

        - match: 'truenas\.(.*)\.(.*)\.cpu_some_pressure\.(.*)'
          match_type: "regex"
          name: "cgroup_cpu_some_pressure"
          labels:
            job: "truenas"
            dimension: "${3}"
            instance: "${1}"
            cgroup: "${2}"
            unit: "percent"

        - match: 'truenas\.(.*)\.(.*)\.cpu_some_pressure_stall_time\.time'
          match_type: "regex"
          name: "cgroup_cpu_some_pressure_stall_time"
          labels:
            job: "truenas"
            dimension: "${3}"
            instance: "${1}"
            cgroup: "${2}"
            unit: "ms"

        - match: 'truenas\.(.*)\.(.*)\.cpu\.(.*)'
          match_type: "regex"
          name: "cgroup_cpu_usage"
          labels:
            job: "truenas"
            type: "${3}"
            instance: "${1}"
            cgroup: "${2}"
            unit: "percent"

        - match: 'truenas\.(.*)\.(.*)\.io_full_pressure\.(.*)'
          match_type: "regex"
          name: "cgroup_io_full_pressure"
          labels:
            job: "truenas"
            dimension: "${3}"
            instance: "${1}"
            cgroup: "${2}"
            unit: "percent"

        - match: 'truenas\.(.*)\.(.*)\.io_full_pressure_stall_time\.time'
          match_type: "regex"
          name: "cgroup_io_full_pressure_stall_time"
          labels:
            job: "truenas"
            dimension: "${3}"
            instance: "${1}"
            cgroup: "${2}"
            unit: "ms"

        - match: 'truenas\.(.*)\.(.*)\.io_some_pressure\.(.*)'
          match_type: "regex"
          name: "cgroup_io_some_pressure"
          labels:
            job: "truenas"
            dimension: "${3}"
            instance: "${1}"
            cgroup: "${2}"
            unit: "percent"

        - match: 'truenas\.(.*)\.(.*)\.io_some_pressure_stall_time\.time'
          match_type: "regex"
          name: "cgroup_io_some_pressure_stall_time"
          labels:
            job: "truenas"
            dimension: "${3}"
            instance: "${1}"
            cgroup: "${2}"
            unit: "ms"

        - match: 'truenas\.(.*)\.(.*)\.mem_full_pressure\.(.*)'
          match_type: "regex"
          name: "cgroup_mem_full_pressure"
          labels:
            job: "truenas"
            dimension: "${3}"
            instance: "${1}"
            cgroup: "${2}"
            unit: "percent"

        - match: 'truenas\.(.*)\.(.*)\.mem_full_pressure_stall_time\.time'
          match_type: "regex"
          name: "cgroup_mem_full_pressure_stall_time"
          labels:
            job: "truenas"
            dimension: "${3}"
            instance: "${1}"
            cgroup: "${2}"
            unit: "ms"

        - match: 'truenas\.(.*)\.(.*)\.mem_some_pressure\.(.*)'
          match_type: "regex"
          name: "cgroup_mem_some_pressure"
          labels:
            job: "truenas"
            dimension: "${3}"
            instance: "${1}"
            cgroup: "${2}"
            unit: "percent"

        - match: 'truenas\.(.*)\.(.*)\.mem_some_pressure_stall_time\.time'
          match_type: "regex"
          name: "cgroup_mem_some_pressure_stall_time"
          labels:
            job: "truenas"
            dimension: "${3}"
            instance: "${1}"
            cgroup: "${2}"
            unit: "ms"

        - match: 'truenas\.(.*)\.(.*)\.mem_usage\.(.*)'
          match_type: "regex"
          name: "cgroup_mem_usage"
          labels:
            job: "truenas"
            type: "${3}"
            instance: "${1}"
            cgroup: "${2}"
            unit: "MiB"

        - match: 'truenas\.(.*)\.(.*)\.mem_usage_limit\.(.*)'
          match_type: "regex"
          name: "cgroup_mem_usage_limit"
          labels:
            job: "truenas"
            type: "${3}"
            instance: "${1}"
            cgroup: "${2}"
            unit: "MiB"

        - match: 'truenas\.(.*)\.(.*)\.mem_utilization'
          match_type: "regex"
          name: "cgroup_mem_utilization"
          labels:
            job: "truenas"
            instance: "${1}"
            cgroup: "${2}"
            unit: "percent"

        - match: 'truenas\.(.*)\.(.*)\.pgfaults\.(.*)'
          match_type: "regex"
          name: "cgroup_pgfaults"
          labels:
            job: "truenas"
            type: "${3}"
            instance: "${1}"
            cgroup: "${2}"
            unit: "MiB/s"

        - match: 'truenas\.(.*)\.(.*)\.throttled'
          match_type: "regex"
          name: "cgroup_cpu_throttled"
          labels:
            job: "truenas"
            instance: "${1}"
            cgroup: "${2}"
            unit: "percent"

        - match: 'truenas\.(.*)\.(.*)\.throttled_duration'
          match_type: "regex"
          name: "cgroup_cpu_throttled_duration"
          labels:
            job: "truenas"
            instance: "${1}"
            cgroup: "${2}"
            unit: "ms"

        - match: 'truenas\.(.*)\.(.*)\.writeback\.(.*)'
          match_type: "regex"
          name: "cgroup_writeback"
          labels:
            job: "truenas"
            type: "${3}"
            instance: "${1}"
            cgroup: "${2}"
            unit: "MiB"
