Last active
January 24, 2017 12:51
-
-
Save untergeek/c56e5c7aa3b94cdc493e to your computer and use it in GitHub Desktop.
Logstash heartbeat plugin -> Zabbix monitoring
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
input { | |
heartbeat { | |
message => "epoch" | |
interval => 10 | |
add_field => { "zabbix_host" => "host.example.tld" "zabbix_key" => "ls_heartbeat" } | |
tags => [ "heartbeat" ] | |
} | |
} | |
filter { } | |
output { | |
if "heartbeat" in [tags] { | |
zabbix { | |
zabbix_server_host => "localhost" | |
zabbix_host => "zabbix_host" | |
zabbix_key => "zabbix_key" | |
zabbix_value => "clock" | |
} | |
} else { | |
# ... Other outputs | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Name: Logstash Heartbeat | |
Type: Zabbix trapper | |
Key: ls_heartbeat | |
Type of information: Numeric unsigned | |
Data type: Decimal | |
Units: unixtime |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# Send calculated difference between "lastclock" (which is the epoch timestamp when Zabbix recorded "lastvalue") | |
# and "lastvalue" (which must also be an epoch timestamp) to "lag_key" at the ls_host on | |
# the specified Zabbix server. | |
from zoop import * | |
from zbxsend import Metric, send_to_zabbix | |
api = zoop(url='http://zabbix.example.tld/zabbix', username='user', password='supersecretpassphrase') | |
ls_host = 'host.example.tld' | |
item_key = 'ls_heartbeat' | |
lag_key = 'ls_heartbeat_lag' | |
zabbix_server = 'localhost' | |
zabbix_port = 10051 | |
zabbixhost = api.host() | |
zabbixhost.get(name=ls_host) | |
zabbixitem = api.item() | |
zabbixitem.get(hostid=zabbixhost["hostid"], key_=item_key) | |
diff = int(zabbixitem["lastclock"]) - int(zabbixitem["lastvalue"]) | |
send_to_zabbix([Metric('host.example.tld', lag_key, diff)], zabbix_server, zabbix_port) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Name: Logstash Heartbeat Lag | |
Type: Zabbix trapper | |
Key: ls_heartbeat_lag | |
Type of information: Numeric unsigned | |
Data type: Decimal | |
Units: s |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@untergeek I would love to see some small guide, how to setup Zabbix monitoring for logstash.
Or perhaps you can recommend easier way to monitor if logstash is working or not?