• This repository has been archived on 18/Aug/2021
  • Stars
    star
    103
  • Rank 333,046 (Top 7 %)
  • Language
    Shell
  • License
    Apache License 2.0
  • Created almost 11 years ago
  • Updated over 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Nagios plugins for alerting on Prometheus query results

nagios_plugins

Nagios plugin (in fact only one) for alerting on prometheus query results.

This repository has been archived. Please use magenta-aps/check_prometheus_metric instead, which is an an actively maintained fork with added features, designed to be fully backwards compatible.

Examples of command line usage:

PROMETHEUS_SERVER='http://demo.robustperception.io:9090'
QUERY_SCALAR_UP='scalar(up{instance="demo.robustperception.io:9100"})'
QUERY_VECTOR_UP='up{instance="demo.robustperception.io:9100"}'

bash check_prometheus_metric.sh -H $PROMETHEUS_SERVER -q $QUERY_SCALAR_UP -w 1 -c 1 -n $QUERY_SCALAR_UP -m lt
OK - scalar(up{instance="demo.robustperception.io:9100"}) is 1

bash check_prometheus_metric.sh -H $PROMETHEUS_SERVER -q $QUERY_SCALAR_UP -w 1 -c 1 -n $QUERY_SCALAR_UP -m lt -i
OK - scalar(up{instance="demo.robustperception.io:9100"}) is 1: UNKNOWN

bash check_prometheus_metric.sh -H $PROMETHEUS_SERVER -q $QUERY_VECTOR_UP -w 1 -c 1 -n $QUERY_VECTOR_UP -m lt -t vector
OK - up{instance="demo.robustperception.io:9100"} is 1

bash check_prometheus_metric.sh -H $PROMETHEUS_SERVER -q $QUERY_VECTOR_UP -w 1 -c 1 -n $QUERY_VECTOR_UP -m lt -t vector -i
OK - up{instance="demo.robustperception.io:9100"} is 1: { __name__: up, instance: demo.robustperception.io:9100, job: node }

You need to add the following commands to your Nagios configuration to use it:

define command {
    command_name check_prometheus
    command_line $USER1$/check_prometheus_metric.sh -H '$ARG1$' -q '$ARG2$' -w '$ARG3$' -c '$ARG4$' -n '$ARG5$' -m '$ARG6$'
}

# check_prometheus, treating a NaN result as ok
define command {
    command_name check_prometheus_nan_ok
    command_line $USER1$/check_prometheus_metric.sh -H '$ARG1$' -q '$ARG2$' -w '$ARG3$' -c '$ARG4$' -n '$ARG5$' -m '$ARG6$' -O
}

# check_prometheus, the first element of the vector is used for the check,
# printing the extra metric information into the Nagios message
define command {
    command_name check_prometheus_extra_info
    command_line $USER1$/check_prometheus_metric.sh -H '$ARG1$' -q '$ARG2$' -w '$ARG3$' -c '$ARG4$' -n '$ARG5$' -m '$ARG6$' -i -t vector
}

The echo, xargs, curl and the jq (version 1.4 or newer) commands must be installed for the plugin to work.

Usage

check_prometheus_metric.sh - simple prometheus metric extractor for nagios

  usage:
  check_prometheus_metric.sh -H HOST -q QUERY -w INT -c INT -n NAME [-m METHOD] [-O] [-i] [-t QUERY_TYPE]

  options:
    -H HOST          URL of Prometheus host to query
    -q QUERY         Prometheus query, in single quotes, that returns by default a float or int (see -t)
    -w INT           Warning level value (must be zero or positive)
    -c INT           Critical level value (must be zero or positive)
    -n NAME          A name for the metric being checked
    -m METHOD        Comparison method, one of gt, ge, lt, le, eq, ne
                     (defaults to ge unless otherwise specified)
    -C CURL_OPTS     Additional flags to pass to curl.
                     Can be passed multiple times. Options and option values must be passed separately.
                     e.g. -C --conect-timetout -C 10 -C --cacert -C /path/to/ca.crt
    -O               Accept NaN as an "OK" result 
    -i               Print the extra metric information into the Nagios message
    -p               Add perfdata to check output
    -t QUERY_TYPE    Prometheus query return type: scalar (default) or vector.
                     The first element of the vector is used for the check.

More Repositories

1

prometheus

The Prometheus monitoring system and time series database.
Go
54,496
star
2

node_exporter

Exporter for machine metrics
Go
10,870
star
3

alertmanager

Prometheus Alertmanager
Go
6,540
star
4

client_golang

Prometheus instrumentation library for Go applications
Go
5,367
star
5

blackbox_exporter

Blackbox prober exporter
Go
4,532
star
6

client_python

Prometheus instrumentation library for Python applications
Python
3,914
star
7

jmx_exporter

A process for exposing JMX Beans via HTTP for Prometheus consumption
Java
3,005
star
8

pushgateway

Push acceptor for ephemeral and batch jobs.
Go
2,969
star
9

client_java

Prometheus instrumentation library for JVM applications
Java
2,166
star
10

mysqld_exporter

Exporter for MySQL server metrics
Go
2,097
star
11

snmp_exporter

SNMP Exporter for Prometheus
Go
1,634
star
12

statsd_exporter

StatsD to Prometheus metrics exporter
Go
912
star
13

cloudwatch_exporter

Metrics exporter for Amazon AWS CloudWatch
Java
892
star
14

procfs

procfs provides functions to retrieve system, kernel and process metrics from the pseudo-filesystem proc.
Go
767
star
15

docs

Prometheus documentation: content and static site generator
SCSS
645
star
16

haproxy_exporter

Simple server that scrapes HAProxy stats and exports them via HTTP for Prometheus consumption
Go
615
star
17

promlens

PromLens – The query builder, analyzer, and explainer for PromQL
TypeScript
552
star
18

client_ruby

Prometheus instrumentation library for Ruby applications
Ruby
510
star
19

client_rust

Prometheus / OpenMetrics client library in Rust
Rust
462
star
20

consul_exporter

Exporter for Consul metrics
Go
436
star
21

prom2json

A tool to scrape a Prometheus client and dump the result as JSON.
Go
364
star
22

graphite_exporter

Server that accepts metrics via the Graphite protocol and exports them as Prometheus metrics
Go
350
star
23

promu

Prometheus Utility Tool
Go
268
star
24

influxdb_exporter

A server that accepts InfluxDB metrics via the HTTP API and exports them via HTTP for Prometheus consumption
Go
261
star
25

exporter-toolkit

Utility package to build exporters
Go
261
star
26

common

Go libraries shared across Prometheus components and libraries.
Go
261
star
27

collectd_exporter

A server that accepts collectd stats via HTTP POST and exports them via HTTP for Prometheus consumption
Go
255
star
28

memcached_exporter

Exports metrics from memcached servers for consumption by Prometheus.
Go
182
star
29

test-infra

Prometheus E2E benchmarking tool
Go
153
star
30

compliance

A set of tests to check compliance with various Prometheus interfaces
Go
127
star
31

demo-site

Demo site auto-deployed with Ansible and Travis CI.
HTML
96
star
32

client_model

Data model artifacts for Prometheus.
Makefile
74
star
33

golang-builder

Prometheus Golang builder Docker images
Shell
69
star
34

codemirror-promql

PromQL support for the CodeMirror code editor
TypeScript
39
star
35

busybox

Prometheus Busybox Docker base images
Makefile
37
star
36

prometheus_api_client_ruby

A Ruby library for reading metrics stored on a Prometheus server
Ruby
36
star
37

talks

Track Prometheus talks
20
star
38

lezer-promql

A lezer-based PromQL grammar
JavaScript
12
star
39

proposals

Design documents for Prometheus Ecosystem
Makefile
9
star
40

host_exporter

See the "node_exporter" repository instead!
8
star
41

circleci

7
star
42

snmp_exporter_mibs

4
star
43

promci

GitHub Actions repository
4
star
44

kube-demo-site

Kubernetes Demo Site
Go
1
star
45

client_java-benchmarks

1
star
46

sigv4

A http.RoundTripper that will sign requests using Amazon's Signature Verification V4 signing procedure
1
star