Resolve Grafana missing login form issue

Resolve Grafana missing login form issue

When firing up your Grafana server, you may be faced with a login screen that has no login form to input your username or password. This may be caused by various issues but I believe my experience is a shared one.

100% of the time, my problem arose from config settings used to query the database during the set-up stage. Case point: I tried to alter the default configuration to enable me to share iframe embeds without prompting a user to log in. The code snippet below illustrates a custom grafana.ini with configurations to allow sharing of embedded iframes.

# Allow iframe embeds
[security]
allow_embedding = true

[auth]
disable_login_form = true

[auth.anonymous]
enabled = true
org_name = My_Custom_Org
org_role = Viewer

The variable responsible for the failure when setting up the server configs, and consequently the disappearing of the login form, was org_name as viewed from the logs.

logger=authn.service t=2024-03-11T14:15:39.386250697Z level=warn msg="Failed to authenticate request" client=auth.client.session error="user token not found"
logger=authn.anonymous t=2024-03-11T14:15:39.871309723Z level=error msg="Failed to find organization" name=My_Custom_Org error="[org.notFound] failed to get org by name: My_Custom_Org"
logger=authn.service t=2024-03-11T14:15:39.87140521Z level=info msg="Failed to authenticate request" client=auth.client.anonymous error="[org.notFound] failed to get org by name: My_Custom_Org"
logger=context userId=0 orgId=0 uname= t=2024-03-11T14:15:39.8715094Z level=info msg="Request Completed" method=GET path=/ status=302 remote_addr=172.17.0.1 time_ms=973 duration=973.774443ms size=29 referer= handler=/
logger=authn.service t=2024-03-11T14:15:40.361256915Z level=warn msg="Failed to authenticate request" client=auth.client.session error="user token not found"
logger=authn.anonymous t=2024-03-11T14:15:40.850114152Z level=error msg="Failed to find organization" name=My_Custom_Org error="[org.notFound] failed to get org by name: My_Custom_Org"
logger=authn.service t=2024-03-11T14:15:40.85024983Z level=info msg="Failed to authenticate request" client=auth.client.anonymous error="[org.notFound] failed to get org by name: My_Custom_Org"

Solution

Setting some Grafana configurations using environment variables using Docker's -e option would be more appropriate than issuing them in the configuration files, grafana.ini or custom.ini.

If you use Dokku, you can alter some fields like the organization name for anonymous users and then set the GF_AUTH_ANONYMOUS_ORG_NAME environment variable using dokku config. PS This will only work if you are using a persistent storage.

Rummaging through the internet, I found a similar issue in the Grafana Community forum that would be useful too.