{"id":13585047,"url":"https://github.com/geekodour/prom-fsd","last_synced_at":"2025-04-07T06:32:14.534Z","repository":{"id":86391223,"uuid":"156857902","full_name":"geekodour/prom-fsd","owner":"geekodour","description":"Add and remove targets and labels to file_sd file for your prometheus configuration directly from the cli","archived":true,"fork":false,"pushed_at":"2019-02-01T02:47:27.000Z","size":25,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-11-06T02:38:24.714Z","etag":null,"topics":["cli","monitoring","prometheus","service-discovery"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/geekodour.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":"2018-11-09T12:16:01.000Z","updated_at":"2023-10-14T09:01:33.000Z","dependencies_parsed_at":null,"dependency_job_id":"5c24d5da-43b0-49d8-a0f9-dab72209bef8","html_url":"https://github.com/geekodour/prom-fsd","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geekodour%2Fprom-fsd","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geekodour%2Fprom-fsd/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geekodour%2Fprom-fsd/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geekodour%2Fprom-fsd/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/geekodour","download_url":"https://codeload.github.com/geekodour/prom-fsd/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247607270,"owners_count":20965942,"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":["cli","monitoring","prometheus","service-discovery"],"created_at":"2024-08-01T15:04:42.475Z","updated_at":"2025-04-07T06:32:14.522Z","avatar_url":"https://github.com/geekodour.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"# promfilesd-cli\nAdd and remove targets and labels to file_sd file for your prometheus configuration directly from the cli\n\n\u003e **Note:** written in python2 to run by ansible, one can run this standalone but i use it from the ansible roles from exporter installs. i.e once the exporter is installed, call this script to add itself to file_sd\n\nContent of `./sample_targets.json`\n```json\n[\n    {\n        \"labels\": {\n            \"datacenter\": \"east\", \n            \"job\": \"mysql\"\n        }, \n        \"targets\": [\n            \"10.11.150.1:7870\", \n            \"10.11.150.4:7870\"\n        ]\n    }, \n    {\n        \"labels\": {\n            \"job\": \"postgres\"\n        }, \n        \"targets\": [\n            \"10.11.122.11:6001\", \n            \"10.11.122.15:6002\"\n        ]\n    }, \n    {\n        \"labels\": {\n            \"job\": \"node_exporter\"\n        }, \n        \"targets\": [\"somehostname\"]\n    }\n]\n```\n### Usage\nAdd a **new target** with a **new job**:\n```\n$ python main.py sample_targets.json '{\"targets\":[\"gitlab42d.fsf.org\"], \"labels\": {\"job\": \"exim\", \"category\":\"mail\"}}'\n```\n\nAdd a **new target** to an **existing job**: (eg. for the `postgres` job)\n```\n$ python main.py sample_targets.json '{\"targets\":[\"newhost.fsf.org\"], \"labels\": {\"job\": \"postgres\", \"category\":\"database\"}}'\n```\n\nRemove a target\n```\n$ python main.py sample_targets.json --remove-targets '[\"gitlab0d.fsf.org\"]'\n```\n\nRemove a label from the whole file(all occurences will be removed **It's the label key!**\n```\n$ python main.py sample_targets.json --remove-labels '[\"category\"]'\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgeekodour%2Fprom-fsd","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgeekodour%2Fprom-fsd","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgeekodour%2Fprom-fsd/lists"}