axsuul / plex-media-server-exporter

A better Prometheus exporter for Plex Media Server
MIT License
56 stars 5 forks source link

[Docker Compose] Using Secrets for Token? #16

Closed Lebowski89 closed 1 hour ago

Lebowski89 commented 5 months ago

Hello,

If I input the token directly into the compose file everything works great, prometheus receives the metrics without issue. But if I try make use of docker secrets, I get the following: '+1000 Rack app ("GET /metrics" - (172.19.0.27)): #<ArgumentError: value must be a number'.

I have tried the following:

PLEX_TOKEN: /run/secrets/plex_token
PLEX_TOKEN_FILE: /run/secrets/plex_token
FILE_PLEX_TOKEN: /run/secrets/plex_token
FILE__PLEX_TOKEN:  /run/secrets/plex_token

All give the same error and promethesus lists the exporter as down.

Compose;

services:
  plex-exporter:
    container_name: '${PLEX_EXP_CONTAINER_NAME}'
    image: ghcr.io/axsuul/plex-media-server-exporter:${PLEX_EXP_IMAGE_TAG}
    networks:
      socket_proxy:
      traefik_proxy: 
      proxy:
    tty: true
    stdin_open: true
    environment:
      PORT: '${PLEX_EXP_CONT_PORT}'
      PLEX_ADDR: '${PLEX_SERVER_ADDRESS}' # Remote
      #PLEX_ADDR: http://plex:32400 # Internal
      PLEX_TIMEOUT: '20'
      PLEX_RETRIES_COUNT: '0'
      METRICS_PREFIX: 'plex'
      METRICS_MEDIA_COLLECTING_INTERVAL_SECONDS: '300'
      #PLEX_TOKEN: '<plex token>'
      PLEX_TOKEN_FILE: '/run/secrets/plex_token'
    ports:
      - '${PLEX_EXP_HOST_PORT}:${PLEX_EXP_CONT_PORT}'
    secrets:
      - plex_token
    env_file:
      - .env
    restart: unless-stopped

networks:
  socket_proxy:
    external: true
  traefik_proxy:
    external: true
  proxy:
    external: true

secrets:
  plex_token: 
    file: '${SECRETS_PATH}/plex_token.txt'

.env

#GLOBAL#
PUID=1000
PGID=1000
UMASK=002
TZ=Australia/Melbourne
SECRETS_PATH=/appdata/ubuntu/docker/secrets

#CONTAINER_NAME
PLEX_EXP_CONTAINER_NAME=plex-exporter

#IMAGE_TAG
PLEX_EXP_IMAGE_TAG=latest

PLEX_SERVER_ADDRESS=http://<LAN IP OF PLEX MACHINE>:32400

#CONTAINER_PORTS
PLEX_EXP_HOST_PORT=9594
PLEX_EXP_CONT_PORT=9594

Any ideas here? As I said, the token itself works if I just use that (including copying out of the token file and pasting in compose), but throwing secrets into the mix is just not working. Not a fan of including api/token in docker-compose.yml or .env.

axsuul commented 1 hour ago

Sorry, there is no support for Docker secrets out of the box at the moment. It's unfortunately not common to support this, although I know the postgres container does support it natively.