Alex Koutmos' Blog

In my first blog post I cover how to package an Elixir 1.9 release within a Docker container using multi-stage builds. I also go over introspecting the running app with observer_cli. Check it out!

16 Likes

In this blog post I cover how to add error monitoring to your Elixir+Phoenix application using Sentry. Check it out!

6 Likes

Ever wondered how to use Prometheus and PostGIS within your Phoenix application? Check out Part 1 of my 2 part series:

4 Likes

Part 2 of the Prometheus+PostGIS+Phoenix series is now published. Check it out if you want to learn how to make cool dashboards like the one below.

11 Likes

Really liked going through this! Very well explained. The stress tester with the erlang modules was a sweet surprise :wink:

I would love a Prometheus and Grafana deep dive! Hope I’m not alone here :grin:

1 Like

Glad you enjoyed the tutorial :smiley:. I’ll be releasing my next post later this week on RabbitMQ+Broadway. I’ll put something in the queue for Prom and Grafana though. Stay tuned!

2 Likes

In this blog post I cover how to setup RabbitMQ along side Broadway to create a powerful yet simple data processing pipeline. Check out Part 1!

5 Likes

Part 2 of my RabbitMQ + Broadway series is up on my blog at

Check it out and learn how to use RabbitMQ+Broadway and monitor your pipeline with Prometheus and Grafana!

You’ll have to scroll all the way to the bottom to see the trend data on HackerNews for Elixir and Erlang :smiley:

3 Likes

Ever wonder how you could write a rate limiter in Elixir? Check out my latest post to learn about GenServers, Task.Supervisor and Erlang’s built in queue data structure.

6 Likes

I haven’t been able to deploy the docker-compose.yml in this project(the elixir_app service fails). So I made another project which builds the elixir app from a local Dockerfile.

I got it running and deploying but I had to disable prometheus_process_collector because it was crashing at startup on both Linux and MacOS.

Another issue I noticed with my repo is that the Brewery Search does not render metrics(have not investigated root cause) but everything else seems to work OK.

Howdy!

Thanks for giving the blog tutorial a whirl…and sorry about the issue that you came across. I am currently not on my Linux machine so I can’t comment on the Linux side of things. But I did have an issue on my MacBook with Docker. Seems like when I was trying to shadow the volume mount it didn’t take (I could have sworn this worked on my Linux box, but I can’t verify at the moment).

This updated docker-compose.yml elixir_app section seems to sort out that Docker issue:

elixir_app:
  image: elixir:1.9.1
  command: >
    /bin/sh -c 'apt-get update && apt-get install -y inotify-tools &&
    mix local.hex --force &&
    mix local.rebar --force &&
    mix deps.get &&
    mix ecto.setup &&
    mix phx.server'
  ports:
    - '4000:4000'
  depends_on:
    - postgres
  working_dir: /app
  volumes:
    - ./config:/app/config:ro
    - ./lib:/app/lib:ro
    - ./priv:/app/priv:ro
    - ./.formatter.exs:/app/formatter.exs:ro
    - ./mix.exs:/app/mix.exs:ro
    - ./mix.lock:/app/mix.lock:ro
    - elixir-deps:/app/deps/
    - elixir-build:/app/_build/

As for the metrics not showing up, I just ran the stress tester in the repo and looks like things are working on that front (after the docker fix).


Let me know if you have issues after that docker fix or if you can provide additional information as to the error.

I see so it was a volume issue. It’s working great on Linux Mint/Ubuntu now, thanks.

2 Likes

Glad to hear it works now! And thanks for letting me know about the issue. Really appreciate the feedback :). I’m fixing the blog and the repo now with the changes.

2 Likes

Hi Alex, I’m trying to deploy prometheus and grafana by adding them to my docker-compose.yml. I’m using your docker compose file as a template. I seem to have gotten them up and running but the postgres_exporter is giving me this error repeatedly:

postgres_exporter_1       | time="2020-01-25T15:13:06Z" level=info msg="Established new database connection to \"postgres:5432\"." source="postgres_exporter.go:777"
postgres_exporter_1       | time="2020-01-25T15:13:06Z" level=error msg="Error opening connection to database (postgresql://postgres:PASSWORD_REMOVED@postgres:5432/?sslmode=disable): dial tcp: lookup postgres on 127.0.0.11:53: no such host" source="postgres_exporter.go:1336"

I’m certain there is a service named postgres running as it is in my docker-compose.yml and my elixir app depends on it.

Do you see anything wrong with my docker-compose.yml ?

Notes:
I disabled/commented-out Traefik because I’m testing the docker deployment on my development mac.

I’m not using postgis, so I am using the standard postgres-12.1 docker image.

I’m also using your configurations found in your docker/ dir

My initial guess is that the credentials that the Postgres Exporter has do not align with the Postgres container https://gist.github.com/mazz/fa217305cf10036d64cd2b06ba1501f1#file-docker-compose-yml-L64-L66 versus https://gist.github.com/mazz/fa217305cf10036d64cd2b06ba1501f1#file-docker-compose-yml-L72-L73

I figured it out. The problem was that postgres-exporter was not on my internal db-network So dockers’ internal DNS name resolution would simply miss it and thus the odd “dial tcp” error.

I added this to the postgres-exporter service yaml and postgres could be discovered:

    networks:
      - db-network

Full yaml chunk:

  postgres_exporter:
    image: wrouesnel/postgres_exporter:v0.5.1
    ports:
      - '9187:9187'
    depends_on:
      - postgres
    environment:
      DATA_SOURCE_USER: ${FW_DATABASE_USERNAME?Variable FW_DATABASE_USERNAME not set}
      DATA_SOURCE_PASS: ${FW_DATABASE_PASSWORD?Variable FW_DATABASE_PASSWORD not set}
      DATA_SOURCE_URI: postgres:5432/?sslmode=disable
    networks:
      - db-network

Awesome! Glad you were able to sort out the issues :slight_smile:

1 Like

Ever wanted to learn how to setup a structured logging solution in Elixir? Check out my latest post https://akoutmos.com/post/elixir-logging-loki to learn how you can set up Grafana’s Loki along side a Phoenix application and extract all those valuable logs!

2 Likes

It’s been a little while since my last post…but here it is! My latest post is on setting up Phoenix LiveDashboard and tracking some of your own application metrics.

Check out the post here:

Happy Monday everyone and May the 4th be with you!

2 Likes

Ever wanted to learn more about Ecto, it’s internals and how to leverage the repository pattern more effectively in your application? Check out my latest post

https://akoutmos.com/post/ecto-repo-testing

2 Likes