Skip to main content

Collect OOM Killer messages from /var/log/messages and represent the data in Prometheus.

Project description

OOM Messages Exporter

An exporter for providing OOM Killer's kills in the Prometheus format. The exporter is compatible with containers runtimes and could be useful to investigate OOM Killer activity inside containers, servers or vms.

Examples

The main metrics are 'oom_messages_exporter_last_killed_pid' and 'oom_messages_exporter_last_killed_time' those provide values of the last pid and the last time of killed processes since the exporter has started. You can configure Alertmanager on the ..._time metric (value > now - last Xh) or on a change of the ..._pid metric by expression delta(_pid[xH]) != 0 function. Also you can combine both metric to get better alerts experience.

Provided labels are:

  • command - a proc title of a killed process;
  • namespace (opt, containers runtimes only)
  • pod (opt, containers runtimes only)
  • container (opt, containers runtimes only)

OOM in kubernetes containers

oom_messages_exporter_last_killed_pid{command="php-fpm: pool w",container="php-fpm",namespace="oldwebsite",pod="a-legacy-app"} 235362.0
oom_messages_exporter_last_killed_time{command="framework",container="nodejs",namespace="lovely-project",pod="awesome-backend"} 1.69484585513779e+09

OOM in bare metal

For this case labels about containers runtime should be as 'None'

oom_messages_exporter_last_killed_pid{command="node /opt/www/p",container="None",namespace="None",pod="None"} 24190.0
oom_messages_exporter_last_killed_time{command="node /opt/www/p",container="None",namespace="None",pod="None"} 1.6948459852485702e+09

How to run

examples

Collecting OOM Killer messages about processes in an operating system:

# ./examples/exporter-container.sh

Collecting OOM Killer messages inside containers:

# ./examples/exporter-systemd.sh

Output (exporter-container.sh):

$ curl -s http://localhost:9001/ | egrep -v '^#' | grep oom_messages_exporter_last_killed_
oom_messages_exporter_last_killed_pid{command="framework",container="nodejs",namespace="lovely-project",pod="awesome-backend"} 1.990532e+06
oom_messages_exporter_last_killed_pid{command="php-fpm: pool w",container="php-fpm",namespace="oldwebsite",pod="a-legacy-app"} 235362.0
oom_messages_exporter_last_killed_time{command="framework",container="nodejs",namespace="lovely-project",pod="awesome-backend"} 1.69484585513779e+09
oom_messages_exporter_last_killed_time{command="php-fpm: pool w",container="php-fpm",namespace="oldwebsite",pod="a-legacy-app"} 1.694845840949523e+09

Production

# pip install oom_messages_exporter
# python3.9 oom_messages_exporter.py

Config

All runtime configuration provides by environment variables:

  • oom_messages_exporter_PORT - an exporter port (default: 9001)
  • oom_messages_exporter_POLL_INTERVAL - log polling interval (default: 1 (sec))
  • oom_messages_exporter_MESSAGES_LOG - a path to log (default: /var/log/messages)

Dependencies

  • python 3.9
  • prometheus_client

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

oom_messages_exporter-20230916.tar.gz (9.8 kB view details)

Uploaded Source

Built Distribution

oom_messages_exporter-20230916-py3-none-any.whl (10.3 kB view details)

Uploaded Python 3

File details

Details for the file oom_messages_exporter-20230916.tar.gz.

File metadata

File hashes

Hashes for oom_messages_exporter-20230916.tar.gz
Algorithm Hash digest
SHA256 a7e4ecfdf5f229b87923945354aab397c2ba2f79d2db677fabfecb87e63f8edd
MD5 2097bb37e77dbfe08aa8e42587beed5d
BLAKE2b-256 76e336bc65d73996164a314d11a1aa63825d6cf5a98f23c1598f3e5d1148fd1d

See more details on using hashes here.

File details

Details for the file oom_messages_exporter-20230916-py3-none-any.whl.

File metadata

File hashes

Hashes for oom_messages_exporter-20230916-py3-none-any.whl
Algorithm Hash digest
SHA256 b57308a9d2d04766013fd6c4c4ae5a67b64d7d51abef4154224987aed3ef0d63
MD5 fa02ce3f66f424c075877a729ee4890c
BLAKE2b-256 e5011fd401b22b2e83fba501824fd9c5191e5a20343e6b4d5bca8a7eee387ce9

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page