{"id":20541036,"url":"https://github.com/netways/check_prometheus","last_synced_at":"2025-04-14T08:39:18.118Z","repository":{"id":183715538,"uuid":"668654877","full_name":"NETWAYS/check_prometheus","owner":"NETWAYS","description":"Icinga check plugin to check Prometheus","archived":false,"fork":false,"pushed_at":"2025-04-07T08:59:27.000Z","size":303,"stargazers_count":18,"open_issues_count":2,"forks_count":3,"subscribers_count":8,"default_branch":"main","last_synced_at":"2025-04-07T09:34:31.766Z","etag":null,"topics":["icinga","monitoring","plugin","prometheus"],"latest_commit_sha":null,"homepage":"https://www.netways.de/","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/NETWAYS.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":"2023-07-20T09:57:22.000Z","updated_at":"2025-04-07T08:44:30.000Z","dependencies_parsed_at":"2024-03-05T08:44:52.618Z","dependency_job_id":"652e500e-0b7e-4c34-9d86-52de0de8435a","html_url":"https://github.com/NETWAYS/check_prometheus","commit_stats":null,"previous_names":["netways/check_prometheus"],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NETWAYS%2Fcheck_prometheus","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NETWAYS%2Fcheck_prometheus/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NETWAYS%2Fcheck_prometheus/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NETWAYS%2Fcheck_prometheus/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/NETWAYS","download_url":"https://codeload.github.com/NETWAYS/check_prometheus/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248848149,"owners_count":21171314,"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":["icinga","monitoring","plugin","prometheus"],"created_at":"2024-11-16T01:18:58.073Z","updated_at":"2025-04-14T08:39:18.111Z","avatar_url":"https://github.com/NETWAYS.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# check_prometheus\n\nAn Icinga check plugin to check Prometheus.\n\n## Usage\n\n```bash\nUsage:\n  check_prometheus [flags]\n  check_prometheus [command]\n\nAvailable Commands:\n  alert       Checks the status of a Prometheus alert\n  health      Checks the health or readiness status of the Prometheus server\n  query       Checks the status of a Prometheus query\n\nFlags:\n  -H, --hostname string    Hostname of the Prometheus server (CHECK_PROMETHEUS_HOSTNAME) (default \"localhost\")\n  -p, --port int           Port of the Prometheus server (default 9090)\n  -U, --url string         URL/Path to append to the Promethes Hostname (CHECK_PROMETHEUS_URL) (default \"/\")\n  -s, --secure             Use a HTTPS connection\n  -i, --insecure           Skip the verification of the server's TLS certificate\n  -b, --bearer string      Specify the Bearer Token for server authentication (CHECK_PROMETHEUS_BEARER)\n  -u, --user string        Specify the user name and password for server authentication \u003cuser:password\u003e (CHECK_PROMETHEUS_BASICAUTH)\n      --ca-file string     Specify the CA File for TLS authentication (CHECK_PROMETHEUS_CA_FILE)\n      --cert-file string   Specify the Certificate File for TLS authentication (CHECK_PROMETHEUS_CERT_FILE)\n      --key-file string    Specify the Key File for TLS authentication (CHECK_PROMETHEUS_KEY_FILE)\n  -t, --timeout int        Timeout in seconds for the CheckPlugin (default 30)\n      --header strings     Additional HTTP header to include in the request. Can be used multiple times.\n                           Keys and values are separated by a colon (--header \"X-Custom: example\").\n  -h, --help               help for check_prometheus\n  -v, --version            version for check_prometheus\n```\n\nThe check plugin respects the environment variables `HTTP_PROXY`, `HTTPS_PROXY` and `NO_PROXY`.\n\nVarious flags can be set with environment variables, refer to the help to see which flags.\n\nIn the case Prometheus runs behind a reverse proxy, the `--url` parameter can be used:\n\n```bash\n# https://monitoring.example.com:443/subpath\n\n$ check_prometheus health -H 'monitoring.example.com' --port 443 --secure --url /subpath\nOK - Prometheus Server is Healthy. | statuscode=200\n```\n\n### Health\n\nChecks the health or readiness status of the Prometheus server.\n\n* `Health`: Checks the health of an endpoint, which returns OK if the Prometheus server is healthy.\n* `Ready`: Checks the readiness of an endpoint, which returns OK if the Prometheus server is ready to serve traffic (i.e. respond to queries).\n\n```bash\nUsage:\n  check_prometheus health [flags]\n\nExamples:\n  $ check_prometheus health --hostname 'localhost' --port 9090 --insecure\n  OK - Prometheus Server is Healthy. | statuscode=200\n\nFlags:\n  -r, --ready   Checks the readiness of an endpoint\n  -I, --info    Displays various build information properties about the Prometheus server\n  -h, --help    help for health\n```\n\n```bash\n$ check_prometheus health --hostname 'localhost' --port 9090 --insecure\nOK - Prometheus Server is Healthy. | statuscode=200\n\n$ check_prometheus health --ready\nOK - Prometheus Server is Ready. | statuscode=200\n```\n\n### Query\n\nChecks the status of a Prometheus query and evaluates the result of the alert.\n\n\u003eNote: Time range values e.G. 'go_memstats_alloc_bytes_total[10s]', only the latest value will be evaluated, other values will be ignored!\n\n```bash\nUsage:\n  check_prometheus query [flags]\n\nExamples:\n  $ check_prometheus query -q 'go_gc_duration_seconds_count' -c 5000 -w 2000\n  CRITICAL - 2 Metrics: 1 Critical - 0 Warning - 1 Ok\n   \\_[OK] go_gc_duration_seconds_count{instance=\"localhost:9090\", job=\"prometheus\"} - value: 1599\n   \\_[CRITICAL] go_gc_duration_seconds_count{instance=\"node-exporter:9100\", job=\"node-exporter\"} - value: 79610\n   | value_go_gc_duration_seconds_count_localhost:9090_prometheus=1599 value_go_gc_duration_seconds_count_node-exporter:9100_node-exporter=79610\n\nFlags:\n  -q, --query string      An Prometheus query which will be performed and the value result will be evaluated\n  -w, --warning string    The warning threshold for a value (default \"10\")\n  -c, --critical string   The critical threshold for a value (default \"20\")\n  -h, --help              help for query\n```\n\n#### Checking a single metric with ONE direct vector result\n\n```bash\n$ check_prometheus query -q 'go_goroutines{job=\"prometheus\"}' -c 40 -w 27\nWARNING - 1 Metrics: 0 Critical - 1 Warning - 0 Ok\n \\_[WARNING] go_goroutines{instance=\"localhost:9090\", job=\"prometheus\"} - value: 37\n | value_go_goroutines_localhost:9090_prometheus=37\n```\n\n#### Checking a single metric with multiple vector results\n\n```bash\n$ check_prometheus query -q 'go_goroutines' -c 40 -w 27\nWARNING - 2 Metrics: 0 Critical - 1 Warning - 1 Ok\n \\_[WARNING] go_goroutines{instance=\"localhost:9090\", job=\"prometheus\"} - value: 37\n \\_[OK] go_goroutines{instance=\"node-exporter:9100\", job=\"node-exporter\"} - value: 7\n | value_go_goroutines_localhost:9090_prometheus=37 value_go_goroutines_node-exporter:9100_node-exporter=7\n```\n\n#### Checking a time series matrix result\n\nHint: Currently only the latest value will be evaluated, other values will be ignored.\n\n```bash\n$ check_prometheus query -q 'go_goroutines{job=\"prometheus\"}[10s]' -c5 -w 10\nCRITICAL - 1 Metrics: 1 Critical - 0 Warning - 0 Ok\n \\_[CRITICAL] go_goroutines{instance=\"localhost:9090\", job=\"prometheus\"} - value: 37\n | value_go_goroutines_localhost:9090_prometheus=37\n\n$ check_prometheus query -q 'go_goroutines[10s]' -c 50 -w 40\nOK - 2 Metrics OK | value_go_goroutines_localhost:9090_prometheus=37 value_go_goroutines_node-exporter:9100_node-exporter=7\n```\n\n### Alert\n\nChecks the status of a Prometheus alert and evaluates the status of the alert.\n\n```bash\nUsage:\n  check_prometheus alert [flags]\n\nExamples:\n  $ check_prometheus alert --name \"PrometheusAlertmanagerJobMissing\"\n  CRITICAL - 1 Alerts: 1 Firing - 0 Pending - 0 Inactive\n   \\_[CRITICAL] [PrometheusAlertmanagerJobMissing] - Job: [alertmanager] is firing - value: 1.00\n   | firing=1 pending=0 inactive=0\n\n  $ check_prometheus a alert --name \"PrometheusAlertmanagerJobMissing\" --name \"PrometheusTargetMissing\"\n  CRITICAL - 2 Alerts: 1 Firing - 0 Pending - 1 Inactive\n   \\_[OK] [PrometheusTargetMissing] is inactive\n   \\_[CRITICAL] [PrometheusAlertmanagerJobMissing] - Job: [alertmanager] is firing - value: 1.00\n   | total=2 firing=1 pending=0 inactive=1\n\nFlags:\n      --exclude-alert stringArray  Alerts to ignore. Can be used multiple times and supports regex.\n  -h, --help                       help for alert\n  -n, --name strings               The name of one or more specific alerts to check.\n                                   This parameter can be repeated e.G.: '--name alert1 --name alert2'\n                                   If no name is given, all alerts will be evaluated\n  -g, --group strings              The name of one or more specific groups to check.\n                                   This parameter can be repeated e.G.: '--group group1 --group group2'\n                                   If no group is given, all groups will be scanned for alerts\n  -T, --no-alerts-state string     State to assign when no alerts are found (0, 1, 2, 3, OK, WARNING, CRITICAL, UNKNOWN). If not set this defaults to OK (default \"OK\")\n  -P, --problems                   Display only alerts which status is not inactive/OK. Note that in combination with the --name flag this might result in no alerts being displayed\n```\n\n#### Checking all defined alerts\n\n```bash\n$ check_prometheus alert\nCRITICAL - 6 Alerts: 3 Firing - 0 Pending - 3 Inactive\n \\_[OK] [PrometheusTargetMissing] is inactive\n \\_[CRITICAL] [PrometheusAlertmanagerJobMissing] - Job: [alertmanager] is firing - value: 1.00\n \\_[OK] [HostOutOfMemory] - Job: [alertmanager]\n \\_[OK] [HostHighCpuLoad] - Job: [alertmanager]\n \\_[CRITICAL] [HighResultLatency] - Job: [prometheus] on Instance: [localhost:9090]  is firing - value: 11.00\n \\_[CRITICAL] [HighResultLatency] - Job: [node-exporter] on Instance: [node-exporter:9100]  is firing - value: 10.00\n | total=6 firing=3 pending=0 inactive=3\n\n```\n\n#### Checking multiple alerts\n\n```bash\n$ check_prometheus alert --name \"HostHighCpuLoad\" --name \"HighResultLatency\"\nCRITICAL - 3 Alerts: 2 Firing - 0 Pending - 1 Inactive\n \\_[OK] [HostHighCpuLoad] is inactive\n \\_[CRITICAL] [HighResultLatency] - Job: [prometheus] on Instance: [localhost:9090]  is firing - value: 11.00\n \\_[CRITICAL] [HighResultLatency] - Job: [node-exporter] on Instance: [node-exporter:9100]  is firing - value: 10.00\n | total=3 firing=2 pending=0 inactive=1\n```\n\n```bash\n$ check_prometheus alert --name \"HostHighCpuLoad\" --name \"PrometheusTargetMissing\"\nOK - Alerts inactive | total=2 firing=0 pending=0 inactive=2\n```\n\n## License\n\nCopyright (c) 2022 [NETWAYS GmbH](mailto:info@netways.de)\n\nThis program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public\nLicense as published by the Free Software Foundation, either version 2 of the License, or\n(at your option) any later version.\n\nThis program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied\nwarranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License along with this program. If not,\nsee [gnu.org/licenses](https://www.gnu.org/licenses/).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnetways%2Fcheck_prometheus","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnetways%2Fcheck_prometheus","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnetways%2Fcheck_prometheus/lists"}