GithubHelp home page GithubHelp logo

magenta-aps / smem-prometheus-exporter Goto Github PK

View Code? Open in Web Editor NEW
3.0 6.0 1.0 19 KB

Prometheus Metrics exporter for shared memory metrics via smem

Home Page: https://www.selenic.com/smem/

License: GNU General Public License v2.0

Python 100.00%
prometheus-exporter prometheus machine-metrics host-metrics metrics procfs system-information system-metrics node-metrics python

smem-prometheus-exporter's Introduction

Shared Memory Prometheus Exporter

Prometheus exporter for shared shared memory metrics via smem. Shared memory details are picked up from the /proc filesystem and processed.

Similar to the mongodb_exporter and node_exporter this exporter has been implemented as a standalone-service to make reuse easier across different platforms and hosts.

Building

wget https://www.selenic.com/smem/download/smem-1.4.tar.gz
tar -xzvf smem-1.4.tar.gz
mv smem-1.4 smem
mv smem/smem smem/smem.py
echo "from smem import *" > smem/__init__.py

This downloads the latest release of smem, and configures it to be used as a python library.

Running

python smem_exporter.py

Upon which a full smem default run will be printed, followed by:

Starting HTTPD on 0.0.0.0:8172

After which the metrics endpoint is available at:

Output

Navigating to the metrics url, should produce output alike the following:

# HELP smem_map Memory usage maps
# TYPE smem_map gauge
smem_map{map="/usr/lib/x86_64-linux-gnu/libxcb-render.so.0.0.0",reading_type="uss"} 100.0
smem_map{map="/usr/share/fonts/type1/gsfonts/n019063l.pfb",reading_type="vss"} 612.0
...
# HELP smem_user Memory usage by user
# TYPE smem_user gauge
smem_user{reading_type="count",user="user",user_id="1000"} 62.0
smem_user{reading_type="pss",user="user",user_id="1000"} 2.475652e+06
...
# HELP smem_system Memory usage for the system
# TYPE smem_system gauge
smem_system{area="free memory",reading_type="noncache"} 0.0
smem_system{area="kernel image",reading_type="noncache"} 0.0
...
# HELP smem_pid Memory usage by process
# TYPE smem_pid gauge
smem_pid{command="/usr/bin/dbus-daemon ...",pid="7888",reading_type="pss",user="user",user_id="1000"} 459.0
smem_pid{command="/usr/bin/python ...",pid="8610",reading_type="maps",user="user",user_id="1000"} 1245.0
...

Along with the default entries for python and process.

The following metrics are provided:

  • smem_map exposes memory maps and shared memory regions, labeled by path and reading type.
  • smem_user exposes memory usage for users, labeled by user, user_id and reading type.
  • smem_system exposes memory areas for the system, labeled by area and reading_type.
  • smem_pid exposes memory usage for processes, labeled by command, pid, user, user_id and reading_type.

Limitations

While running as non-root smem can only query so much information from /proc/. As such this exporter can only export so much information when running as non-root.

To work around this, either:

  • Run the exporter as root (bad solution), or
  • mount /proc with the gid option and add the export user to the corresponding group.

Future considerations

Below follows a list of ideas for future improvements:

  • Adapt to futurization-smem?
  • Support commandline flags via argparse?
    • Support for enabling / disabling entire exporters (map, user, system, pid).
    • Support for enabling / disabling based upon labels.
    • Support truncating long commands with ellipsis.
    • Support transforming long commands into just the executable name.
      • Alternatively adding a new label just for executable name might do.
  • Utilize Custom Collectors instead of Gauge + resetting.

smem-prometheus-exporter's People

Contributors

skeen avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

Forkers

secoya

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.