promtext-cli


Namepromtext-cli JSON
Version 0.1.1 PyPI version JSON
download
home_pageNone
SummaryPrometheus Textfile Tooling
upload_time2024-07-27 09:39:21
maintainerNone
docs_urlNone
authorNone
requires_python>=3.7
licenseNone
keywords prometheus
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # promtext-cli

promtext-cli is a tool for creating prometheus text files from a simple cli command.

It is intended for use with cronjob scripts (e.g. backups).

Features:
- supports merging new metrics into existing files
- metrics will be updated (same labelset or no labels given), or appended to existing metrics as new timeseries
- currently only supports gauge metrics

## Usage
```
promtext -h
usage: main.py [-h] [--docs DOCS] [--label KEY=VALUE] [-v] filename metric value

Prometheus textfile helper

positional arguments:
  filename           Path to existing or new prometheus textfile, will be updated
  metric             metric name (new or updated)
  value              metric value

options:
  -h, --help         show this help message and exit
  --docs DOCS        metric documentation
  --label KEY=VALUE  label key=value pairs
  -v, --verbose
```

## Examples
`tmp/backup.prom` before:
```
# HELP backup_last_start 
# TYPE backup_last_start gauge
backup_last_start{backup="example_1"} 1.721923501e+09
# HELP backup_last_end 
# TYPE backup_last_end gauge
backup_last_end{backup="example_1"} 1.721989156e+09
# HELP backup_last_exit 
# TYPE backup_last_exit gauge
backup_last_exit{backup="example_1"} 2.0
```

Updating existing timeseries: `promtext tmp/backup.prom backup_last_start 0 --label backup=example_1`:
```
# HELP backup_last_start 
# TYPE backup_last_start gauge
backup_last_start{backup="example_1"} 0.0
# HELP backup_last_end 
# TYPE backup_last_end gauge
backup_last_end{backup="example_1"} 1.721989156e+09
# HELP backup_last_exit 
# TYPE backup_last_exit gauge
backup_last_exit{backup="example_1"} 2.0
```

Adding a new label: `promtext tmp/backup.prom backup_last_start 0 --label backup=example_2`
```
# HELP backup_last_start 
# TYPE backup_last_start gauge
backup_last_start{backup="example_1"} 0.0
backup_last_start{backup="example_2"} 0.0
# HELP backup_last_end 
# TYPE backup_last_end gauge
backup_last_end{backup="example_1"} 1.721989156e+09
# HELP backup_last_exit 
# TYPE backup_last_exit gauge
backup_last_exit{backup="example_1"} 2.0
```

Adding a new metric: `promtext tmp/backup.prom some_other_state 0 --label new_label=foo_bar`
```
# HELP backup_last_start 
# TYPE backup_last_start gauge
backup_last_start{backup="example_1"} 0.0
backup_last_start{backup="example_2"} 0.0
# HELP backup_last_end 
# TYPE backup_last_end gauge
backup_last_end{backup="example_1"} 1.721989156e+09
# HELP backup_last_exit 
# TYPE backup_last_exit gauge
backup_last_exit{backup="example_1"} 2.0
# HELP some_other_state metric appended by promtext-cli
# TYPE some_other_state gauge
some_other_state{new_label="foo_bar"} 0.0
```

However, changing the label keys does not work:
```
promtext tmp/backup.prom some_other_state 0 --label foo_bar=foo_bar  
ERROR:promtext_cli.main:labelnames for metric some_other_state not compatible, cannot update! Old: ['new_label'], New: ['foo_bar']
```

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "promtext-cli",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": null,
    "keywords": "Prometheus",
    "author": null,
    "author_email": "margau <dev@marvingaube.de>",
    "download_url": "https://files.pythonhosted.org/packages/bd/3c/3bff1940e4a662976d4fb3145d6f3aef2e743cf6d1f26023d30c5db9f76a/promtext_cli-0.1.1.tar.gz",
    "platform": null,
    "description": "# promtext-cli\n\npromtext-cli is a tool for creating prometheus text files from a simple cli command.\n\nIt is intended for use with cronjob scripts (e.g. backups).\n\nFeatures:\n- supports merging new metrics into existing files\n- metrics will be updated (same labelset or no labels given), or appended to existing metrics as new timeseries\n- currently only supports gauge metrics\n\n## Usage\n```\npromtext -h\nusage: main.py [-h] [--docs DOCS] [--label KEY=VALUE] [-v] filename metric value\n\nPrometheus textfile helper\n\npositional arguments:\n  filename           Path to existing or new prometheus textfile, will be updated\n  metric             metric name (new or updated)\n  value              metric value\n\noptions:\n  -h, --help         show this help message and exit\n  --docs DOCS        metric documentation\n  --label KEY=VALUE  label key=value pairs\n  -v, --verbose\n```\n\n## Examples\n`tmp/backup.prom` before:\n```\n# HELP backup_last_start \n# TYPE backup_last_start gauge\nbackup_last_start{backup=\"example_1\"} 1.721923501e+09\n# HELP backup_last_end \n# TYPE backup_last_end gauge\nbackup_last_end{backup=\"example_1\"} 1.721989156e+09\n# HELP backup_last_exit \n# TYPE backup_last_exit gauge\nbackup_last_exit{backup=\"example_1\"} 2.0\n```\n\nUpdating existing timeseries: `promtext tmp/backup.prom backup_last_start 0 --label backup=example_1`:\n```\n# HELP backup_last_start \n# TYPE backup_last_start gauge\nbackup_last_start{backup=\"example_1\"} 0.0\n# HELP backup_last_end \n# TYPE backup_last_end gauge\nbackup_last_end{backup=\"example_1\"} 1.721989156e+09\n# HELP backup_last_exit \n# TYPE backup_last_exit gauge\nbackup_last_exit{backup=\"example_1\"} 2.0\n```\n\nAdding a new label: `promtext tmp/backup.prom backup_last_start 0 --label backup=example_2`\n```\n# HELP backup_last_start \n# TYPE backup_last_start gauge\nbackup_last_start{backup=\"example_1\"} 0.0\nbackup_last_start{backup=\"example_2\"} 0.0\n# HELP backup_last_end \n# TYPE backup_last_end gauge\nbackup_last_end{backup=\"example_1\"} 1.721989156e+09\n# HELP backup_last_exit \n# TYPE backup_last_exit gauge\nbackup_last_exit{backup=\"example_1\"} 2.0\n```\n\nAdding a new metric: `promtext tmp/backup.prom some_other_state 0 --label new_label=foo_bar`\n```\n# HELP backup_last_start \n# TYPE backup_last_start gauge\nbackup_last_start{backup=\"example_1\"} 0.0\nbackup_last_start{backup=\"example_2\"} 0.0\n# HELP backup_last_end \n# TYPE backup_last_end gauge\nbackup_last_end{backup=\"example_1\"} 1.721989156e+09\n# HELP backup_last_exit \n# TYPE backup_last_exit gauge\nbackup_last_exit{backup=\"example_1\"} 2.0\n# HELP some_other_state metric appended by promtext-cli\n# TYPE some_other_state gauge\nsome_other_state{new_label=\"foo_bar\"} 0.0\n```\n\nHowever, changing the label keys does not work:\n```\npromtext tmp/backup.prom some_other_state 0 --label foo_bar=foo_bar  \nERROR:promtext_cli.main:labelnames for metric some_other_state not compatible, cannot update! Old: ['new_label'], New: ['foo_bar']\n```\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Prometheus Textfile Tooling",
    "version": "0.1.1",
    "project_urls": {
        "Issues": "https://github.com/margau/promtext-cli/issues",
        "Source": "https://github.com/margau/promtext-cli"
    },
    "split_keywords": [
        "prometheus"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "cea89ef0ea25a8b1a1ab7ae29d5a55350bca2d6fabbb42b8a243320f922e29b0",
                "md5": "f72ab6c14f5e27b314bdb9bdcbadd353",
                "sha256": "50ea696a5efe710341f1106d89a72ace19c3b0f8a39365d0c10cc41a6a7689af"
            },
            "downloads": -1,
            "filename": "promtext_cli-0.1.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "f72ab6c14f5e27b314bdb9bdcbadd353",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 3874,
            "upload_time": "2024-07-27T09:39:20",
            "upload_time_iso_8601": "2024-07-27T09:39:20.141937Z",
            "url": "https://files.pythonhosted.org/packages/ce/a8/9ef0ea25a8b1a1ab7ae29d5a55350bca2d6fabbb42b8a243320f922e29b0/promtext_cli-0.1.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "bd3c3bff1940e4a662976d4fb3145d6f3aef2e743cf6d1f26023d30c5db9f76a",
                "md5": "ab48bf97c2b0124261e4f80316516fdc",
                "sha256": "beb6029a76e214df6cb4a850fe0c11e831b889fc2eb09f5448a98acc56ec2b4e"
            },
            "downloads": -1,
            "filename": "promtext_cli-0.1.1.tar.gz",
            "has_sig": false,
            "md5_digest": "ab48bf97c2b0124261e4f80316516fdc",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 4000,
            "upload_time": "2024-07-27T09:39:21",
            "upload_time_iso_8601": "2024-07-27T09:39:21.308437Z",
            "url": "https://files.pythonhosted.org/packages/bd/3c/3bff1940e4a662976d4fb3145d6f3aef2e743cf6d1f26023d30c5db9f76a/promtext_cli-0.1.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-07-27 09:39:21",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "margau",
    "github_project": "promtext-cli",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "promtext-cli"
}
        
Elapsed time: 0.32115s