├── README.md └── logstash-messages-per-hour.sh /README.md: -------------------------------------------------------------------------------- 1 | # Munin Plugins by Raymii.org 2 | 3 | My munin plugins: 4 | 5 | - Logstash/Kibana: https://raymii.org/s/software/Munin_plugin_Logstash_Kibana_messages_per_hour.html 6 | 7 | -------------------------------------------------------------------------------- /logstash-messages-per-hour.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Logstash Munin plugin 3 | # Copyright (C) 2013 - Remy van Elst 4 | 5 | # This program is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation, either version 3 of the License, or 8 | # (at your option) any later version. 9 | 10 | # This program is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | 15 | # You should have received a copy of the GNU General Public License 16 | # along with this program. If not, see . 17 | 18 | # I need a logstash /elasticsearch server 19 | 20 | TIMEFRAME=60 21 | MUNIN_PERIOD=5 #minutes 22 | 23 | case $1 in 24 | config) 25 | cat <<'EOM' 26 | graph_title Central Log Messages Per Hour 27 | graph_vlabel Messages / Hour 28 | events.label syslog messages 29 | graph_scale no 30 | graph_category logging 31 | graph_info The number of events the logstash server handles per hour 32 | events.info Number of log events per 5 minutes. 33 | EOM 34 | exit 0;; 35 | esac 36 | 37 | TOTAL_EVENTS=$(curl -s -k -XGET http://localhost:9200/logstash-`date +%Y.%m.%d`/_search -d '{ "size": 0, "query": { "filtered": { "query": { "match_all": { } }, "filter": { "range": { "@timestamp": { "from": "'`date --date "2 hours ago" +%Y-%m-%dT%H:00:00+01:00`'", "to": "'`date --date "1 hour ago" +%Y-%m-%dT%H:00:00+01:00`'" } } } } }, "from": 0, "sort": { "@timestamp": { "order": "desc" } }}' | grep --only \"hits\"\:\{\"total\"\:[0-9]*,\" | grep -o [0-9]*) 38 | 39 | # Basic check to see if we get any logging... 40 | if [[ $TOTAL_EVENTS -lt 1 ]]; then 41 | echo -n events.value U 42 | exit 43 | fi 44 | 45 | echo -n events.value $TOTAL_EVENTS 46 | --------------------------------------------------------------------------------