Skip to content

Instantly share code, notes, and snippets.

Last active Jan 24, 2017
What would you like to do?
Logstash heartbeat plugin -> Zabbix monitoring
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
Name: Logstash Heartbeat
Type: Zabbix trapper
Key: ls_heartbeat
Type of information: Numeric unsigned
Data type: Decimal
Units: unixtime
#!/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 =
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)
Name: Logstash Heartbeat Lag
Type: Zabbix trapper
Key: ls_heartbeat_lag
Type of information: Numeric unsigned
Data type: Decimal
Units: s
Copy link

tuudik commented Jan 24, 2017

@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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment