HUB
Sign inSign up
vastnfs-exporter logo

vastdataorg/vastnfs-exporter

By vastdataorg

•Updated 2 days ago

Image
0

179

vastdataorg/vastnfs-exporter repository overview

⁠VastNFS Exporter

Docker Image Version

⁠Introduction

This image runs the VastNFS Prometheus exporter, an HTTP server that exposes VastNFS RPC transport statistics for Prometheus. It runs on NFS client hosts (the hosts that mount VastNFS exports) and reads kernel debugfs/sysfs; the NFS server is out of scope.

The exporter mirrors the discovery logic of vastnfs-ctl: it walks VastNFS mount RPC transports and publishes per-operation counters (same source as vastnfs-ctl rpc-transports-stats), live per-transport queue depths (same sysfs fields as vastnfs-ctl rpc-transports), transport state flags, and per-mount configuration.

Published as vastdataorg/vastnfs-exporter. The latest tag tracks the most recent GA release; pin a specific version with vastdataorg/vastnfs-exporter:TAG. Images are multi-arch (linux/amd64, linux/arm64).

The exporter reports on the VastNFS kernel module installed on the host. The module is not part of this image and must be installed on the node separately.

⁠Quick start

The container must see the host network namespace and the host's debugfs and sunrpc sysfs trees (read-only):

docker run -d --name vastnfs-exporter --network host --pid host \
  --read-only --cap-drop ALL --security-opt no-new-privileges \
  -v /sys/kernel/debug:/sys/kernel/debug:ro \
  -v /sys/kernel/sunrpc:/sys/kernel/sunrpc:ro \
  vastdataorg/vastnfs-exporter:latest

curl -s localhost:9001/metrics | head

The container runs as root with all capabilities dropped, so it can traverse the root-owned debugfs files without any additional privilege.

--pid host lets the exporter read the host's mount table (/proc/1/mountinfo) to label each VastNFS mount with its mount point and options. Without it the container only sees its own mount namespace, and vastnfs_mount_info and vastnfs_exporter_mount_count stay empty.

To run it on Kubernetes, see Deploy as a Kubernetes DaemonSet⁠.

⁠Deploy as a Kubernetes DaemonSet

Run one exporter pod on every node that mounts VastNFS exports. The pod needs the host network namespace (so Prometheus scrapes the node address) and read-only hostPath mounts of the host's debugfs and sunrpc sysfs trees.

Save the following as vastnfs-exporter.yaml:

apiVersion: v1
kind: Namespace
metadata:
  name: vastnfs-exporter
  labels:
    # hostNetwork, hostPath and root need the "privileged" Pod Security level.
    pod-security.kubernetes.io/enforce: privileged
---
apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: vastnfs-exporter
  namespace: vastnfs-exporter
spec:
  selector:
    matchLabels:
      app: vastnfs-exporter
  template:
    metadata:
      labels:
        app: vastnfs-exporter
      annotations:
        prometheus.io/scrape: "true"
        prometheus.io/port: "9001"
        prometheus.io/path: "/metrics"
    spec:
      # hostNetwork only affects how the exporter is *reached* (node IP + port
      # on the host vs. pod IP); it is not needed to read debugfs/sysfs, which
      # come from the hostPath mounts. Set to false to use the pod network.
      hostNetwork: true
      # Needed so /proc/1/mountinfo is the host's mount table (mountpoint and
      # options of the VastNFS mounts). Without it vastnfs_mount_info is empty.
      hostPID: true
      containers:
        - name: vastnfs-exporter
          image: docker.io/vastdataorg/vastnfs-exporter:latest
          env:
            - name: VASTNFS_EXPORTER_PORT
              valueFrom:
                fieldRef:
                  fieldPath: metadata.annotations['prometheus.io/port']
          securityContext:
            runAsUser: 0
            runAsGroup: 0
            allowPrivilegeEscalation: false
            readOnlyRootFilesystem: true
            capabilities:
              drop:
                - ALL
          volumeMounts:
            - name: debugfs
              mountPath: /sys/kernel/debug
              readOnly: true
            - name: sysfs-sunrpc
              mountPath: /sys/kernel/sunrpc
              readOnly: true
      volumes:
        - name: debugfs
          hostPath:
            path: /sys/kernel/debug
            type: Directory
        - name: sysfs-sunrpc
          hostPath:
            path: /sys/kernel/sunrpc
            type: Directory

Apply it and verify:

kubectl apply -f vastnfs-exporter.yaml
kubectl -n vastnfs-exporter rollout status ds/vastnfs-exporter
kubectl -n vastnfs-exporter get pods -o wide

# Scrape one node directly (replace NODE_IP)
curl -s NODE_IP:9001/metrics | head

Notes:

  • VastNFS must be installed on the nodes. The pod mounts /sys/kernel/sunrpc, which only exists once the sunrpc module is loaded. On a node without it the pod stays in ContainerCreating. Restrict the DaemonSet to nodes that run VastNFS with a nodeSelector (for example a label you apply to those nodes) in the pod spec.

  • Pod Security. hostNetwork, hostPath and running as root require the privileged Pod Security level, which is why the namespace carries the pod-security.kubernetes.io/enforce: privileged label. The container itself drops all capabilities, forbids privilege escalation and uses a read-only root filesystem.

  • Host PID is required for mount labels. hostPID: true makes /proc/1/mountinfo the node's mount table, which is how the exporter finds each VastNFS mount's mount point and options. Without it the pod sees only its own mounts, and vastnfs_mount_info and vastnfs_exporter_mount_count stay empty (RPC transport metrics are unaffected). The container still drops all capabilities. If a security policy (for example an AppArmor or SELinux profile) blocks reading /proc/1/mountinfo, the exporter falls back to its own table and the mount labels stay empty.

  • Host network is optional. The exporter reads its data from the hostPath mounts, not from the network namespace, so hostNetwork only decides how Prometheus reaches it. With hostNetwork: true (the default here, like node_exporter) the exporter listens on the node's IP and the port must be free on every node; it is also reachable on every node interface, so restrict access with a host firewall if needed. With hostNetwork: false it gets a pod IP, there are no host port conflicts, and NetworkPolicy can limit who scrapes it. Switch with:

    kubectl -n vastnfs-exporter patch ds/vastnfs-exporter --type merge -p \
      '{"spec":{"template":{"spec":{"hostNetwork":false}}}}'
    

    Either way the pod still needs the privileged Pod Security level because of the hostPath mounts and root user.

  • Changing the port. The pod annotation prometheus.io/port is the single source of truth: it is passed to the container as VASTNFS_EXPORTER_PORT through the downward API, and Prometheus uses the same annotation to find the target. Change that one value, for example:

    kubectl -n vastnfs-exporter patch ds/vastnfs-exporter --type merge -p \
      '{"spec":{"template":{"metadata":{"annotations":{"prometheus.io/port":"9100"}}}}}'
    

    The pod uses the host network, so make sure the port is free on every node.

  • Pinning the version. Replace :latest with a specific tag for reproducible rollouts.

  • Scraping with Prometheus. With annotation-based discovery (the default kubernetes-pods scrape config) the prometheus.io/* annotations are all that is needed. With the Prometheus Operator, create a PodMonitor selecting app: vastnfs-exporter in the vastnfs-exporter namespace with podMetricsEndpoints on the /metrics path and the port you configured.

  • Tolerations. Add tolerations to the pod spec if the nodes that mount VastNFS are tainted.

⁠Configuration

The listen address and port are set at deployment time through environment variables. Command-line flags take precedence over the environment.

Environment variableFlagDefaultDescription
VASTNFS_EXPORTER_HOST--host0.0.0.0Listen address
VASTNFS_EXPORTER_PORT--port9001Listen port
VASTNFS_EXPORTER_MOUNTINFO–/proc/1/mountinfo in the image (/proc/self/mountinfo otherwise)Mount table used for mount point and options labels; falls back to /proc/self/mountinfo if unreadable
–--shutdown-timeout5Grace period after SIGTERM/SIGINT before exit (seconds)

For example, to listen on port 9100:

docker run -d --network host -e VASTNFS_EXPORTER_PORT=9100 ... vastdataorg/vastnfs-exporter:latest

Because the container uses the host network, the effective port is whatever VASTNFS_EXPORTER_PORT is set to; the EXPOSE 9001 in the image only documents the default. In a Kubernetes DaemonSet, set the port in one place (for example from the prometheus.io/port pod annotation via the downward API) so the exporter and the Prometheus scrape configuration always agree.

Endpoints:

PathDescription
/metricsPrometheus text exposition
/Minimal health/index body

⁠Prerequisites

The exporter reads kernel debugfs and sysfs, not /proc mountstats. debugfs must be mounted on the host at /sys/kernel/debug (most distributions do this at boot):

mount | grep debugfs
ls /sys/kernel/debug/vastnfs

If debugfs is not mounted, RPC metrics stay empty and vastnfs_exporter_vastnfs_present is 0. Mount it manually if needed:

sudo mount -t debugfs none /sys/kernel/debug

Paths the exporter uses:

PathFilesystemRole
/sys/kernel/debug/vastnfs/nfs_sb/*debugfsIdentify VastNFS mounts (not present in upstream Linux NFS)
/sys/kernel/debug/vastnfs/nfs_clnt/*debugfsMap NFS clients to rpc_clnt IDs
/sys/kernel/debug/sunrpc/rpc_xprt/*/extradebugfsPer-operation RPC counters
/sys/kernel/debug/sunrpc/rpc_xprt/*/infodebugfsTransport id, netid, addr, port labels
/sys/kernel/sunrpc/rpc-clients/, xprt-switches/sysfsTraverse RPC client → xprt-switch → transport IDs
/sys/kernel/sunrpc/xprt-switches/*/xprt*/xprt_statesysfsTransport state flags (CONNECTED, BOUND, etc.)
/sys/kernel/sunrpc/xprt-switches/*/xprt*/xprt_infosysfsLive queue depths

Discovery walks VastNFS NFS clients, resolves each to an RPC client and its transports via sysfs, then reads per-op counters from debugfs and queue depths and state flags from sysfs for those transports only.

⁠Metrics

The exporter uses a private Prometheus registry (no default python_* or process_* series).

⁠Labels

Per-transport labels used across RPC metrics:

LabelDescriptionExample
xprt_idKernel RPC transport ID2
netidRPC network IDtcp, rdma
addrRemote endpoint192.168.23.11:2049

RPC counter metrics add op (RPC operation name, e.g. READ, WRITE, GETATTR). Queue length gauges and vastnfs_rpc_xprt_state use only xprt_id, netid, and addr (state gauges also add state). Exporter-level state and self-observability metrics have no transport labels.

⁠RPC counters (per transport, per operation)

Each counter is a cumulative total with labels xprt_id, netid, addr, and op. All-zero per-op rows are omitted (same filter as vastnfs-ctl rpc-transports-stats).

MetricDescription
vastnfs_rpc_xprt_ops_totalTotal RPC operations
vastnfs_rpc_xprt_trans_totalTotal RPC transmissions
vastnfs_rpc_xprt_timeouts_totalTotal RPC timeouts
vastnfs_rpc_xprt_bytes_sent_totalTotal bytes sent
vastnfs_rpc_xprt_bytes_received_totalTotal bytes received
vastnfs_rpc_xprt_queue_milliseconds_totalCumulative queue wait time (ms); not an instantaneous queue depth
vastnfs_rpc_xprt_rtt_milliseconds_totalTotal round-trip time (ms)
vastnfs_rpc_xprt_execute_milliseconds_totalTotal execute time (ms)
vastnfs_rpc_xprt_errors_totalTotal RPC errors
⁠Queue length gauges (per transport)

Instantaneous queue depths for each VastNFS mount transport (gauges, not cumulative counters). Labels: xprt_id, netid, addr.

MetricSysfs fieldDescription
vastnfs_rpc_xprt_binding_queue_lengthbinding_q_lenTasks waiting for bind/rpcbind
vastnfs_rpc_xprt_sending_queue_lengthsending_q_lenTasks waiting to send
vastnfs_rpc_xprt_pending_queue_lengthpending_q_lenTasks in flight (awaiting reply)
vastnfs_rpc_xprt_backlog_queue_lengthbacklog_q_lenTasks waiting for a free request slot
vastnfs_rpc_xprt_tasks_queue_lengthtasks_queuelenTotal tasks associated with this transport

Queue gauges are omitted when xprt_info is unreadable or the kernel reports <closed> (disconnected transports). During reconnection a transport may show state flags (e.g. CONNECTING) while queue gauges are absent.

⁠Transport state

vastnfs_rpc_xprt_state is a gauge set to 1 for each active state flag on a transport; a transport in CONNECTED BOUND emits two series. Common state values: CONNECTED, BOUND, CONNECTING, CLOSE, DISCONN. Labels: xprt_id, netid, addr, state.

⁠Mount configuration

vastnfs_mount_info is a gauge 1 per mount. Labels: nfs_id, mountpoint, proto (effective transport), options (NFS mount options from the host mount table, see VASTNFS_EXPORTER_MOUNTINFO).

⁠State gauges (always emitted)
MetricValuesDescription
vastnfs_exporter_vastnfs_present0 or 11 when /sys/kernel/debug/vastnfs exists
vastnfs_exporter_mount_countintegerNumber of VastNFS mounts exported this scrape
vastnfs_exporter_xprt_countintegerNumber of VastNFS mount transports exported this scrape
⁠Self-observability
MetricTypeDescription
vastnfs_exporter_build_infoinfoBuild version (version label)
vastnfs_exporter_scrape_duration_secondsgaugeWall-clock time of the last collection
vastnfs_exporter_collection_errors_totalcounterFailed collection attempts

⁠Behavior when VastNFS or debugfs is absent

The exporter process stays up. /metrics always returns HTTP 200, never 5xx for collection failures. State gauges are always emitted so operators can tell why a scrape is empty:

Conditionvastnfs_exporter_vastnfs_presentvastnfs_exporter_xprt_countRPC metrics
debugfs not mounted / vastnfs not loaded00absent
vastnfs loaded, no mounts10absent
vastnfs loaded, mounts active1> 0present
Tag summary
Recent tags
Content type
Image
Digest
sha256:04b087cda…
Size
47.1 MB
Last updated
2 days ago
docker pull vastdataorg/vastnfs-exporter:latest