How can I enable metrics in my self hosted server?

Hi there!

First of all, what a great tool! I have been using it for years now and I show it to everyone I know (that uses a terminal ^^!)

I have just recently decided to self host an atuin server and I saw that in the server.toml file, generated when running it via docker compose, there is a metrics section

So I tried fiddling with it without much success, am I missing something?

I was surprised to not find any reference in the docs so maybe the sample server config file is outdated and the metrics option was deprecated, or I am just simply not doing something right ^^!

This is my docker-compose.yml file

version: '3.5'
services:
  atuin:
    restart: always
    image: ghcr.io/atuinsh/atuin:v18.6.1
    command: server start
    volumes:
      - "./config:/config"
      - "./certs:/etc/letsencrypt:ro"
    links:
      - postgresql:db
    ports:
      - 8888:8888
    environment:
      ATUIN_HOST: "0.0.0.0"
      ATUIN_OPEN_REGISTRATION: "true"
      ATUIN_DB_URI: postgres://$ATUIN_DB_USERNAME:$ATUIN_DB_PASSWORD@db/$ATUIN_DB_NAME
      RUST_LOG: info,atuin_server=debug
  postgresql:
    image: postgres:14
    restart: unless-stopped
    volumes: # Don't remove permanent storage for index database files!
      - "./database:/var/lib/postgresql/data/"
    environment:
      POSTGRES_USER: ${ATUIN_DB_USERNAME}
      POSTGRES_PASSWORD: ${ATUIN_DB_PASSWORD}
      POSTGRES_DB: ${ATUIN_DB_NAME}

This is my server.toml file

## host to bind, can also be passed via CLI args
# host = "127.0.0.1"

## port to bind, can also be passed via CLI args
# port = 8888

## whether to allow anyone to register an account
open_registration = false

## URI for postgres (using development creds here)
# db_uri="postgres://username:password@localhost/atuin"

## Maximum size for one history entry
# max_history_length = 8192

## Maximum size for one record entry
## 1024 * 1024 * 1024
# max_record_size = 1073741824

## Webhook to be called when user registers on the servers
# register_webhook_username = ""

## Default page size for requests
# page_size = 1100

[metrics]
enable = true
host = "127.0.0.1"
port = 8889

#[tls]
#enable = true
#cert_path = "/etc/letsencrypt/fullchain.pem"
#key_path = "/etc/letsencrypt/privkey.pem"

I am also not having much luck with enabling TLS but it might be that I am missing something or just some permissions issues

Any help would be appreciated!

Thank you!

I imagine you need to add

- 8889:8889

here, so that we also expose the metrics server! You may also want to bind it on a different interface

1 Like

:man_facepalming:

I should have caught that on my own… yikes…

For anyone that stumbles upon this thread, here is my final docker compose file:

version: '3.5'
services:
  atuin:
    restart: always
    image: ghcr.io/atuinsh/atuin:v18.6.1
    command: server start
    volumes:
      - "./config:/config"
      - "./certs:/etc/letsencrypt:ro"
    links:
      - postgresql:db
    ports:
      - 8888:8888
      - 8889:8889
    environment:
      ATUIN_HOST: "0.0.0.0"
      ATUIN_OPEN_REGISTRATION: "true"
      ATUIN_DB_URI: postgres://$ATUIN_DB_USERNAME:$ATUIN_DB_PASSWORD@db/$ATUIN_DB_NAME
      RUST_LOG: info,atuin_server=debug
  postgresql:
    image: postgres:14
    restart: unless-stopped
    volumes: # Don't remove permanent storage for index database files!
      - "./database:/var/lib/postgresql/data/"
    environment:
      POSTGRES_USER: ${ATUIN_DB_USERNAME}
      POSTGRES_PASSWORD: ${ATUIN_DB_PASSWORD}
      POSTGRES_DB: ${ATUIN_DB_NAME}

And my server.toml

# whether to allow anyone to register an account
open_registration = false

[metrics]
enable = true
host = "0.0.0.0"
port = 8889

Thank you Ellie!

2 Likes