Installing insights on Ubuntu 16.4

Hi, I am currently trying to get analytics installed on an EC2 (Ubuntu 16.4) instance following the instructions located at :

https://openedx.atlassian.net/wiki/spaces/OpenOPS/pages/43385371/edX+Analytics+Installation

I’m currently using Tutor to deploy OpenEDX (koa.2) using an external MySQL (AWS RDS).
I have a tracking.log file I grabbed from the cms container and put put into the home directory of the EC2 analytics instance (as instructed).

I’m currently stuck on step 3 when running the command ansible-playbook -i localhost, -c local analytics_single.yml --extra-vars "INSIGHTS_LMS_BASE=<myLMS-site>"

The following log (I apologize if its one whole string)
TASK [edx_django_service : migrate database] ************************************************************************************************************************************************************************ fatal: [localhost]: FAILED! => {"changed": true, "cmd": ["make", "migrate"], "delta": "0:00:00.785855", "end": "2021-04-07 02:57:08.871323", "msg": "non-zero return code", "rc": 2, "start": "2021-04-07 02:57:08.085468", "stderr": "Traceback (most recent call last):\n File \"/edx/app/analytics_api/venvs/analytics_api/lib/python3.8/site-packages/django/db/backends/base/base.py\", line 217, in ensure_connection\n self.connect()\n File \"/edx/app/analytics_api/venvs/analytics_api/lib/python3.8/site-packages/django/db/backends/base/base.py\", line 195, in connect\n self.connection = self.get_new_connection(conn_params)\n File \"/edx/app/analytics_api/venvs/analytics_api/lib/python3.8/site-packages/django/db/backends/mysql/base.py\", line 227, in get_new_connection\n return Database.connect(**conn_params)\n File \"/edx/app/analytics_api/venvs/analytics_api/lib/python3.8/site-packages/MySQLdb/__init__.py\", line 130, in Connect\n return Connection(*args, **kwargs)\n File \"/edx/app/analytics_api/venvs/analytics_api/lib/python3.8/site-packages/MySQLdb/connections.py\", line 185, in __init__\n super().__init__(*args, **kwargs2)\nMySQLdb._exceptions.OperationalError: (2002, \"Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)\")\n\nThe above exception was the direct cause of the following exception:\n\nTraceback (most recent call last):\n File \"./manage.py\", line 10, in <module>\n execute_from_command_line(sys.argv)\n File \"/edx/app/analytics_api/venvs/analytics_api/lib/python3.8/site-packages/django/core/management/__init__.py\", line 381, in execute_from_command_line\n utility.execute()\n File \"/edx/app/analytics_api/venvs/analytics_api/lib/python3.8/site-packages/django/core/management/__init__.py\", line 375, in execute\n self.fetch_command(subcommand).run_from_argv(self.argv)\n File \"/edx/app/analytics_api/venvs/analytics_api/lib/python3.8/site-packages/django/core/management/base.py\", line 323, in run_from_argv\n self.execute(*args, **cmd_options)\n File \"/edx/app/analytics_api/venvs/analytics_api/lib/python3.8/site-packages/django/core/management/base.py\", line 361, in execute\n self.check()\n File \"/edx/app/analytics_api/venvs/analytics_api/lib/python3.8/site-packages/django/core/management/base.py\", line 387, in check\n all_issues = self._run_checks(\n File \"/edx/app/analytics_api/venvs/analytics_api/lib/python3.8/site-packages/django/core/management/commands/migrate.py\", line 64, in _run_checks\n issues = run_checks(tags=[Tags.database])\n File \"/edx/app/analytics_api/venvs/analytics_api/lib/python3.8/site-packages/django/core/checks/registry.py\", line 72, in run_checks\n new_errors = check(app_configs=app_configs)\n File \"/edx/app/analytics_api/venvs/analytics_api/lib/python3.8/site-packages/django/core/checks/database.py\", line 10, in check_database_backends\n issues.extend(conn.validation.check(**kwargs))\n File \"/edx/app/analytics_api/venvs/analytics_api/lib/python3.8/site-packages/django/db/backends/mysql/validation.py\", line 9, in check\n issues.extend(self._check_sql_mode(**kwargs))\n File \"/edx/app/analytics_api/venvs/analytics_api/lib/python3.8/site-packages/django/db/backends/mysql/validation.py\", line 13, in _check_sql_mode\n with self.connection.cursor() as cursor:\n File \"/edx/app/analytics_api/venvs/analytics_api/lib/python3.8/site-packages/django/db/backends/base/base.py\", line 256, in cursor\n return self._cursor()\n File \"/edx/app/analytics_api/venvs/analytics_api/lib/python3.8/site-packages/django/db/backends/base/base.py\", line 233, in _cursor\n self.ensure_connection()\n File \"/edx/app/analytics_api/venvs/analytics_api/lib/python3.8/site-packages/django/db/backends/base/base.py\", line 217, in ensure_connection\n self.connect()\n File \"/edx/app/analytics_api/venvs/analytics_api/lib/python3.8/site-packages/django/db/utils.py\", line 89, in __exit__\n raise dj_exc_value.with_traceback(traceback) from exc_value\n File \"/edx/app/analytics_api/venvs/analytics_api/lib/python3.8/site-packages/django/db/backends/base/base.py\", line 217, in ensure_connection\n self.connect()\n File \"/edx/app/analytics_api/venvs/analytics_api/lib/python3.8/site-packages/django/db/backends/base/base.py\", line 195, in connect\n self.connection = self.get_new_connection(conn_params)\n File \"/edx/app/analytics_api/venvs/analytics_api/lib/python3.8/site-packages/django/db/backends/mysql/base.py\", line 227, in get_new_connection\n return Database.connect(**conn_params)\n File \"/edx/app/analytics_api/venvs/analytics_api/lib/python3.8/site-packages/MySQLdb/__init__.py\", line 130, in Connect\n return Connection(*args, **kwargs)\n File \"/edx/app/analytics_api/venvs/analytics_api/lib/python3.8/site-packages/MySQLdb/connections.py\", line 185, in __init__\n super().__init__(*args, **kwargs2)\ndjango.db.utils.OperationalError: (2002, \"Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)\")\nmake: *** [migrate] Error 1", "stderr_lines": ["Traceback (most recent call last):", " File \"/edx/app/analytics_api/venvs/analytics_api/lib/python3.8/site-packages/django/db/backends/base/base.py\", line 217, in ensure_connection", " self.connect()", " File \"/edx/app/analytics_api/venvs/analytics_api/lib/python3.8/site-packages/django/db/backends/base/base.py\", line 195, in connect", " self.connection = self.get_new_connection(conn_params)", " File \"/edx/app/analytics_api/venvs/analytics_api/lib/python3.8/site-packages/django/db/backends/mysql/base.py\", line 227, in get_new_connection", " return Database.connect(**conn_params)", " File \"/edx/app/analytics_api/venvs/analytics_api/lib/python3.8/site-packages/MySQLdb/__init__.py\", line 130, in Connect", " return Connection(*args, **kwargs)", " File \"/edx/app/analytics_api/venvs/analytics_api/lib/python3.8/site-packages/MySQLdb/connections.py\", line 185, in __init__", " super().__init__(*args, **kwargs2)", "MySQLdb._exceptions.OperationalError: (2002, \"Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)\")", "", "The above exception was the direct cause of the following exception:", "", "Traceback (most recent call last):", " File \"./manage.py\", line 10, in <module>", " execute_from_command_line(sys.argv)", " File \"/edx/app/analytics_api/venvs/analytics_api/lib/python3.8/site-packages/django/core/management/__init__.py\", line 381, in execute_from_command_line", " utility.execute()", " File \"/edx/app/analytics_api/venvs/analytics_api/lib/python3.8/site-packages/django/core/management/__init__.py\", line 375, in execute", " self.fetch_command(subcommand).run_from_argv(self.argv)", " File \"/edx/app/analytics_api/venvs/analytics_api/lib/python3.8/site-packages/django/core/management/base.py\", line 323, in run_from_argv", " self.execute(*args, **cmd_options)", " File \"/edx/app/analytics_api/venvs/analytics_api/lib/python3.8/site-packages/django/core/management/base.py\", line 361, in execute", " self.check()", " File \"/edx/app/analytics_api/venvs/analytics_api/lib/python3.8/site-packages/django/core/management/base.py\", line 387, in check", " all_issues = self._run_checks(", " File \"/edx/app/analytics_api/venvs/analytics_api/lib/python3.8/site-packages/django/core/management/commands/migrate.py\", line 64, in _run_checks", " issues = run_checks(tags=[Tags.database])", " File \"/edx/app/analytics_api/venvs/analytics_api/lib/python3.8/site-packages/django/core/checks/registry.py\", line 72, in run_checks", " new_errors = check(app_configs=app_configs)", " File \"/edx/app/analytics_api/venvs/analytics_api/lib/python3.8/site-packages/django/core/checks/database.py\", line 10, in check_database_backends", " issues.extend(conn.validation.check(**kwargs))", " File \"/edx/app/analytics_api/venvs/analytics_api/lib/python3.8/site-packages/django/db/backends/mysql/validation.py\", line 9, in check", " issues.extend(self._check_sql_mode(**kwargs))", " File \"/edx/app/analytics_api/venvs/analytics_api/lib/python3.8/site-packages/django/db/backends/mysql/validation.py\", line 13, in _check_sql_mode", " with self.connection.cursor() as cursor:", " File \"/edx/app/analytics_api/venvs/analytics_api/lib/python3.8/site-packages/django/db/backends/base/base.py\", line 256, in cursor", " return self._cursor()", " File \"/edx/app/analytics_api/venvs/analytics_api/lib/python3.8/site-packages/django/db/backends/base/base.py\", line 233, in _cursor", " self.ensure_connection()", " File \"/edx/app/analytics_api/venvs/analytics_api/lib/python3.8/site-packages/django/db/backends/base/base.py\", line 217, in ensure_connection", " self.connect()", " File \"/edx/app/analytics_api/venvs/analytics_api/lib/python3.8/site-packages/django/db/utils.py\", line 89, in __exit__", " raise dj_exc_value.with_traceback(traceback) from exc_value", " File \"/edx/app/analytics_api/venvs/analytics_api/lib/python3.8/site-packages/django/db/backends/base/base.py\", line 217, in ensure_connection", " self.connect()", " File \"/edx/app/analytics_api/venvs/analytics_api/lib/python3.8/site-packages/django/db/backends/base/base.py\", line 195, in connect", " self.connection = self.get_new_connection(conn_params)", " File \"/edx/app/analytics_api/venvs/analytics_api/lib/python3.8/site-packages/django/db/backends/mysql/base.py\", line 227, in get_new_connection", " return Database.connect(**conn_params)", " File \"/edx/app/analytics_api/venvs/analytics_api/lib/python3.8/site-packages/MySQLdb/__init__.py\", line 130, in Connect", " return Connection(*args, **kwargs)", " File \"/edx/app/analytics_api/venvs/analytics_api/lib/python3.8/site-packages/MySQLdb/connections.py\", line 185, in __init__", " super().__init__(*args, **kwargs2)", "django.db.utils.OperationalError: (2002, \"Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)\")", "make: *** [migrate] Error 1"], "stdout": "./manage.py migrate --noinput --run-syncdb --database=default\nMakefile:106: recipe for target 'migrate' failed", "stdout_lines": ["./manage.py migrate --noinput --run-syncdb --database=default", "Makefile:106: recipe for target 'migrate' failed"]}

I’ve checked the comments below in the article by some people having issues and read about not using the master branch when checking out the repo. So I’ve used the following command: git clone --depth 1 --branch open-release/koa.2 https://github.com/edx/configuration. However, it seems like the problem still persists. As, we’re still testing our deployment of edx we haven’t set up https yet, but according to the instructions, it isn’t required (and shouldn’t affect this step). Does anyone have any insight on what could be causing this error?

I guess the issue is similar to: Installing INSIGHTS: Database Migrate Error. However, there’s no permission issues from the log.

Hi @c3ho,

This error also can mean that there is no mysqld.sock, which in turn means that MySQL is down or not installed.

Does your analytics server have MySQL installed? (You can check it quickly by running sudo service mysql status).

Consider this line from the playbook. You should set EDXAPP_MYSQL_HOST Ansible variable either to localhost (in this case, local MySQL will be installed) or address of your RDS instance.

1 Like

Hi @0x29a,

Thanks for the reply!

I’ve tried both methods: setting EDXAPP_MYSQL_HOST variable to

EDXAPP_MYSQL_HOST=‘localhost’`: working so far!

else:

EDXAPP_MYSQL_HOST=<EDX RDS instance>: I had to make some more changes to the file.

COMMON_ENABLE_AWS_ROLE: True
roles
 - role: aws
   when: COMMON_ENABLE_AWS_ROLE == True

I receive an error with the migrate@localhost doesn’t have permissions, shelled into the RDS instance in this case and created a user with the following taken from the post:

I still got a connection error so I tried starting a local instance of MySQL also. Created: reports001, api001 and migrate on the EDX MySQL database (and the local instance):

CREATE USER '<user>'@'%' IDENTIFIED BY '<password>'
GRANT ALL PRIVILEGES ON `reports`.* TO '<user>'@'%';
GRANT ALL PRIVILEGES ON `dashboard`.* TO '<user>'@'%';
GRANT ALL PRIVILEGES ON `analytics-api`.* TO '<user>'@'%';
FLUSH PRIVILEGES;

Now getting an issue which I’m currently looking into: seems like the api-analytics DB is not created?
tal: [localhost]: FAILED! => {"changed": true, "cmd": ["make", "migrate"], "delta": "0:00:00.803559", "end": "2021-04-13 01:47:59.160978", "msg": "non-zero return code", "rc": 2, "start": "2021-04-13 01:47:58.357419", "stderr": "Traceback (most recent call last):\n File \"/edx/app/analytics_api/venvs/analytics_api/lib/python3.8/site-packages/django/db/backends/base/base.py\", line 217, in ensure_connection\n self.connect()\n File \"/edx/app/analytics_api/venvs/analytics_api/lib/python3.8/site-packages/django/db/backends/base/base.py\", line 195, in connect\n self.connection = self.get_new_connection(conn_params)\n File \"/edx/app/analytics_api/venvs/analytics_api/lib/python3.8/site-packages/django/db/backends/mysql/base.py\", line 227, in get_new_connection\n return Database.connect(**conn_params)\n File \"/edx/app/analytics_api/venvs/analytics_api/lib/python3.8/site-packages/MySQLdb/__init__.py\", line 130, in Connect\n return Connection(*args, **kwargs)\n File \"/edx/app/analytics_api/venvs/analytics_api/lib/python3.8/site-packages/MySQLdb/connections.py\", line 185, in __init__\n super().__init__(*args, **kwargs2)\nMySQLdb._exceptions.OperationalError: (1049, \"Unknown database 'analytics-api'\")\n\nThe above exception was the direct cause of the following exception:\n\nTraceback (most recent call last):\n File \"./manage.py\", line 10, in <module>\n execute_from_command_line(sys.argv)\n File \"/edx/app/analytics_api/venvs/analytics_api/lib/python3.8/site-packages/django/core/management/__init__.py\", line 381, in execute_from_command_line\n utility.execute()\n File \"/edx/app/analytics_api/venvs/analytics_api/lib/python3.8/site-packages/django/core/management/__init__.py\", line 375, in execute\n self.fetch_command(subcommand).run_from_argv(self.argv)\n File \"/edx/app/analytics_api/venvs/analytics_api/lib/python3.8/site-packages/django/core/management/base.py\", line 323, in run_from_argv\n self.execute(*args, **cmd_options)\n File \"/edx/app/analytics_api/venvs/analytics_api/lib/python3.8/site-packages/django/core/management/base.py\", line 361, in execute\n self.check()\n File \"/edx/app/analytics_api/venvs/analytics_api/lib/python3.8/site-packages/django/core/management/base.py\", line 387, in check\n all_issues = self._run_checks(\n File \"/edx/app/analytics_api/venvs/analytics_api/lib/python3.8/site-packages/django/core/management/commands/migrate.py\", line 64, in _run_checks\n issues = run_checks(tags=[Tags.database])\n File \"/edx/app/analytics_api/venvs/analytics_api/lib/python3.8/site-packages/django/core/checks/registry.py\", line 72, in run_checks\n new_errors = check(app_configs=app_configs)\n File \"/edx/app/analytics_api/venvs/analytics_api/lib/python3.8/site-packages/django/core/checks/database.py\", line 10, in check_database_backends\n issues.extend(conn.validation.check(**kwargs))\n File \"/edx/app/analytics_api/venvs/analytics_api/lib/python3.8/site-packages/django/db/backends/mysql/validation.py\", line 9, in check\n issues.extend(self._check_sql_mode(**kwargs))\n File \"/edx/app/analytics_api/venvs/analytics_api/lib/python3.8/site-packages/django/db/backends/mysql/validation.py\", line 13, in _check_sql_mode\n with self.connection.cursor() as cursor:\n File \"/edx/app/analytics_api/venvs/analytics_api/lib/python3.8/site-packages/django/db/backends/base/base.py\", line 256, in cursor\n return self._cursor()\n File \"/edx/app/analytics_api/venvs/analytics_api/lib/python3.8/site-packages/django/db/backends/base/base.py\", line 233, in _cursor\n self.ensure_connection()\n File \"/edx/app/analytics_api/venvs/analytics_api/lib/python3.8/site-packages/django/db/backends/base/base.py\", line 217, in ensure_connection\n self.connect()\n File \"/edx/app/analytics_api/venvs/analytics_api/lib/python3.8/site-packages/django/db/utils.py\", line 89, in __exit__\n raise dj_exc_value.with_traceback(traceback) from exc_value\n File \"/edx/app/analytics_api/venvs/analytics_api/lib/python3.8/site-packages/django/db/backends/base/base.py\", line 217, in ensure_connection\n self.connect()\n File \"/edx/app/analytics_api/venvs/analytics_api/lib/python3.8/site-packages/django/db/backends/base/base.py\", line 195, in connect\n self.connection = self.get_new_connection(conn_params)\n File \"/edx/app/analytics_api/venvs/analytics_api/lib/python3.8/site-packages/django/db/backends/mysql/base.py\", line 227, in get_new_connection\n return Database.connect(**conn_params)\n File \"/edx/app/analytics_api/venvs/analytics_api/lib/python3.8/site-packages/MySQLdb/__init__.py\", line 130, in Connect\n return Connection(*args, **kwargs)\n File \"/edx/app/analytics_api/venvs/analytics_api/lib/python3.8/site-packages/MySQLdb/connections.py\", line 185, in __init__\n super().__init__(*args, **kwargs2)\ndjango.db.utils.OperationalError: (1049, \"Unknown database 'analytics-api'\")\nmake: *** [migrate] Error 1", "stderr_lines": ["Traceback (most recent call last):", " File \"/edx/app/analytics_api/venvs/analytics_api/lib/python3.8/site-packages/django/db/backends/base/base.py\", line 217, in ensure_connection", " self.connect()", " File \"/edx/app/analytics_api/venvs/analytics_api/lib/python3.8/site-packages/django/db/backends/base/base.py\", line 195, in connect", " self.connection = self.get_new_connection(conn_params)", " File \"/edx/app/analytics_api/venvs/analytics_api/lib/python3.8/site-packages/django/db/backends/mysql/base.py\", line 227, in get_new_connection", " return Database.connect(**conn_params)", " File \"/edx/app/analytics_api/venvs/analytics_api/lib/python3.8/site-packages/MySQLdb/__init__.py\", line 130, in Connect", " return Connection(*args, **kwargs)", " File \"/edx/app/analytics_api/venvs/analytics_api/lib/python3.8/site-packages/MySQLdb/connections.py\", line 185, in __init__", " super().__init__(*args, **kwargs2)", "MySQLdb._exceptions.OperationalError: (1049, \"Unknown database 'analytics-api'\")", "", "The above exception was the direct cause of the following exception:", "", "Traceback (most recent call last):", " File \"./manage.py\", line 10, in <module>", " execute_from_command_line(sys.argv)", " File \"/edx/app/analytics_api/venvs/analytics_api/lib/python3.8/site-packages/django/core/management/__init__.py\", line 381, in execute_from_command_line", " utility.execute()", " File \"/edx/app/analytics_api/venvs/analytics_api/lib/python3.8/site-packages/django/core/management/__init__.py\", line 375, in execute", " self.fetch_command(subcommand).run_from_argv(self.argv)", " File \"/edx/app/analytics_api/venvs/analytics_api/lib/python3.8/site-packages/django/core/management/base.py\", line 323, in run_from_argv", " self.execute(*args, **cmd_options)", " File \"/edx/app/analytics_api/venvs/analytics_api/lib/python3.8/site-packages/django/core/management/base.py\", line 361, in execute", " self.check()", " File \"/edx/app/analytics_api/venvs/analytics_api/lib/python3.8/site-packages/django/core/management/base.py\", line 387, in check", " all_issues = self._run_checks(", " File \"/edx/app/analytics_api/venvs/analytics_api/lib/python3.8/site-packages/django/core/management/commands/migrate.py\", line 64, in _run_checks", " issues = run_checks(tags=[Tags.database])", " File \"/edx/app/analytics_api/venvs/analytics_api/lib/python3.8/site-packages/django/core/checks/registry.py\", line 72, in run_checks", " new_errors = check(app_configs=app_configs)", " File \"/edx/app/analytics_api/venvs/analytics_api/lib/python3.8/site-packages/django/core/checks/database.py\", line 10, in check_database_backends", " issues.extend(conn.validation.check(**kwargs))", " File \"/edx/app/analytics_api/venvs/analytics_api/lib/python3.8/site-packages/django/db/backends/mysql/validation.py\", line 9, in check", " issues.extend(self._check_sql_mode(**kwargs))", " File \"/edx/app/analytics_api/venvs/analytics_api/lib/python3.8/site-packages/django/db/backends/mysql/validation.py\", line 13, in _check_sql_mode", " with self.connection.cursor() as cursor:", " File \"/edx/app/analytics_api/venvs/analytics_api/lib/python3.8/site-packages/django/db/backends/base/base.py\", line 256, in cursor", " return self._cursor()", " File \"/edx/app/analytics_api/venvs/analytics_api/lib/python3.8/site-packages/django/db/backends/base/base.py\", line 233, in _cursor", " self.ensure_connection()", " File \"/edx/app/analytics_api/venvs/analytics_api/lib/python3.8/site-packages/django/db/backends/base/base.py\", line 217, in ensure_connection", " self.connect()", " File \"/edx/app/analytics_api/venvs/analytics_api/lib/python3.8/site-packages/django/db/utils.py\", line 89, in __exit__", " raise dj_exc_value.with_traceback(traceback) from exc_value", " File \"/edx/app/analytics_api/venvs/analytics_api/lib/python3.8/site-packages/django/db/backends/base/base.py\", line 217, in ensure_connection", " self.connect()", " File \"/edx/app/analytics_api/venvs/analytics_api/lib/python3.8/site-packages/django/db/backends/base/base.py\", line 195, in connect", " self.connection = self.get_new_connection(conn_params)", " File \"/edx/app/analytics_api/venvs/analytics_api/lib/python3.8/site-packages/django/db/backends/mysql/base.py\", line 227, in get_new_connection", " return Database.connect(**conn_params)", " File \"/edx/app/analytics_api/venvs/analytics_api/lib/python3.8/site-packages/MySQLdb/__init__.py\", line 130, in Connect", " return Connection(*args, **kwargs)", " File \"/edx/app/analytics_api/venvs/analytics_api/lib/python3.8/site-packages/MySQLdb/connections.py\", line 185, in __init__", " super().__init__(*args, **kwargs2)", "django.db.utils.OperationalError: (1049, \"Unknown database 'analytics-api'\")", "make: *** [migrate] Error 1"], "stdout": "./manage.py migrate --noinput --run-syncdb --database=default\nMakefile:106: recipe for target 'migrate' failed", "stdout_lines": ["./manage.py migrate --noinput --run-syncdb --database=default", "Makefile:106: recipe for target 'migrate' failed"]}

You right, @c3ho.

Consider tasks from this file. They are performed when EDXAPP_MYSQL_HOST='localhost'.

When you’re using an external database, you have to perform the same operations to prepare it.

Thanks @0x29a! I want to just say a big thank you for taking the time to answer my questions, its my first time working with something so complex…

I opted to go with a localhost installation for now since I want to get insights working at least and it seems like the shortest path.

I’m near the last steps of the guide and configuring the OAuth2:

In <lms Domain>/admin/oauth2_provider/application I added a new application with the following:

Client id: <generated Client id>
User: <created an insights superuser>
Redirect urls: <insightsDomain>:18110/complete/edx-oauth2/
Client type: Confidential
Authorization grant type: Authorization code
Client secret: <generated Client secret>
Name: <insights-sso>
Skip authorization: enabled

According to the instructions the Redirect urls should be <insightsDomain>:18110/complete/edx-oidc/, however it seems it has been discontinued so I changed it to <insightsDomain>:18110/complete/edx-oauth2/ instead. Also the suggested client method in step 7 seems to not exist anymore for koa.

I also have the following values for the insights.yml file:

SOCIAL_AUTH_EDX_OAUTH2_ISSUER: <lmsDomain>
SOCIAL_AUTH_EDX_OAUTH2_KEY: <generated Client id>
SOCIAL_AUTH_EDX_OAUTH2_LOGOUT_URL: <lmsDomain>/logout
SOCIAL_AUTH_EDX_OAUTH2_SECRET: <generated Client secret>
SOCIAL_AUTH_EDX_OAUTH2_URL_ROOT: <lmsDomain>
SOCIAL_AUTH_REDIRECT_IS_HTTPS: false

In <lms Domain>/admin/oauth_dispath/applicationaccess/
I also created a record insights with the following:

Application: insights
Scopes: user_id
Filters: <empty>

Am I missing anything or doing something wrong? When I try to log in at :18110 and login with credentials I get a 500 error:

Log from insights:

Apr 14 04:17:28 ip-172-31-69-160 [service_variant=insights][django.request][env:no_env] ERROR [ip-172-31-69-160  18004] [log.py:222] - Internal Server Error: /complete/edx-oauth2/
Traceback (most recent call last):
  File "/edx/app/insights/venvs/insights/lib/python3.8/site-packages/django/core/handlers/exception.py", line 34, in inner
    response = get_response(request)
  File "/edx/app/insights/venvs/insights/lib/python3.8/site-packages/django/core/handlers/base.py", line 115, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/edx/app/insights/venvs/insights/lib/python3.8/site-packages/django/core/handlers/base.py", line 113, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/edx/app/insights/venvs/insights/lib/python3.8/site-packages/django/views/decorators/cache.py", line 44, in _wrapped_view_func
    response = view_func(request, *args, **kwargs)
  File "/edx/app/insights/venvs/insights/lib/python3.8/site-packages/django/views/decorators/csrf.py", line 54, in wrapped_view
    return view_func(*args, **kwargs)
  File "/edx/app/insights/venvs/insights/src/social-auth-app-django/social_django/utils.py", line 49, in wrapper
    return func(request, backend, *args, **kwargs)
  File "/edx/app/insights/venvs/insights/src/social-auth-app-django/social_django/views.py", line 31, in complete
    return do_complete(request.backend, _do_login, user=request.user,
  File "/edx/app/insights/venvs/insights/lib/python3.8/site-packages/social_core/actions.py", line 43, in do_complete
    user = backend.complete(user=user, *args, **kwargs)
  File "/edx/app/insights/venvs/insights/lib/python3.8/site-packages/social_core/backends/base.py", line 40, in complete
    return self.auth_complete(*args, **kwargs)
  File "/edx/app/insights/venvs/insights/lib/python3.8/site-packages/auth_backends/backends.py", line 98, in auth_complete
    user = super().auth_complete(*args, **kwargs)
  File "/edx/app/insights/venvs/insights/lib/python3.8/site-packages/social_core/utils.py", line 251, in wrapper
    return func(*args, **kwargs)
  File "/edx/app/insights/venvs/insights/lib/python3.8/site-packages/social_core/backends/oauth.py", line 387, in auth_complete
    self.process_error(self.data)
  File "/edx/app/insights/venvs/insights/lib/python3.8/site-packages/social_core/backends/oauth.py", line 379, in process_error
    raise AuthFailed(self, data.get('error_description') or
social_core.exceptions.AuthFailed: Authentication failed: unauthorized_client

I saw a post mentioning to get around this issue, we could downgrade an earlier version of insights. However, I am currently deployed on koa and don’t think that is an option.