{"id":20834118,"url":"https://github.com/zifter/textfile-exporter","last_synced_at":"2026-04-25T13:06:09.938Z","repository":{"id":263060605,"uuid":"889219709","full_name":"zifter/textfile-exporter","owner":"zifter","description":"Export metrics from text filee","archived":false,"fork":false,"pushed_at":"2024-11-20T16:25:13.000Z","size":4155,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-18T21:30:34.428Z","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/zifter.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":"2024-11-15T21:01:46.000Z","updated_at":"2024-11-20T16:19:36.000Z","dependencies_parsed_at":"2024-11-15T22:40:24.675Z","dependency_job_id":null,"html_url":"https://github.com/zifter/textfile-exporter","commit_stats":null,"previous_names":["zifter/textfile-exporter"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zifter%2Ftextfile-exporter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zifter%2Ftextfile-exporter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zifter%2Ftextfile-exporter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zifter%2Ftextfile-exporter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zifter","download_url":"https://codeload.github.com/zifter/textfile-exporter/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243188203,"owners_count":20250453,"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-11-18T00:18:13.620Z","updated_at":"2026-04-25T13:06:09.932Z","avatar_url":"https://github.com/zifter.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# textfile-exporter\n\nA lightweight HTTP server that reads metrics from a text file and exposes them in [Prometheus exposition format](https://prometheus.io/docs/instrumenting/exposition_formats/).\n\nUseful for exporting deployment metadata, environment variables, or any static/slowly-changing values to Prometheus without writing a full exporter.\n\n## How it works\n\n1. You write metrics to a file in Prometheus text format (e.g. from a deploy script or CI/CD pipeline)\n2. `textfile-exporter` serves that file at `/metrics`\n3. Prometheus scrapes the endpoint as usual\n\n## Quick start\n\n```bash\n# Write metrics to a file\ncat \u003e metrics.txt \u003c\u003c EOF\n# HELP deploy_info Deployment metadata\n# TYPE deploy_info gauge\ndeploy_info{version=\"1.2.3\",env=\"prod\",commit=\"abc123\"} 1\n\n# HELP deploy_timestamp Unix timestamp of last deployment\n# TYPE deploy_timestamp gauge\ndeploy_timestamp 1713436800\nEOF\n\n# Run the exporter\n./textfile-exporter\n# or\ndocker run -v $(pwd)/metrics.txt:/metrics.txt -p 8080:8080 textfile-exporter\n```\n\n```\n$ curl localhost:8080/metrics\n# HELP deploy_info Deployment metadata\n# TYPE deploy_info gauge\ndeploy_info{version=\"1.2.3\",env=\"prod\",commit=\"abc123\"} 1\n...\n```\n\n## Configuration\n\nAll settings are configured via environment variables:\n\n| Variable | Default | Description |\n|---|---|---|\n| `SERVE_ADDR` | `:8080` | Address and port to listen on |\n| `METRICS_FILE_PATH` | `metrics.txt` | Path to the metrics file |\n| `METRICS_ENDPOINT` | `/metrics` | HTTP path to expose metrics at |\n| `REFRESH_INTERVAL` | `0` | How often to reload the file (`0` = load once at startup). Accepts Go duration strings: `30s`, `1m`, `5m` |\n| `LOG_OUTPUT` | `stdout` | Log destination (`stdout` or `stderr`) |\n\n## Docker\n\n```bash\ndocker build -t textfile-exporter .\n\n# Mount your metrics file and run\ndocker run \\\n  -v /path/to/metrics.txt:/metrics.txt \\\n  -e METRICS_FILE_PATH=/metrics.txt \\\n  -e REFRESH_INTERVAL=30s \\\n  -p 8080:8080 \\\n  textfile-exporter\n```\n\n## Use case: deploy-time metrics\n\nGenerate `metrics.txt` as part of your deployment pipeline:\n\n```bash\n#!/bin/bash\ncat \u003e /var/metrics/deploy.txt \u003c\u003c EOF\n# HELP deploy_info Current deployment info\n# TYPE deploy_info gauge\ndeploy_info{version=\"${APP_VERSION}\",env=\"${ENVIRONMENT}\",commit=\"${GIT_COMMIT}\"} 1\n\n# HELP deploy_timestamp Unix timestamp of last successful deployment\n# TYPE deploy_timestamp gauge\ndeploy_timestamp $(date +%s)\n\n# HELP build_number CI build number\n# TYPE build_number gauge\nbuild_number ${BUILD_NUMBER}\nEOF\n```\n\nRun `textfile-exporter` with `REFRESH_INTERVAL=30s` so it picks up the new file after each deploy without restarting.\n\n## Prometheus config\n\n```yaml\nscrape_configs:\n  - job_name: deploy_metrics\n    static_configs:\n      - targets: ['localhost:8080']\n```\n\n## Metrics file format\n\nStandard [Prometheus text format](https://prometheus.io/docs/instrumenting/exposition_formats/#text-based-format):\n\n```\n# HELP metric_name Description of the metric\n# TYPE metric_name gauge\nmetric_name{label=\"value\"} 42\nmetric_name_with_timestamp{label=\"value\"} 42 1713436800000\n```\n\nSupported types: `gauge`, `counter`, `untyped`.\n\n## Endpoints\n\n| Path | Description |\n|---|---|\n| `/metrics` | Prometheus metrics (configurable via `METRICS_ENDPOINT`) |\n| `/` | Health check — returns `200 OK` |\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzifter%2Ftextfile-exporter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzifter%2Ftextfile-exporter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzifter%2Ftextfile-exporter/lists"}