Random 401 errors on refresh

I am getting the following messages in my grafana logs. I get randomly get a single 401 when I refresh my dashboard that has 8 panels with Elasticsearch as a datasource:

t=2017-10-06T12:36:43+1300 lvl=info msg="Searching for user's groups" logger=ldap filter="(&(objectclass=organization)(o=SomeOrg))"
t=2017-10-06T12:36:43+1300 lvl=dbug msg="Ldap User found" logger=ldap info="(*login.LdapUserInfo)(0xc42078d490)({\n DN: (string) (len=46) \"uid=SomeUser,o=SomeOrg,dc=SomeDomain,dc=com\",\n FirstName: (string) (len=4) \"SomeFirstName\",\n LastName: (string) (len=1) \"SomeLastName\",\n Username: (string) (len=6) \"SomeFirstName SomeLastName\",\n Email: (string) \"\",\n MemberOf: ([]string) (len=1 cap=1) {\n  (string) (len=15) \"SomeOrg\"\n }\n})\n"
t=2017-10-06T12:36:43+1300 lvl=dbug msg="Syncing user info" logger=ldap username="SomeFirstName SomeLastName"
t=2017-10-06T12:36:43+1300 lvl=eror msg="Failed to get user with id" logger=context userId=2
t=2017-10-06T12:36:43+1300 lvl=info msg="Request Completed" logger=context userId=0 orgId=0 uname= method=POST path=/api/datasources/proxy/159/_msearch status=401 remote_addr=172.20.32.206 time_ms=0s size=26

The successful requests are all caught in the nginx proxy I have set on top of Elasticsearch, but I do not get the failed 401 request in the nginx access log, suggesting the request never made it there.

My Grafana version is v4.2.0 and my database is sqlite3.

Any help to point me in the right direction would be appreciated.

Hi,

It appears to be related to session storage. When the error happens user id 2 has been extracted from the session, but there doesn’t seem to exist any user in the database with user id 2.

Seems like you’re using an LDAP integration as well. Could it be a misconfiguration of the LDAP integration? Do you see any problems in Grafana UI when this happens? Are you still identified as logged in in the UI for example?

I would suggest you try and clear your cookies and session storage.

Marcus

Hello Marcus,

Thank you for taking time to comment on my question :slight_smile:

This issue only reared its head during a performance test driven from jmeter with a 100 threads. I suspected the session issue too, and hence suggested to the tester that she use different users when trying to login and logout from multiple threads.
Because there were no problems reported by actual end users (one of the reasons maybe because of a much much lower load), we did not investigate this further.

Thanks,
Kunal.

1 Like