processone / docker-ejabberd

Set of ejabberd Docker images
95 stars 77 forks source link

Load custom module into Ejabberd docker container #81

Closed sunbladehub closed 2 years ago

sunbladehub commented 2 years ago

I want to load this custom module into an ejabberd docker container running in docker compose.

https://github.com/skythet/ejabberd-prometheus-exporter

What is the recommended way to do that?

badlop commented 2 years ago

If you are already using docker-compose, I guess this is the easiest way. I tried it with ejabberd latest and works correctly. Please note, in my example, the container is named ecs_main_1:

  1. First of all, get and prepare the module source code. I had to grant permission to 9000:
mkdir -p modules/sources/mod_prometheus/ebin
git clone https://github.com/skythet/ejabberd-prometheus-exporter.git modules/sources/mod_prometheus/src
echo "summary: \"Ejabberd metrics for Prometheus\"" > modules/sources/mod_prometheus/mod_prometheus.spec
sudo chown -R 9000:9000 modules
  1. In your docker-compose.yml add something like this:
    volumes:
      - ./modules:/home/ejabberd/.ejabberd-modules
  1. Start the ejabberd docker container

  2. Check the module source code is available:

    sudo docker exec -it ecs_main_1 bin/ejabberdctl modules_available
    mod_prometheus  Ejabberd metrics for Prometheus
  3. Then compile and install it:

    sudo docker exec -it ecs_main_1 bin/ejabberdctl module_install mod_prometheus
    Module mod_prometheus has been installed.
    Now you can configure it in your ejabberd.yml
  4. As it says, configure it in ejabberd.yml. In my case I added it to request_handlers in port 5280:

    -
    port: 5280
    ip: "::"
    module: ejabberd_http
    request_handlers:
      /admin: ejabberd_web_admin
      /metrics: mod_prometheus
  5. Restart ejabberd. It doesn't show any specific log message.

  6. Visit the URL http://localhost:5280/metrics It shows raw text:

    ejabberd_memory_total_bytes{node="ejabberd@main"} 37200928
    ejabberd_memory_processes_bytes{node="ejabberd@main"} 4976968
    ejabberd_memory_processes_used_bytes{node="ejabberd@main"} 4976816
    ...
sunbladehub commented 2 years ago

This is working 100%. Thank you for the fast answer.

dodziraynard commented 6 months ago

I'm using version 24.2.0 and I have to mount the volume at /opt/ejabberd/.ejabberd-modules/

badlop commented 6 months ago

Right @dodziraynard , you both are right. As mentioned in Alternative Image in GitHub: