https://github.com/geekodour/prom-fsd
Add and remove targets and labels to file_sd file for your prometheus configuration directly from the cli
https://github.com/geekodour/prom-fsd
cli monitoring prometheus service-discovery
Last synced: over 1 year ago
JSON representation
Add and remove targets and labels to file_sd file for your prometheus configuration directly from the cli
- Host: GitHub
- URL: https://github.com/geekodour/prom-fsd
- Owner: geekodour
- License: gpl-3.0
- Archived: true
- Created: 2018-11-09T12:16:01.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-02-01T02:47:27.000Z (over 7 years ago)
- Last Synced: 2024-11-06T02:38:24.714Z (over 1 year ago)
- Topics: cli, monitoring, prometheus, service-discovery
- Language: Python
- Size: 24.4 KB
- Stars: 3
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# promfilesd-cli
Add and remove targets and labels to file_sd file for your prometheus configuration directly from the cli
> **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
Content of `./sample_targets.json`
```json
[
{
"labels": {
"datacenter": "east",
"job": "mysql"
},
"targets": [
"10.11.150.1:7870",
"10.11.150.4:7870"
]
},
{
"labels": {
"job": "postgres"
},
"targets": [
"10.11.122.11:6001",
"10.11.122.15:6002"
]
},
{
"labels": {
"job": "node_exporter"
},
"targets": ["somehostname"]
}
]
```
### Usage
Add a **new target** with a **new job**:
```
$ python main.py sample_targets.json '{"targets":["gitlab42d.fsf.org"], "labels": {"job": "exim", "category":"mail"}}'
```
Add a **new target** to an **existing job**: (eg. for the `postgres` job)
```
$ python main.py sample_targets.json '{"targets":["newhost.fsf.org"], "labels": {"job": "postgres", "category":"database"}}'
```
Remove a target
```
$ python main.py sample_targets.json --remove-targets '["gitlab0d.fsf.org"]'
```
Remove a label from the whole file(all occurences will be removed **It's the label key!**
```
$ python main.py sample_targets.json --remove-labels '["category"]'
```