{"id":17196278,"url":"https://github.com/dundee/disk_usage_exporter","last_synced_at":"2025-03-17T11:30:29.885Z","repository":{"id":37255917,"uuid":"355325800","full_name":"dundee/disk_usage_exporter","owner":"dundee","description":"Disk Usage Prometheus Exporter","archived":false,"fork":false,"pushed_at":"2024-02-28T22:09:43.000Z","size":156,"stargazers_count":84,"open_issues_count":1,"forks_count":15,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-16T11:11:21.653Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dundee.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-04-06T20:48:42.000Z","updated_at":"2025-03-03T19:24:37.000Z","dependencies_parsed_at":"2024-06-19T00:16:24.225Z","dependency_job_id":"784d23a7-48da-4c68-b914-72ac2be599d8","html_url":"https://github.com/dundee/disk_usage_exporter","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dundee%2Fdisk_usage_exporter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dundee%2Fdisk_usage_exporter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dundee%2Fdisk_usage_exporter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dundee%2Fdisk_usage_exporter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dundee","download_url":"https://codeload.github.com/dundee/disk_usage_exporter/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244025171,"owners_count":20385529,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-15T01:52:48.340Z","updated_at":"2025-03-17T11:30:29.575Z","avatar_url":"https://github.com/dundee.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Disk Usage Prometheus Exporter\n\n[![Build Status](https://travis-ci.com/dundee/disk_usage_exporter.svg?branch=master)](https://travis-ci.com/dundee/disk_usage_exporter)\n[![codecov](https://codecov.io/gh/dundee/disk_usage_exporter/branch/master/graph/badge.svg)](https://codecov.io/gh/dundee/disk_usage_exporter)\n[![Go Report Card](https://goreportcard.com/badge/github.com/dundee/disk_usage_exporter)](https://goreportcard.com/report/github.com/dundee/disk_usage_exporter)\n[![Maintainability](https://api.codeclimate.com/v1/badges/74d685f0c638e6109ab3/maintainability)](https://codeclimate.com/github/dundee/disk_usage_exporter/maintainability)\n[![CodeScene Code Health](https://codescene.io/projects/14689/status-badges/code-health)](https://codescene.io/projects/14689)\n\nProvides detailed info about disk usage of the selected filesystem path.\n\nUses [gdu](https://github.com/dundee/gdu) under the hood for the disk usage analysis.\n\n## Demo Grafana dashboard\n\nhttps://grafana.milde.cz/d/0TfJhs_Mz/disk-usage (credentials: grafana / gdu)\n\n## Usage\n\n```\nUsage:\n  disk_usage_exporter [flags]\n\nFlags:\n  -p, --analyzed-path string              Path where to analyze disk usage (default \"/\")\n      --basic-auth-users stringToString   Basic Auth users and their passwords as bcypt hashes (default [])\n  -b, --bind-address string               Address to bind to (default \"0.0.0.0:9995\")\n  -c, --config string                     config file (default is $HOME/.disk_usage_exporter.yaml)\n  -l, --dir-level int                     Directory nesting level to show (0 = only selected dir) (default 2)\n  -L, --follow-symlinks                   Follow symlinks for files, i.e. show the size of the file to which symlink points to (symlinks to directories are not followed)\n  -h, --help                              help for disk_usage_exporter\n  -i, --ignore-dirs strings               Absolute paths to ignore (separated by comma) (default [/proc,/dev,/sys,/run,/var/cache/rsnapshot])\n  -m, --mode string                       Expose method - either 'file' or 'http' (default \"http\")\n      --multi-paths stringToString        Multiple paths where to analyze disk usage, in format /path1=level1,/path2=level2,... (default [])\n  -f, --output-file string                Target file to store metrics in (default \"./disk-usage-exporter.prom\")\n```\n\nEither one path can be specified using `--analyzed-path` and `--dir-level` flags or multiple can be set\nusing `--multi-paths` flag:\n\n```bash\ndisk_usage_exporter --multi-paths=/home=2,/var=3\n```\n\n## Example output\n\n```\n# HELP node_disk_usage_bytes Disk usage of the directory/file\n# TYPE node_disk_usage_bytes gauge\nnode_disk_usage_bytes{path=\"/var/cache\"} 2.1766144e+09\nnode_disk_usage_bytes{path=\"/var/db\"} 20480\nnode_disk_usage_bytes{path=\"/var/dpkg\"} 8192\nnode_disk_usage_bytes{path=\"/var/empty\"} 4096\nnode_disk_usage_bytes{path=\"/var/games\"} 4096\nnode_disk_usage_bytes{path=\"/var/lib\"} 7.554709504e+09\nnode_disk_usage_bytes{path=\"/var/local\"} 4096\nnode_disk_usage_bytes{path=\"/var/lock\"} 0\nnode_disk_usage_bytes{path=\"/var/log\"} 4.247068672e+09\nnode_disk_usage_bytes{path=\"/var/mail\"} 0\nnode_disk_usage_bytes{path=\"/var/named\"} 4096\nnode_disk_usage_bytes{path=\"/var/opt\"} 4096\nnode_disk_usage_bytes{path=\"/var/run\"} 0\nnode_disk_usage_bytes{path=\"/var/snap\"} 1.11694848e+10\nnode_disk_usage_bytes{path=\"/var/spool\"} 16384\nnode_disk_usage_bytes{path=\"/var/tmp\"} 475136\n# HELP node_disk_usage_level_1_bytes Disk usage of the directory/file level 1\n# TYPE node_disk_usage_level_1_bytes gauge\nnode_disk_usage_level_1_bytes{path=\"/bin\"} 0\nnode_disk_usage_level_1_bytes{path=\"/boot\"} 1.29736704e+08\nnode_disk_usage_level_1_bytes{path=\"/etc\"} 1.3090816e+07\nnode_disk_usage_level_1_bytes{path=\"/home\"} 8.7081373696e+10\nnode_disk_usage_level_1_bytes{path=\"/lib\"} 0\nnode_disk_usage_level_1_bytes{path=\"/lib64\"} 0\nnode_disk_usage_level_1_bytes{path=\"/lost+found\"} 4096\nnode_disk_usage_level_1_bytes{path=\"/mnt\"} 4096\nnode_disk_usage_level_1_bytes{path=\"/opt\"} 2.979229696e+09\nnode_disk_usage_level_1_bytes{path=\"/root\"} 4096\nnode_disk_usage_level_1_bytes{path=\"/sbin\"} 0\nnode_disk_usage_level_1_bytes{path=\"/snap\"} 0\nnode_disk_usage_level_1_bytes{path=\"/srv\"} 4.988928e+06\nnode_disk_usage_level_1_bytes{path=\"/tmp\"} 1.3713408e+07\nnode_disk_usage_level_1_bytes{path=\"/usr\"} 1.8109427712e+10\nnode_disk_usage_level_1_bytes{path=\"/var\"} 2.5156793856e+10\n```\n\n## Example Prometheus queries\n\nDisk usage of `/var` directory:\n\n```\nsum(node_disk_usage_bytes{path=~\"/var.*\"})\n```\n\n## Example config files\n\n`~/.disk_usage_exporter.yaml`:\n```yaml\nanalyzed-path: /\nbind-address: 0.0.0.0:9995\ndir-level: 2\nignore-dirs:\n- /proc\n- /dev\n- /sys\n- /run\n```\n\n`~/.disk_usage_exporter.yaml`:\n```yaml\nanalyzed-path: /\nmode: file\noutput-file: ./disk-usage-exporter.prom\ndir-level: 2\nignore-dirs:\n- /proc\n- /dev\n- /sys\n- /run\n```\n\n`~/.disk_usage_exporter.yaml`:\n```yaml\nmulti-paths:\n  /home: 2\n  /var: 3\n  /tmp: 1\nbind-address: 0.0.0.0:9995\ndir-level: 2\nignore-dirs:\n- /proc\n- /dev\n- /sys\n- /run\nbasic-auth-users:\n  prom: $2b$12$MzUQjmLxPRM9WW6OI4ZzwuZHB7ubHiiSnngJxIufgZms27nw.5ZAq\n```\n\n## Prometheus scrape config\n\nDisk usage analysis can be resource heavy.\nSet the `scrape_interval` and `scrape_timeout` according to the size of analyzed path.\n\n```yaml\nscrape_configs:\n  - job_name: 'disk-usage'\n    scrape_interval: 5m\n    scrape_timeout: 20s\n    static_configs:\n    - targets: ['localhost:9995']\n```\n\n## Dump to file\n\nThe official `node-exporter` allows to specify a folder which contains additional metric files through a [textfile collection mechanism](https://github.com/prometheus/node_exporter#textfile-collector).\nIn order to make use of this, one has to set up `node-exporter` according to the documentation and set the `output-file`\nof this exporter to any name ending in `.prom` within said folder (and of course also `mode` to `file`).\n\nA common use case for this is when the calculation of metrics takes particularly long and therefore can only be done\nonce in a while. To automate the periodic update of the output file, simply set up a cronjob.\n\n## Basic Auth\n\nYou can enable HTTP Basic authorization by setting the `--basic-auth-users` flag (password is \"test\"):\n\n```\ndisk_usage_exporter --basic-auth-users='admin=$2b$12$hNf2lSsxfm0.i4a.1kVpSOVyBCfIB51VRjgBUyv6kdnyTlgWj81Ay'\n```\n\nor by setting the key in config:\n\n```yaml\nbasic-auth-users:\n  admin: $2b$12$hNf2lSsxfm0.i4a.1kVpSOVyBCfIB51VRjgBUyv6kdnyTlgWj81Ay\n```\n\nThe password needs to be hashed by [bcrypt](https://bcrypt-generator.com/) in both cases.\n\n\n## Example systemd unit file\n\n```\n[Unit]\nDescription=Prometheus disk usage exporter\nDocumentation=https://github.com/dundee/disk_usage_exporter\n\n[Service]\nRestart=always\nUser=prometheus\nExecStart=/usr/bin/disk_usage_exporter $ARGS\nExecReload=/bin/kill -HUP $MAINPID\nTimeoutStopSec=20s\nSendSIGKILL=no\n\n[Install]\nWantedBy=multi-user.target\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdundee%2Fdisk_usage_exporter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdundee%2Fdisk_usage_exporter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdundee%2Fdisk_usage_exporter/lists"}