friendlyFriend4000 / prometheus-immich-exporter

A prometheus exporter for immich written in Python. Docker image
https://github.com/immich-app/immich#demo
GNU General Public License v3.0
19 stars 9 forks source link

def combine_url(self, api_endpoint) #9

Closed mentalsoup closed 4 months ago

mentalsoup commented 10 months ago

It appears the URL constructor for the API URL is very strict, in my use case I have Immich behind Tarefik and as a result the direct path constructed with the URL and port combination cannot connect to my Immich instance because the constructor forces http and :PORT.

def combine_url(self, api_endpoint)

Would it be possible to simply provide the base URL is full via the env, leaving it to user discretion for the base path? So that you append the API postfix to the base path. It would then allow the user to form the base path via envs as required, example base paths:

http://IP
http://immich.mydomin
https://immich.mydomain
friendlyFriend4000 commented 8 months ago

I am not completely sure what you need to get it to work. Please help understand your situation, since I use NPM instead of Traefik. You are not able to use the combination of ' http + url + port' and you'd like to have the option to use 'http + url' as a single env. Do I understand this right?

alex-007 commented 4 months ago

@friendlyFriend4000 I think the problem here is that for example in my case I use https instead of http. Also if we use defaulted port (like 443 for https or 80 for http), there is no need to set port at all. So in this case the following code doesn't give you ability to set the URLs shown in the issue.

        prefix_url = "http://"
        base_url = self.config["immich_host"]
        base_url_port = self.config["immich_port"]
        combined_url = prefix_url + base_url + ":" + base_url_port + api_endpoint

In my case it's OK, because I just put the exporter to the same docker-compose file, so I can directly access to the immich server container

  immich-exporter:
#    image: friendlyfriend/prometheus-immich-exporter
    build: ../sources/prometheus-immich-exporter
    container_name: immich_exporter
    environment:
      - IMMICH_PORT=3001
      - IMMICH_HOST=immich-server
      - IMMICH_API_TOKEN=<redacted>
#    ports:
#      - 8090:8090
    restart: unless-stopped

But if you run exporter in a different node/server, it could be a problem