Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to set a display name coming from a env var in the title tag and in the page header #3515

Closed
UnclePhil opened this issue Jan 7, 2025 · 17 comments · Fixed by #3535
Closed
Labels
enhancement New feature or request

Comments

@UnclePhil
Copy link

Describe the feature you would like to see

I use Dozzle on 16 swarm clusters, and sometimes I've 4 or 5 instances open in the same browser with all difficulties to find the good one.
It will be fine to have a Env var with a display name appearing in the title tag and in the header of the application.

BTW your app is a killer one.
best regards

Describe how you would like to see this feature implemented

  • Create a DOZZLE_TITLE envvar
  • Inject it in the title tag, and in the header of the nav bar, in-place of under the svg logo

Describe any alternatives you've considered

No response

@UnclePhil UnclePhil added the enhancement New feature or request label Jan 7, 2025
@amir20
Copy link
Owner

amir20 commented Jan 7, 2025

https://dozzle.dev/guide/hostname

Isn't this already done?

@amir20 amir20 closed this as completed Jan 7, 2025
@UnclePhil
Copy link
Author

Sorry,
I totally pass over this setting.
It work perfectly.
already loaded on all clusters

@UnclePhil
Copy link
Author

And i rollback,
because when you put the --hostname flag on a swarm implementation in global mode, all swarm host in the right display have the same name. But i need the real host name !!

services:
  dozzle:
    image: amir20/dozzle:latest
    environment:
      - DOZZLE_MODE=swarm
      - DOZZLE_HOSTNAME=${CLUSTER_NAME}
      - DOZZLE_NO_ANALYTICS=true
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    ports:
      - 28080:8080
    networks:
      - dozzle
    deploy:
      mode: global
    ...

The display
image

@amir20
Copy link
Owner

amir20 commented Jan 7, 2025

What would you expect it to do? DOZZLE_HOSTNAME=${CLUSTER_NAME} is it different on each node? I haven't tested it, but if passed correctly, each hostname should change. I am not an expert on how variables work in swarm mode, but maybe you can append something else to it?

@UnclePhil
Copy link
Author

${CLUSTER_NAME) is the generic name of the cluster
The cluster is composed of multiple nodes with the pattern -0x
Like the following list
[dcltst01]
dcltst01-01
dcltst01-02
dcltst01-03
dcltst01-04
dcltst01-05

What i hope to see on the header and title is dcltst01,
but i'd like to see each hosts statistics with his own name

That's why i think that a DISPLAY_NAME var will be a good feature.
BTW I understand perfectly your --hostname flags for a host with a very long cloud generated fqdn, but the usage in cluster is not adequate imho.

best regards

@amir20
Copy link
Owner

amir20 commented Jan 7, 2025

You would have to use ${CLUSTER_NAME}-${NODE_ID}.

What i hope to see on the header and title is dcltst01,

However, I don't think this is possible now. Because is swarm mode, each node is hit at random. So the header will change on every page load.

I am not sure what the solution would be. Sorry. If you see something easy, then send a PR.

@UnclePhil
Copy link
Author

I'll check that.
and come back to you

@UnclePhil
Copy link
Author

HI, i come back to you.
I'm almost ready with a pr for the title tag, but i've still one problem because i'm not a specialist in vue and in go.

where did you fill the effective data in config array that you use in title.ts
I modify the ,

  • main.go & args.go to receive the new env var
  • config.ts to define the config interface
  • title.js to use it

if I set the default value for config it works, but dynamically not

If you have any idea it will be great
best regards
UnclePhil

@amir20
Copy link
Owner

amir20 commented Jan 9, 2025

I think you are going down the wrong path. I am still not sure what you are doing or want here. executeTemplate passes config data in index.go. This template is executed on the node and it is chosen at random. I don't think this is what you want because it would break when the page is reloaded.

Are you just trying to make it so that the chosen host is in the title? If so, --hostname should work already. I am not understand what this new variable would do.

Maybe once I see the PR it will make more sense.

@UnclePhil
Copy link
Author

I just add an DOZZLE_SWARMTITLE var loaded on all node, and the put it in title and in the navbar if hostname is not set.
And with your help it work's

i'll made some test tomorrow and i PR it

best regards

@amir20
Copy link
Owner

amir20 commented Jan 9, 2025

I think I know what you are trying to do. Perhaps you should use DOZZLE_HOSTNAME instead and change the behavior when DOZZLE_MODE=SWARM.

I'll most likely ask for that in the PR :) No reason to introduce yet another var that does the same thing as something that already exists.

@UnclePhil
Copy link
Author

This one is working with a new variable
but i respect the precedence of hostname over swarmtitle

docker run -it --rm -v /var/run/docker.sock:/var/run/docker.sock -p 8080:8080  -e DOZZLE_SWARMTITLE=UnclePhil amir20/dozzle:latest

image

I'm going to check your idea of the behavior in another run

@amir20
Copy link
Owner

amir20 commented Jan 9, 2025

There reason --hostname doesn't work because of here

dozzle/main.go

Line 174 in 5766410

localClient, err := docker.NewLocalClient(args.Hostname)

In Swarm, agents are created on all node. It should probably not take args.Hostname as an argument. I bet if you just remove that, it will just work.

@UnclePhil
Copy link
Author

  • Amir: 1 line
  • Unclephil: 5 line
    And the winner is .... Amir !!

image

Did you prefer a PR, or you process the change in a next build ??
Line 174 localClient, err := docker.NewLocalClient("")

Many thank's for the support

Ph. Koenig
UnclePhil

@amir20
Copy link
Owner

amir20 commented Jan 10, 2025

Easy enough to do on my side

@amir20
Copy link
Owner

amir20 commented Jan 10, 2025

It's merged, but I probably won't release until next week when there are a few more fixes to apply.

@UnclePhil
Copy link
Author

UnclePhil commented Jan 10, 2025 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants