{"id":23080101,"url":"https://github.com/opsdis/monitor-promdiscovery","last_synced_at":"2025-08-15T22:30:44.330Z","repository":{"id":49135981,"uuid":"202751018","full_name":"opsdis/monitor-promdiscovery","owner":"opsdis","description":"The monitor-promdiscovery tool generate file-based service discovery files for Prometheus and the monitor-exporter","archived":false,"fork":false,"pushed_at":"2024-01-20T08:18:38.000Z","size":107,"stargazers_count":4,"open_issues_count":1,"forks_count":3,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-12-14T16:19:14.819Z","etag":null,"topics":["discovery","icinga2","incinga2-exporter","monitor-exporter","monitor-promdiscovery","prometheus"],"latest_commit_sha":null,"homepage":"https://www.opsdis.com","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/opsdis.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"COPYING","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":"2019-08-16T15:17:48.000Z","updated_at":"2024-11-03T22:37:20.000Z","dependencies_parsed_at":"2023-12-14T15:25:30.796Z","dependency_job_id":"67782450-04e9-4435-8114-3f4338768e8c","html_url":"https://github.com/opsdis/monitor-promdiscovery","commit_stats":{"total_commits":43,"total_committers":4,"mean_commits":10.75,"dds":0.06976744186046513,"last_synced_commit":"11e440656d76ebb9cab11d1be3a463973991db07"},"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/opsdis%2Fmonitor-promdiscovery","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/opsdis%2Fmonitor-promdiscovery/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/opsdis%2Fmonitor-promdiscovery/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/opsdis%2Fmonitor-promdiscovery/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/opsdis","download_url":"https://codeload.github.com/opsdis/monitor-promdiscovery/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":229964405,"owners_count":18152034,"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":["discovery","icinga2","incinga2-exporter","monitor-exporter","monitor-promdiscovery","prometheus"],"created_at":"2024-12-16T13:04:42.711Z","updated_at":"2024-12-16T13:04:43.500Z","avatar_url":"https://github.com/opsdis.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![PyPI version](https://badge.fury.io/py/monitor-promdiscovery.svg)](https://badge.fury.io/py/monitor-promdiscovery)\n\nmonitor-promdiscovery\n------------------------\n\n# Overview\nThe *monitor-promdiscovery* tool generate file-based service discovery files for Prometheus, for the \n[monitor-exporter](https://github.com/opsdis/monitor-exporter) and [icinga2-exporter](https://github.com/opsdis/icinga2-exporter).\nThe tool is typically run from cron or equivalent tool to check OP5 Monitor or Icinga2 for hosts service that should be \nscraped for performance metrics by the exporters.  \nFor a host to be detected, it must be a part of hostgroup(s) or servicegroup(s) that is defined in the configuration \nfile. For a servicegroup(s) configuration all hosts that has at least on service in the configured servicegroup(s) will\nbe added.\n\u003e Servicegroups configuration is not supported for icinga2\n\n# Flow\n\n![Flow overview](https://github.com/opsdis/monitor-promdiscovery/raw/master/doc/overview.png)\n\n 1. *monitor-promdiscovery* is executed at regular intervals, e.g. every minute, by cron.\n 2. *monitor-promdiscovery* performs a filter query against the configured Monitor instance for all hosts that are part of a specific hostgroup. All hosts in the hostgroup(s) will be scraped for all their services' performance data\n *monitor-exporter* or *icinga2-exporter*. \n 3. *monitor-promdiscovery* checks against the configured file-based discovery if any host from the above call is new or not existing anymore.\n 4. Only if there is not a match the file-based discovery file will be updated\n 5. If the file is updated, Prometheus will reload the configuration file.\n\n# Running\n## Only use configuration file \n\n\tpython -m monitor_promdiscovery -f ./config.yml\n\n## Override system property in the configuration file \n\n\tpython -m monitor_promdiscovery -f ./config.yml -s \u003csystem\u003e\n\t\n\u003e Where *\u003csystem\u003e* can be either icinga2 or monitor\n\t\n# Installing\n1. Check out / clone the git repo.\n2. Install dependencies\n    \n    `pip install -r requirements.txt`\n     \n3. Build a distribution \n\n    `python setup.py sdist`\n\n4. Install locally\n \n    `pip install dist/monitor-promdiscovery-X.Y.Z.tar.gz`\n     \n\n\n# Configuration\nThe *monitor-promdiscovery* configuration file should be rather self-explanatory. \n\n\u003eNB! Only icinga2 or op5monitor has to be configured. If both are used, use the -s switch instead of configure\n\u003esystem in the property file. Using the below config executing without specifiying -s \u003csystem\u003e, the icinga2 entry will be used.\n\n```yaml\n# The system can be either op5monitor or icinga2 \nsystem: icinga2\n\nop5monitor:  \n  url: https://monitor.local  \n  user: monitor  \n  passwd: monitor  \n  # Connection timeout - default 5\n  # timeout: 5\n  # Verify ssl - default False\n  # verify: False\n\n  # The hostgroup(s) used to select hosts as targets  \n  hostgroup: \n    - prometheus\n  # The servicegroup(s) used to select hosts as targets\n  # Will include all hosts that has at least on service in the configured servicegroup(s)\n  servicegroup:\n    - servicepoint\n  prometheus:  \n    # path where to create the file-based discovery file - must be set  \n    sd_file: \u003csd_directory\u003e/monitor_sd.yml  \n    # Additional labels to tag metrics with - optional\n    labels:  \n      source: monitor  \n      env: prod\n\nicinga2:\n  url: https://127.0.0.1:5665\n  user: root\n  passwd: cf593406ffcfd2ef\n  # Connection timeout - default 5\n  # timeout: 5\n  # Verify ssl - default False\n  # verify: False\n\n  # The hostgroup used to select hosts as targets\n  hostgroup: \n    - prometheus\n    - linux_servers\n  prometheus:\n    # path where to create the file-based discovery file - must be set\n    sd_file: /home/andersh/programs/prometheus/sd/icinga2_sd.yml\n    # Additional labels to tag metrics with - optional\n    labels:\n      source: icinga2\n      env: prod\n\nlogger:\n  # Path and name for the log file. If not set sent to stdout\n  logfile: monitor-promdiscovery.log\n  # Format if day will have current day as post fix\n  # format: day\n  # Log level\n  #level: INFO\n\n``` \n\n\u003e The hostgroup property can be both a single value or a list of different hostgroups as shown above.\n\n## Prometheus configuration\nThe Prometheus configuration file would typical have the following job configuration in the scrape_configs section for the *monitor-exporter*:  \n```yaml\n\n  - job_name: 'op5'\n    scrape_interval: 2m\n    metrics_path: /metrics\n    file_sd_configs:\n    - files:\n      - 'sd/monitor_sd.yml'\n    relabel_configs:\n      - source_labels: [__address__]\n        target_label: __param_target\n      - source_labels: [__param_target]\n        target_label: instance\n      - target_label: __address__\n        # The address for the monitor-exporter\n        replacement: localhost:5000\n\n```\nAnd the format for icinga2 is almost the same:\n```yaml\n  - job_name: 'icinga2'\n    scrape_interval: 2m\n    metrics_path: /metrics\n    file_sd_configs:\n    - files:\n      - 'sd/icinga2_sd.yml'\n    relabel_configs:\n      - source_labels: [__address__]\n        target_label: __param_target\n      - source_labels: [__param_target]\n        target_label: instance\n      - target_label: __address__\n        # The address for the monitor-exporter\n        replacement: localhost:5000\n```\n\n\u003e The `file_sd_configs` must have the same filename as created by the tool, as defined in the configuration file. \n\n# System requirement\nPython 3.6\n\nFor required packages, please review `requirements.txt`\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopsdis%2Fmonitor-promdiscovery","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fopsdis%2Fmonitor-promdiscovery","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopsdis%2Fmonitor-promdiscovery/lists"}